[Notes] [Git][BuildStream/buildstream][master] 3 commits: tests: Use cli.configure for custom logging test



Title: GitLab

richardmaw-codethink pushed to branch master at BuildStream / buildstream

Commits:

2 changed files:

Changes:

  • tests/frontend/logging.py
    ... ... @@ -54,8 +54,7 @@ def test_custom_logging(cli, tmpdir, datafiles):
    54 54
     
    
    55 55
         custom_log_format = '%{elapsed},%{elapsed-us},%{wallclock},%{key},%{element},%{action},%{message}'
    
    56 56
         user_config = {'logging': {'message-format': custom_log_format}}
    
    57
    -    user_config_file = str(tmpdir.join('buildstream.conf'))
    
    58
    -    _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file)
    
    57
    +    cli.configure(user_config)
    
    59 58
     
    
    60 59
         # Create our repo object of the given source type with
    
    61 60
         # the bin files, and then collect the initial ref.
    
    ... ... @@ -75,7 +74,7 @@ def test_custom_logging(cli, tmpdir, datafiles):
    75 74
                                 element_name))
    
    76 75
     
    
    77 76
         # Now try to fetch it
    
    78
    -    result = cli.run(project=project, args=['-c', user_config_file, 'fetch', element_name])
    
    77
    +    result = cli.run(project=project, args=['fetch', element_name])
    
    79 78
         result.assert_success()
    
    80 79
     
    
    81 80
         m = re.search("\d\d:\d\d:\d\d,\d\d:\d\d:\d\d.\d{6},\d\d:\d\d:\d\d,,,SUCCESS,Checking sources", result.stderr)
    

  • tests/frontend/workspace.py
    ... ... @@ -43,10 +43,13 @@ DATA_DIR = os.path.join(
    43 43
     )
    
    44 44
     
    
    45 45
     
    
    46
    -def open_workspace(cli, tmpdir, datafiles, kind, track, suffix='', workspace_dir=None):
    
    46
    +def open_workspace(cli, tmpdir, datafiles, kind, track, suffix='', workspace_dir=None, project_path=None):
    
    47 47
         if not workspace_dir:
    
    48 48
             workspace_dir = os.path.join(str(tmpdir), 'workspace{}'.format(suffix))
    
    49
    -    project_path = os.path.join(datafiles.dirname, datafiles.basename)
    
    49
    +    if not project_path:
    
    50
    +        project_path = os.path.join(datafiles.dirname, datafiles.basename)
    
    51
    +    else:
    
    52
    +        shutil.copytree(os.path.join(datafiles.dirname, datafiles.basename), project_path)
    
    50 53
         bin_files_path = os.path.join(project_path, 'files', 'bin-files')
    
    51 54
         element_path = os.path.join(project_path, 'elements')
    
    52 55
         element_name = 'workspace-test-{}{}.bst'.format(kind, suffix)
    
    ... ... @@ -218,41 +221,42 @@ def test_close(cli, tmpdir, datafiles, kind):
    218 221
     
    
    219 222
     @pytest.mark.datafiles(DATA_DIR)
    
    220 223
     def test_close_external_after_move_project(cli, tmpdir, datafiles):
    
    221
    -    tmp_parent = os.path.dirname(str(tmpdir))
    
    222
    -    workspace_dir = os.path.join(tmp_parent, "workspace")
    
    223
    -    element_name, project_path, _ = open_workspace(cli, tmpdir, datafiles, 'git', False, "", workspace_dir)
    
    224
    +    workspace_dir = os.path.join(str(tmpdir), "workspace")
    
    225
    +    project_path = os.path.join(str(tmpdir), 'initial_project')
    
    226
    +    element_name, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', False, "", workspace_dir, project_path)
    
    224 227
         assert os.path.exists(workspace_dir)
    
    225
    -    tmp_dir = os.path.join(tmp_parent, 'external_project')
    
    226
    -    shutil.move(project_path, tmp_dir)
    
    227
    -    assert os.path.exists(tmp_dir)
    
    228
    +    moved_dir = os.path.join(str(tmpdir), 'external_project')
    
    229
    +    shutil.move(project_path, moved_dir)
    
    230
    +    assert os.path.exists(moved_dir)
    
    228 231
     
    
    229 232
         # Close the workspace
    
    230
    -    result = cli.run(configure=False, project=tmp_dir, args=[
    
    233
    +    result = cli.run(project=moved_dir, args=[
    
    231 234
             'workspace', 'close', '--remove-dir', element_name
    
    232 235
         ])
    
    233 236
         result.assert_success()
    
    234 237
     
    
    235 238
         # Assert the workspace dir has been deleted
    
    236 239
         assert not os.path.exists(workspace_dir)
    
    237
    -    # Move directory back inside tmp directory so it can be recognised
    
    238
    -    shutil.move(tmp_dir, project_path)
    
    239 240
     
    
    240 241
     
    
    241 242
     @pytest.mark.datafiles(DATA_DIR)
    
    242 243
     def test_close_internal_after_move_project(cli, tmpdir, datafiles):
    
    243
    -    element_name, project, _ = open_workspace(cli, tmpdir, datafiles, 'git', False)
    
    244
    -    tmp_dir = os.path.join(os.path.dirname(str(tmpdir)), 'external_project')
    
    245
    -    shutil.move(str(tmpdir), tmp_dir)
    
    246
    -    assert os.path.exists(tmp_dir)
    
    244
    +    initial_dir = os.path.join(str(tmpdir), 'initial_project')
    
    245
    +    initial_workspace = os.path.join(initial_dir, 'workspace')
    
    246
    +    element_name, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', False,
    
    247
    +                                        workspace_dir=initial_workspace, project_path=initial_dir)
    
    248
    +    moved_dir = os.path.join(str(tmpdir), 'internal_project')
    
    249
    +    shutil.move(initial_dir, moved_dir)
    
    250
    +    assert os.path.exists(moved_dir)
    
    247 251
     
    
    248 252
         # Close the workspace
    
    249
    -    result = cli.run(configure=False, project=tmp_dir, args=[
    
    253
    +    result = cli.run(project=moved_dir, args=[
    
    250 254
             'workspace', 'close', '--remove-dir', element_name
    
    251 255
         ])
    
    252 256
         result.assert_success()
    
    253 257
     
    
    254 258
         # Assert the workspace dir has been deleted
    
    255
    -    workspace = os.path.join(tmp_dir, 'workspace')
    
    259
    +    workspace = os.path.join(moved_dir, 'workspace')
    
    256 260
         assert not os.path.exists(workspace)
    
    257 261
     
    
    258 262
     
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]