[Notes] [Git][BuildStream/buildstream][tpollard/workspacebuildtree] WIP: Opening a workspace with a cached build



Title: GitLab

Tom Pollard pushed to branch tpollard/workspacebuildtree at BuildStream / buildstream

Commits:

7 changed files:

Changes:

  • buildstream/_artifactcache/artifactcache.py
    ... ... @@ -603,6 +603,20 @@ class ArtifactCache():
    603 603
             raise ImplError("Cache '{kind}' does not implement calculate_cache_size()"
    
    604 604
                             .format(kind=type(self).__name__))
    
    605 605
     
    
    606
    +    # checkout_artifact_subdir()
    
    607
    +    #
    
    608
    +    # Checkout given artifact subdir into provided directory
    
    609
    +    #
    
    610
    +    # Args:
    
    611
    +    #     element (Element): The Element
    
    612
    +    #     key (str): The cache key to use
    
    613
    +    #     subdir (str): The subdir to checkout
    
    614
    +    #     tmpdir (str): The dir to place the buildtree content
    
    615
    +    #
    
    616
    +    def checkout_artifact_subdir(self, element, key, subdir, tmpdir):
    
    617
    +        raise ImplError("Cache '{kind}' does not implement checkout_artifact_subdir()"
    
    618
    +                        .format(kind=type(self).__name__))
    
    619
    +
    
    606 620
         ################################################
    
    607 621
         #               Local Private Methods          #
    
    608 622
         ################################################
    

  • buildstream/_artifactcache/cascache.py
    ... ... @@ -452,6 +452,13 @@ class CASCache(ArtifactCache):
    452 452
     
    
    453 453
             return pushed
    
    454 454
     
    
    455
    +    def checkout_artifact_subdir(self, element, key, subdir, tmpdir):
    
    456
    +        tree = self.resolve_ref(self.get_artifact_fullname(element, key))
    
    457
    +
    
    458
    +        # This assumes that the subdir digest is present in the element tree
    
    459
    +        subdirdigest = self._get_subdir(tree, subdir)
    
    460
    +        self._checkout(tmpdir, subdirdigest)
    
    461
    +
    
    455 462
         ################################################
    
    456 463
         #                API Private Methods           #
    
    457 464
         ################################################
    

  • buildstream/_context.py
    ... ... @@ -114,6 +114,9 @@ class Context():
    114 114
             # Whether or not to attempt to pull buildtrees globally
    
    115 115
             self.pullbuildtrees = False
    
    116 116
     
    
    117
    +        # Whether to not include artifact buildtrees in workspaces if available
    
    118
    +        self.workspacebuildtrees = True
    
    119
    +
    
    117 120
             # Private variables
    
    118 121
             self._cache_key = None
    
    119 122
             self._message_handler = None
    
    ... ... @@ -164,7 +167,7 @@ class Context():
    164 167
             _yaml.node_validate(defaults, [
    
    165 168
                 'sourcedir', 'builddir', 'artifactdir', 'logdir',
    
    166 169
                 'scheduler', 'artifacts', 'logging', 'projects',
    
    167
    -            'cache', 'pullbuildtrees'
    
    170
    +            'cache', 'pullbuildtrees', 'workspacebuildtrees'
    
    168 171
             ])
    
    169 172
     
    
    170 173
             for directory in ['sourcedir', 'builddir', 'artifactdir', 'logdir']:
    
    ... ... @@ -192,6 +195,9 @@ class Context():
    192 195
             # Load pull buildtrees configuration
    
    193 196
             self.pullbuildtrees = _yaml.node_get(defaults, bool, 'pullbuildtrees', default_value='False')
    
    194 197
     
    
    198
    +        # Load workspace buildtrees configuration
    
    199
    +        self.workspacebuildtrees = _yaml.node_get(defaults, bool, 'workspacebuildtrees', default_value='True')
    
    200
    +
    
    195 201
             # Load logging config
    
    196 202
             logging = _yaml.node_get(defaults, Mapping, 'logging')
    
    197 203
             _yaml.node_validate(logging, [
    

  • buildstream/_frontend/cli.py
    ... ... @@ -686,12 +686,16 @@ def workspace():
    686 686
                   help="Overwrite files existing in checkout directory")
    
    687 687
     @click.option('--track', 'track_', default=False, is_flag=True,
    
    688 688
                   help="Track and fetch new source references before checking out the workspace")
    
    689
    +@click.option('--no-cache', default=False, is_flag=True,
    
    690
    +              help="Do not checkout the cached buildtree")
    
    689 691
     @click.argument('element',
    
    690 692
                     type=click.Path(readable=False))
    
    691 693
     @click.argument('directory', type=click.Path(file_okay=False))
    
    692 694
     @click.pass_obj
    
    693
    -def workspace_open(app, no_checkout, force, track_, element, directory):
    
    694
    -    """Open a workspace for manual source modification"""
    
    695
    +def workspace_open(app, no_checkout, force, track_, no_cache, element, directory):
    
    696
    +    """Open a workspace for manual source modification, the elements buildtree
    
    697
    +    will be provided if available in the local artifact cache.
    
    698
    +    """
    
    695 699
     
    
    696 700
         if os.path.exists(directory):
    
    697 701
     
    
    ... ... @@ -703,11 +707,15 @@ def workspace_open(app, no_checkout, force, track_, element, directory):
    703 707
                 click.echo("Checkout directory is not empty: {}".format(directory), err=True)
    
    704 708
                 sys.exit(-1)
    
    705 709
     
    
    710
    +    if not no_cache:
    
    711
    +        click.echo("WARNING: Workspace will be opened without the cached buildtree if not cached locally")
    
    712
    +
    
    706 713
         with app.initialized():
    
    707 714
             app.stream.workspace_open(element, directory,
    
    708 715
                                       no_checkout=no_checkout,
    
    709 716
                                       track_first=track_,
    
    710
    -                                  force=force)
    
    717
    +                                  force=force,
    
    718
    +                                  no_cache=no_cache)
    
    711 719
     
    
    712 720
     
    
    713 721
     ##################################################################
    

  • buildstream/_stream.py
    ... ... @@ -456,11 +456,17 @@ class Stream():
    456 456
         #    no_checkout (bool): Whether to skip checking out the source
    
    457 457
         #    track_first (bool): Whether to track and fetch first
    
    458 458
         #    force (bool): Whether to ignore contents in an existing directory
    
    459
    +    #    no_cache (bool): Whether to not include the cached buildtree
    
    459 460
         #
    
    460 461
         def workspace_open(self, target, directory, *,
    
    461 462
                            no_checkout,
    
    462 463
                            track_first,
    
    463
    -                       force):
    
    464
    +                       force,
    
    465
    +                       no_cache):
    
    466
    +
    
    467
    +        # Override no_cache if the global user conf workspacebuildtrees is false
    
    468
    +        if not self._context.workspacebuildtrees:
    
    469
    +            no_cache = True
    
    464 470
     
    
    465 471
             if track_first:
    
    466 472
                 track_targets = (target,)
    
    ... ... @@ -473,7 +479,21 @@ class Stream():
    473 479
             target = elements[0]
    
    474 480
             directory = os.path.abspath(directory)
    
    475 481
     
    
    476
    -        if not list(target.sources()):
    
    482
    +        # Check if given target has a buildtree artifact cached locally
    
    483
    +        buildtree = None
    
    484
    +        if target._cached():
    
    485
    +            buildtree = self._artifacts.contains_subdir_artifact(target, target._get_cache_key(), 'buildtree')
    
    486
    +
    
    487
    +        # If we're running in the default state, make the user aware of buildtree usage
    
    488
    +        if not no_cache:
    
    489
    +            if buildtree:
    
    490
    +                self._message(MessageType.INFO, "{} buildtree artifact is available,"
    
    491
    +                              " workspace will be opened with it".format(target.name))
    
    492
    +            else:
    
    493
    +                self._message(MessageType.WARN, "{} buildtree artifact not available,"
    
    494
    +                              " workspace will be opened with source checkout".format(target.name))
    
    495
    +
    
    496
    +        if (not buildtree or no_cache) and not list(target.sources()):
    
    477 497
                 build_depends = [x.name for x in target.dependencies(Scope.BUILD, recurse=False)]
    
    478 498
                 if not build_depends:
    
    479 499
                     raise StreamError("The given element has no sources")
    
    ... ... @@ -492,18 +512,21 @@ class Stream():
    492 512
             # If we're going to checkout, we need at least a fetch,
    
    493 513
             # if we were asked to track first, we're going to fetch anyway.
    
    494 514
             #
    
    495
    -        if not no_checkout or track_first:
    
    496
    -            track_elements = []
    
    497
    -            if track_first:
    
    498
    -                track_elements = elements
    
    499
    -            self._fetch(elements, track_elements=track_elements)
    
    500
    -
    
    501
    -        if not no_checkout and target._get_consistency() != Consistency.CACHED:
    
    502
    -            raise StreamError("Could not stage uncached source. " +
    
    503
    -                              "Use `--track` to track and " +
    
    504
    -                              "fetch the latest version of the " +
    
    505
    -                              "source.")
    
    506
    -
    
    515
    +        if not buildtree or no_cache:
    
    516
    +            if not no_checkout or track_first:
    
    517
    +                track_elements = []
    
    518
    +                if track_first:
    
    519
    +                    track_elements = elements
    
    520
    +                self._fetch(elements, track_elements=track_elements)
    
    521
    +
    
    522
    +        if not buildtree or no_cache:
    
    523
    +            if not no_checkout and target._get_consistency() != Consistency.CACHED:
    
    524
    +                raise StreamError("Could not stage uncached source. " +
    
    525
    +                                  "Use `--track` to track and " +
    
    526
    +                                  "fetch the latest version of the " +
    
    527
    +                                  "source.")
    
    528
    +
    
    529
    +        # Presume workspace to be forced if previous StreamError not raised
    
    507 530
             if workspace:
    
    508 531
                 workspaces.delete_workspace(target._get_full_name())
    
    509 532
                 workspaces.save_config()
    
    ... ... @@ -515,9 +538,13 @@ class Stream():
    515 538
     
    
    516 539
             workspaces.create_workspace(target._get_full_name(), directory)
    
    517 540
     
    
    518
    -        if not no_checkout:
    
    541
    +        if (not buildtree or no_cache) and not no_checkout:
    
    519 542
                 with target.timed_activity("Staging sources to {}".format(directory)):
    
    520 543
                     target._open_workspace()
    
    544
    +        # Handle opening workspace with buildtree instead of source staging
    
    545
    +        elif buildtree and not no_cache:
    
    546
    +            with target.timed_activity("Staging buildtree to {}".format(directory)):
    
    547
    +                target._open_workspace(buildtree=buildtree)
    
    521 548
     
    
    522 549
             workspaces.save_config()
    
    523 550
             self._message(MessageType.INFO, "Saved workspace configuration")
    

  • buildstream/element.py
    ... ... @@ -1911,7 +1911,10 @@ class Element(Plugin):
    1911 1911
         # This requires that a workspace already be created in
    
    1912 1912
         # the workspaces metadata first.
    
    1913 1913
         #
    
    1914
    -    def _open_workspace(self):
    
    1914
    +    # Args:
    
    1915
    +    #    buildtree (bool): Whether to open workspace with artifact buildtree
    
    1916
    +    #
    
    1917
    +    def _open_workspace(self, buildtree=None):
    
    1915 1918
             context = self._get_context()
    
    1916 1919
             workspace = self._get_workspace()
    
    1917 1920
             assert workspace is not None
    
    ... ... @@ -1924,11 +1927,15 @@ class Element(Plugin):
    1924 1927
             # files in the target directory actually works without any
    
    1925 1928
             # additional support from Source implementations.
    
    1926 1929
             #
    
    1930
    +
    
    1927 1931
             os.makedirs(context.builddir, exist_ok=True)
    
    1928 1932
             with utils._tempdir(dir=context.builddir, prefix='workspace-{}'
    
    1929 1933
                                 .format(self.normal_name)) as temp:
    
    1930
    -            for source in self.sources():
    
    1931
    -                source._init_workspace(temp)
    
    1934
    +            if not buildtree:
    
    1935
    +                for source in self.sources():
    
    1936
    +                    source._init_workspace(temp)
    
    1937
    +            else:
    
    1938
    +                self.__artifacts.checkout_artifact_subdir(self, self._get_cache_key(), 'buildtree', temp)
    
    1932 1939
     
    
    1933 1940
                 # Now hardlink the files into the workspace target.
    
    1934 1941
                 utils.link_files(temp, workspace.get_absolute_path())
    

  • tests/frontend/workspace.py
    ... ... @@ -44,7 +44,7 @@ DATA_DIR = os.path.join(
    44 44
     
    
    45 45
     
    
    46 46
     def open_workspace(cli, tmpdir, datafiles, kind, track, suffix='', workspace_dir=None,
    
    47
    -                   project_path=None, element_attrs=None):
    
    47
    +                   project_path=None, element_attrs=None, no_cache=False):
    
    48 48
         if not workspace_dir:
    
    49 49
             workspace_dir = os.path.join(str(tmpdir), 'workspace{}'.format(suffix))
    
    50 50
         if not project_path:
    
    ... ... @@ -88,6 +88,8 @@ def open_workspace(cli, tmpdir, datafiles, kind, track, suffix='', workspace_dir
    88 88
         args = ['workspace', 'open']
    
    89 89
         if track:
    
    90 90
             args.append('--track')
    
    91
    +    if no_cache:
    
    92
    +        args.append('--no-cache')
    
    91 93
         args.extend([element_name, workspace_dir])
    
    92 94
         result = cli.run(project=project_path, args=args)
    
    93 95
     
    
    ... ... @@ -101,7 +103,7 @@ def open_workspace(cli, tmpdir, datafiles, kind, track, suffix='', workspace_dir
    101 103
         filename = os.path.join(workspace_dir, 'usr', 'bin', 'hello')
    
    102 104
         assert os.path.exists(filename)
    
    103 105
     
    
    104
    -    return (element_name, project_path, workspace_dir)
    
    106
    +    return (element_name, project_path, workspace_dir, result)
    
    105 107
     
    
    106 108
     
    
    107 109
     @pytest.mark.datafiles(DATA_DIR)
    
    ... ... @@ -112,7 +114,7 @@ def test_open(cli, tmpdir, datafiles, kind):
    112 114
     
    
    113 115
     @pytest.mark.datafiles(DATA_DIR)
    
    114 116
     def test_open_bzr_customize(cli, tmpdir, datafiles):
    
    115
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "bzr", False)
    
    117
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, "bzr", False)
    
    116 118
     
    
    117 119
         # Check that the .bzr dir exists
    
    118 120
         bzrdir = os.path.join(workspace, ".bzr")
    
    ... ... @@ -137,7 +139,7 @@ def test_open_track(cli, tmpdir, datafiles, kind):
    137 139
     @pytest.mark.datafiles(DATA_DIR)
    
    138 140
     @pytest.mark.parametrize("kind", repo_kinds)
    
    139 141
     def test_open_force(cli, tmpdir, datafiles, kind):
    
    140
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
    
    142
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, kind, False)
    
    141 143
     
    
    142 144
         # Close the workspace
    
    143 145
         result = cli.run(project=project, args=[
    
    ... ... @@ -158,7 +160,7 @@ def test_open_force(cli, tmpdir, datafiles, kind):
    158 160
     @pytest.mark.datafiles(DATA_DIR)
    
    159 161
     @pytest.mark.parametrize("kind", repo_kinds)
    
    160 162
     def test_open_force_open(cli, tmpdir, datafiles, kind):
    
    161
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
    
    163
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, kind, False)
    
    162 164
     
    
    163 165
         # Assert the workspace dir exists
    
    164 166
         assert os.path.exists(workspace)
    
    ... ... @@ -173,7 +175,7 @@ def test_open_force_open(cli, tmpdir, datafiles, kind):
    173 175
     @pytest.mark.datafiles(DATA_DIR)
    
    174 176
     @pytest.mark.parametrize("kind", repo_kinds)
    
    175 177
     def test_open_force_different_workspace(cli, tmpdir, datafiles, kind):
    
    176
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False, "-alpha")
    
    178
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, kind, False, "-alpha")
    
    177 179
     
    
    178 180
         # Assert the workspace dir exists
    
    179 181
         assert os.path.exists(workspace)
    
    ... ... @@ -183,7 +185,7 @@ def test_open_force_different_workspace(cli, tmpdir, datafiles, kind):
    183 185
     
    
    184 186
         tmpdir = os.path.join(str(tmpdir), "-beta")
    
    185 187
         shutil.move(hello_path, hello1_path)
    
    186
    -    element_name2, project2, workspace2 = open_workspace(cli, tmpdir, datafiles, kind, False, "-beta")
    
    188
    +    element_name2, project2, workspace2, _ = open_workspace(cli, tmpdir, datafiles, kind, False, "-beta")
    
    187 189
     
    
    188 190
         # Assert the workspace dir exists
    
    189 191
         assert os.path.exists(workspace2)
    
    ... ... @@ -210,7 +212,7 @@ def test_open_force_different_workspace(cli, tmpdir, datafiles, kind):
    210 212
     @pytest.mark.datafiles(DATA_DIR)
    
    211 213
     @pytest.mark.parametrize("kind", repo_kinds)
    
    212 214
     def test_close(cli, tmpdir, datafiles, kind):
    
    213
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
    
    215
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, kind, False)
    
    214 216
     
    
    215 217
         # Close the workspace
    
    216 218
         result = cli.run(project=project, args=[
    
    ... ... @@ -226,7 +228,7 @@ def test_close(cli, tmpdir, datafiles, kind):
    226 228
     def test_close_external_after_move_project(cli, tmpdir, datafiles):
    
    227 229
         workspace_dir = os.path.join(str(tmpdir), "workspace")
    
    228 230
         project_path = os.path.join(str(tmpdir), 'initial_project')
    
    229
    -    element_name, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', False, "", workspace_dir, project_path)
    
    231
    +    element_name, _, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', False, "", workspace_dir, project_path)
    
    230 232
         assert os.path.exists(workspace_dir)
    
    231 233
         moved_dir = os.path.join(str(tmpdir), 'external_project')
    
    232 234
         shutil.move(project_path, moved_dir)
    
    ... ... @@ -246,8 +248,8 @@ def test_close_external_after_move_project(cli, tmpdir, datafiles):
    246 248
     def test_close_internal_after_move_project(cli, tmpdir, datafiles):
    
    247 249
         initial_dir = os.path.join(str(tmpdir), 'initial_project')
    
    248 250
         initial_workspace = os.path.join(initial_dir, 'workspace')
    
    249
    -    element_name, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', False,
    
    250
    -                                        workspace_dir=initial_workspace, project_path=initial_dir)
    
    251
    +    element_name, _, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', False,
    
    252
    +                                           workspace_dir=initial_workspace, project_path=initial_dir)
    
    251 253
         moved_dir = os.path.join(str(tmpdir), 'internal_project')
    
    252 254
         shutil.move(initial_dir, moved_dir)
    
    253 255
         assert os.path.exists(moved_dir)
    
    ... ... @@ -265,7 +267,7 @@ def test_close_internal_after_move_project(cli, tmpdir, datafiles):
    265 267
     
    
    266 268
     @pytest.mark.datafiles(DATA_DIR)
    
    267 269
     def test_close_removed(cli, tmpdir, datafiles):
    
    268
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False)
    
    270
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, 'git', False)
    
    269 271
     
    
    270 272
         # Remove it first, closing the workspace should work
    
    271 273
         shutil.rmtree(workspace)
    
    ... ... @@ -282,7 +284,7 @@ def test_close_removed(cli, tmpdir, datafiles):
    282 284
     
    
    283 285
     @pytest.mark.datafiles(DATA_DIR)
    
    284 286
     def test_close_nonexistant_element(cli, tmpdir, datafiles):
    
    285
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False)
    
    287
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, 'git', False)
    
    286 288
         element_path = os.path.join(datafiles.dirname, datafiles.basename, 'elements', element_name)
    
    287 289
     
    
    288 290
         # First brutally remove the element.bst file, ensuring that
    
    ... ... @@ -304,9 +306,9 @@ def test_close_nonexistant_element(cli, tmpdir, datafiles):
    304 306
     def test_close_multiple(cli, tmpdir, datafiles):
    
    305 307
         tmpdir_alpha = os.path.join(str(tmpdir), 'alpha')
    
    306 308
         tmpdir_beta = os.path.join(str(tmpdir), 'beta')
    
    307
    -    alpha, project, workspace_alpha = open_workspace(
    
    309
    +    alpha, project, workspace_alpha, _ = open_workspace(
    
    308 310
             cli, tmpdir_alpha, datafiles, 'git', False, suffix='-alpha')
    
    309
    -    beta, project, workspace_beta = open_workspace(
    
    311
    +    beta, project, workspace_beta, _ = open_workspace(
    
    310 312
             cli, tmpdir_beta, datafiles, 'git', False, suffix='-beta')
    
    311 313
     
    
    312 314
         # Close the workspaces
    
    ... ... @@ -324,9 +326,9 @@ def test_close_multiple(cli, tmpdir, datafiles):
    324 326
     def test_close_all(cli, tmpdir, datafiles):
    
    325 327
         tmpdir_alpha = os.path.join(str(tmpdir), 'alpha')
    
    326 328
         tmpdir_beta = os.path.join(str(tmpdir), 'beta')
    
    327
    -    alpha, project, workspace_alpha = open_workspace(
    
    329
    +    alpha, project, workspace_alpha, _ = open_workspace(
    
    328 330
             cli, tmpdir_alpha, datafiles, 'git', False, suffix='-alpha')
    
    329
    -    beta, project, workspace_beta = open_workspace(
    
    331
    +    beta, project, workspace_beta, _ = open_workspace(
    
    330 332
             cli, tmpdir_beta, datafiles, 'git', False, suffix='-beta')
    
    331 333
     
    
    332 334
         # Close the workspaces
    
    ... ... @@ -343,7 +345,7 @@ def test_close_all(cli, tmpdir, datafiles):
    343 345
     @pytest.mark.datafiles(DATA_DIR)
    
    344 346
     def test_reset(cli, tmpdir, datafiles):
    
    345 347
         # Open the workspace
    
    346
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False)
    
    348
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, 'git', False)
    
    347 349
     
    
    348 350
         # Modify workspace
    
    349 351
         shutil.rmtree(os.path.join(workspace, 'usr', 'bin'))
    
    ... ... @@ -366,9 +368,9 @@ def test_reset_multiple(cli, tmpdir, datafiles):
    366 368
         # Open the workspaces
    
    367 369
         tmpdir_alpha = os.path.join(str(tmpdir), 'alpha')
    
    368 370
         tmpdir_beta = os.path.join(str(tmpdir), 'beta')
    
    369
    -    alpha, project, workspace_alpha = open_workspace(
    
    371
    +    alpha, project, workspace_alpha, _ = open_workspace(
    
    370 372
             cli, tmpdir_alpha, datafiles, 'git', False, suffix='-alpha')
    
    371
    -    beta, project, workspace_beta = open_workspace(
    
    373
    +    beta, project, workspace_beta, _ = open_workspace(
    
    372 374
             cli, tmpdir_beta, datafiles, 'git', False, suffix='-beta')
    
    373 375
     
    
    374 376
         # Modify workspaces
    
    ... ... @@ -392,9 +394,9 @@ def test_reset_all(cli, tmpdir, datafiles):
    392 394
         # Open the workspaces
    
    393 395
         tmpdir_alpha = os.path.join(str(tmpdir), 'alpha')
    
    394 396
         tmpdir_beta = os.path.join(str(tmpdir), 'beta')
    
    395
    -    alpha, project, workspace_alpha = open_workspace(
    
    397
    +    alpha, project, workspace_alpha, _ = open_workspace(
    
    396 398
             cli, tmpdir_alpha, datafiles, 'git', False, suffix='-alpha')
    
    397
    -    beta, project, workspace_beta = open_workspace(
    
    399
    +    beta, project, workspace_beta, _ = open_workspace(
    
    398 400
             cli, tmpdir_beta, datafiles, 'git', False, suffix='-beta')
    
    399 401
     
    
    400 402
         # Modify workspaces
    
    ... ... @@ -415,7 +417,7 @@ def test_reset_all(cli, tmpdir, datafiles):
    415 417
     
    
    416 418
     @pytest.mark.datafiles(DATA_DIR)
    
    417 419
     def test_list(cli, tmpdir, datafiles):
    
    418
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False)
    
    420
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, 'git', False)
    
    419 421
     
    
    420 422
         # Now list the workspaces
    
    421 423
         result = cli.run(project=project, args=[
    
    ... ... @@ -437,7 +439,7 @@ def test_list(cli, tmpdir, datafiles):
    437 439
     @pytest.mark.parametrize("kind", repo_kinds)
    
    438 440
     @pytest.mark.parametrize("strict", [("strict"), ("non-strict")])
    
    439 441
     def test_build(cli, tmpdir, datafiles, kind, strict):
    
    440
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
    
    442
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, kind, False)
    
    441 443
         checkout = os.path.join(str(tmpdir), 'checkout')
    
    442 444
     
    
    443 445
         # Modify workspace
    
    ... ... @@ -516,7 +518,7 @@ def test_buildable_no_ref(cli, tmpdir, datafiles):
    516 518
     @pytest.mark.parametrize("modification", [("addfile"), ("removefile"), ("modifyfile")])
    
    517 519
     @pytest.mark.parametrize("strict", [("strict"), ("non-strict")])
    
    518 520
     def test_detect_modifications(cli, tmpdir, datafiles, modification, strict):
    
    519
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False)
    
    521
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, 'git', False)
    
    520 522
         checkout = os.path.join(str(tmpdir), 'checkout')
    
    521 523
     
    
    522 524
         # Configure strict mode
    
    ... ... @@ -779,7 +781,7 @@ def test_list_supported_workspace(cli, tmpdir, datafiles, workspace_cfg, expecte
    779 781
     @pytest.mark.datafiles(DATA_DIR)
    
    780 782
     @pytest.mark.parametrize("kind", repo_kinds)
    
    781 783
     def test_inconsitent_pipeline_message(cli, tmpdir, datafiles, kind):
    
    782
    -    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
    
    784
    +    element_name, project, workspace, _ = open_workspace(cli, tmpdir, datafiles, kind, False)
    
    783 785
     
    
    784 786
         shutil.rmtree(workspace)
    
    785 787
     
    
    ... ... @@ -793,8 +795,8 @@ def test_inconsitent_pipeline_message(cli, tmpdir, datafiles, kind):
    793 795
     @pytest.mark.parametrize("strict", [("strict"), ("non-strict")])
    
    794 796
     def test_cache_key_workspace_in_dependencies(cli, tmpdir, datafiles, strict):
    
    795 797
         checkout = os.path.join(str(tmpdir), 'checkout')
    
    796
    -    element_name, project, workspace = open_workspace(cli, os.path.join(str(tmpdir), 'repo-a'),
    
    797
    -                                                      datafiles, 'git', False)
    
    798
    +    element_name, project, workspace, _ = open_workspace(cli, os.path.join(str(tmpdir), 'repo-a'),
    
    799
    +                                                         datafiles, 'git', False)
    
    798 800
     
    
    799 801
         element_path = os.path.join(project, 'elements')
    
    800 802
         back_dep_element_name = 'workspace-test-back-dep.bst'
    
    ... ... @@ -869,10 +871,26 @@ def test_multiple_failed_builds(cli, tmpdir, datafiles):
    869 871
                 ]
    
    870 872
             }
    
    871 873
         }
    
    872
    -    element_name, project, _ = open_workspace(cli, tmpdir, datafiles,
    
    873
    -                                              "git", False, element_attrs=element_config)
    
    874
    +    element_name, project, _, _ = open_workspace(cli, tmpdir, datafiles,
    
    875
    +                                                 "git", False, element_attrs=element_config)
    
    874 876
     
    
    875 877
         for _ in range(2):
    
    876 878
             result = cli.run(project=project, args=["build", element_name])
    
    877 879
             assert "BUG" not in result.stderr
    
    878 880
             assert cli.get_element_state(project, element_name) != "cached"
    
    881
    +
    
    882
    +
    
    883
    +@pytest.mark.datafiles(DATA_DIR)
    
    884
    +def test_nocache_messages(cli, tmpdir, datafiles):
    
    885
    +    # cli default WARN for source dropback possibility when no-cache flag is not passed
    
    886
    +    element_name, project, workspace, result = open_workspace(cli, tmpdir, datafiles, 'git', False, suffix='1')
    
    887
    +    assert "WARNING: Workspace will be opened without the cached buildtree if not cached locally" in result.output
    
    888
    +
    
    889
    +    # cli WARN for source dropback happening when no-cache flag not given, but buildtree not available
    
    890
    +    assert "workspace will be opened with source checkout" in result.stderr
    
    891
    +
    
    892
    +    # cli default WARN for source dropback possibilty not given when no-cache flag is passed
    
    893
    +    tmpdir = os.path.join(str(tmpdir), "2")
    
    894
    +    element_name, project, workspace, result = open_workspace(cli, tmpdir, datafiles, 'git', False, suffix='2',
    
    895
    +                                                              no_cache=True)
    
    896
    +    assert "WARNING: Workspace will be opened without the cached buildtree if not cached locally" not in result.output



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