[Notes] [Git][BuildStream/buildstream][valentindavid/bst_workspace_open_force_does_nothing-1.2] 5 commits: Fix crash when --debug is passed



Title: GitLab

Valentin David pushed to branch valentindavid/bst_workspace_open_force_does_nothing-1.2 at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • buildstream/_artifactcache/cascache.py
    ... ... @@ -845,6 +845,9 @@ class _CASRemote():
    845 845
     
    
    846 846
     
    
    847 847
     def _grouper(iterable, n):
    
    848
    -    # pylint: disable=stop-iteration-return
    
    849 848
         while True:
    
    850
    -        yield itertools.chain([next(iterable)], itertools.islice(iterable, n - 1))
    849
    +        try:
    
    850
    +            current = next(iterable)
    
    851
    +        except StopIteration:
    
    852
    +            return
    
    853
    +        yield itertools.chain([current], itertools.islice(iterable, n - 1))

  • buildstream/_stream.py
    ... ... @@ -478,7 +478,7 @@ class Stream():
    478 478
     
    
    479 479
             # Check for workspace config
    
    480 480
             workspace = workspaces.get_workspace(target._get_full_name())
    
    481
    -        if workspace:
    
    481
    +        if workspace and not force:
    
    482 482
                 raise StreamError("Workspace '{}' is already defined at: {}"
    
    483 483
                                   .format(target.name, workspace.path))
    
    484 484
     
    
    ... ... @@ -497,6 +497,10 @@ class Stream():
    497 497
                                   "fetch the latest version of the " +
    
    498 498
                                   "source.")
    
    499 499
     
    
    500
    +        if workspace:
    
    501
    +            workspaces.delete_workspace(target._get_full_name())
    
    502
    +            workspaces.save_config()
    
    503
    +            shutil.rmtree(directory)
    
    500 504
             try:
    
    501 505
                 os.makedirs(directory, exist_ok=True)
    
    502 506
             except OSError as e:
    

  • buildstream/element.py
    ... ... @@ -194,6 +194,9 @@ class Element(Plugin):
    194 194
     
    
    195 195
         def __init__(self, context, project, artifacts, meta, plugin_conf):
    
    196 196
     
    
    197
    +        self.__cache_key_dict = None            # Dict for cache key calculation
    
    198
    +        self.__cache_key = None                 # Our cached cache key
    
    199
    +
    
    197 200
             super().__init__(meta.name, context, project, meta.provenance, "element")
    
    198 201
     
    
    199 202
             self.__is_junction = meta.kind == "junction"
    
    ... ... @@ -212,8 +215,6 @@ class Element(Plugin):
    212 215
             self.__runtime_dependencies = []        # Direct runtime dependency Elements
    
    213 216
             self.__build_dependencies = []          # Direct build dependency Elements
    
    214 217
             self.__sources = []                     # List of Sources
    
    215
    -        self.__cache_key_dict = None            # Dict for cache key calculation
    
    216
    -        self.__cache_key = None                 # Our cached cache key
    
    217 218
             self.__weak_cache_key = None            # Our cached weak cache key
    
    218 219
             self.__strict_cache_key = None          # Our cached cache key for strict builds
    
    219 220
             self.__artifacts = artifacts            # Artifact cache
    

  • tests/frontend/workspace.py
    ... ... @@ -123,6 +123,58 @@ def test_open_force(cli, tmpdir, datafiles, kind):
    123 123
         result.assert_success()
    
    124 124
     
    
    125 125
     
    
    126
    +@pytest.mark.datafiles(DATA_DIR)
    
    127
    +@pytest.mark.parametrize("kind", repo_kinds)
    
    128
    +def test_open_force_open(cli, tmpdir, datafiles, kind):
    
    129
    +    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
    
    130
    +
    
    131
    +    # Assert the workspace dir exists
    
    132
    +    assert os.path.exists(workspace)
    
    133
    +
    
    134
    +    # Now open the workspace again with --force, this should happily succeed
    
    135
    +    result = cli.run(project=project, args=[
    
    136
    +        'workspace', 'open', '--force', element_name, workspace
    
    137
    +    ])
    
    138
    +    result.assert_success()
    
    139
    +
    
    140
    +
    
    141
    +@pytest.mark.datafiles(DATA_DIR)
    
    142
    +@pytest.mark.parametrize("kind", repo_kinds)
    
    143
    +def test_open_force_different_workspace(cli, tmpdir, datafiles, kind):
    
    144
    +    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False, "-alpha")
    
    145
    +
    
    146
    +    # Assert the workspace dir exists
    
    147
    +    assert os.path.exists(workspace)
    
    148
    +
    
    149
    +    hello_path = os.path.join(workspace, 'usr', 'bin', 'hello')
    
    150
    +    hello1_path = os.path.join(workspace, 'usr', 'bin', 'hello1')
    
    151
    +
    
    152
    +    tmpdir = os.path.join(str(tmpdir), "-beta")
    
    153
    +    shutil.move(hello_path, hello1_path)
    
    154
    +    element_name2, project2, workspace2 = open_workspace(cli, tmpdir, datafiles, kind, False, "-beta")
    
    155
    +
    
    156
    +    # Assert the workspace dir exists
    
    157
    +    assert os.path.exists(workspace2)
    
    158
    +
    
    159
    +    # Assert that workspace 1 contains the modified file
    
    160
    +    assert os.path.exists(hello1_path)
    
    161
    +
    
    162
    +    # Assert that workspace 2 contains the unmodified file
    
    163
    +    assert os.path.exists(os.path.join(workspace2, 'usr', 'bin', 'hello'))
    
    164
    +
    
    165
    +    # Now open the workspace again with --force, this should happily succeed
    
    166
    +    result = cli.run(project=project, args=[
    
    167
    +        'workspace', 'open', '--force', element_name2, workspace
    
    168
    +    ])
    
    169
    +
    
    170
    +    # Assert that the file in workspace 1 has been replaced
    
    171
    +    # With the file from workspace 2
    
    172
    +    assert os.path.exists(hello_path)
    
    173
    +    assert not os.path.exists(hello1_path)
    
    174
    +
    
    175
    +    result.assert_success()
    
    176
    +
    
    177
    +
    
    126 178
     @pytest.mark.datafiles(DATA_DIR)
    
    127 179
     @pytest.mark.parametrize("kind", repo_kinds)
    
    128 180
     def test_close(cli, tmpdir, datafiles, kind):
    



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