[Notes] [Git][BuildStream/buildstream][doraskayo/filter-indirect-deps-fix-1.2] filter.py: don't recurse when staging dependencies



Title: GitLab

Dor Askayo pushed to branch doraskayo/filter-indirect-deps-fix-1.2 at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • buildstream/plugins/elements/filter.py
    ... ... @@ -47,7 +47,9 @@ from buildstream import Element, ElementError, Scope
    47 47
     class FilterElement(Element):
    
    48 48
         # pylint: disable=attribute-defined-outside-init
    
    49 49
     
    
    50
    -    # The filter element's output is it's dependencies, so
    
    50
    +    BST_ARTIFACT_VERSION = 1
    
    51
    +
    
    52
    +    # The filter element's output is its dependencies, so
    
    51 53
         # we must rebuild if the dependencies change even when
    
    52 54
         # not in strict build plans.
    
    53 55
         BST_STRICT_REBUILD = True
    
    ... ... @@ -102,7 +104,7 @@ class FilterElement(Element):
    102 104
     
    
    103 105
         def assemble(self, sandbox):
    
    104 106
             with self.timed_activity("Staging artifact", silent_nested=True):
    
    105
    -            for dep in self.dependencies(Scope.BUILD):
    
    107
    +            for dep in self.dependencies(Scope.BUILD, recurse=False):
    
    106 108
                     dep.stage_artifact(sandbox, include=self.include,
    
    107 109
                                        exclude=self.exclude, orphans=self.include_orphans)
    
    108 110
             return ""
    

  • tests/plugins/filter.py
    ... ... @@ -452,3 +452,23 @@ def test_filter_track_multi_exclude(datafiles, cli, tmpdir):
    452 452
         assert "ref" not in new_input["sources"][0]
    
    453 453
         new_input2 = _yaml.load(input2_file)
    
    454 454
         assert new_input2["sources"][0]["ref"] == ref
    
    455
    +
    
    456
    +
    
    457
    +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
    
    458
    +def test_filter_include_with_indirect_deps(datafiles, cli, tmpdir):
    
    459
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    460
    +    result = cli.run(project=project, args=[
    
    461
    +        'build', 'output-include-with-indirect-deps.bst'])
    
    462
    +    result.assert_success()
    
    463
    +
    
    464
    +    checkout = os.path.join(tmpdir.dirname, tmpdir.basename, 'checkout')
    
    465
    +    result = cli.run(project=project, args=[
    
    466
    +        'checkout', 'output-include-with-indirect-deps.bst', checkout])
    
    467
    +    result.assert_success()
    
    468
    +
    
    469
    +    # direct dependencies should be staged and filtered
    
    470
    +    assert os.path.exists(os.path.join(checkout, "baz"))
    
    471
    +
    
    472
    +    # indirect dependencies shouldn't be staged and filtered
    
    473
    +    assert not os.path.exists(os.path.join(checkout, "foo"))
    
    474
    +    assert not os.path.exists(os.path.join(checkout, "bar"))

  • tests/plugins/filter/basic/elements/input-with-deps.bst
    1
    +kind: import
    
    2
    +
    
    3
    +depends:
    
    4
    +- filename: input.bst
    
    5
    +
    
    6
    +sources:
    
    7
    +- kind: local
    
    8
    +  path: files
    
    9
    +
    
    10
    +public:
    
    11
    +  bst:
    
    12
    +    split-rules:
    
    13
    +      baz:
    
    14
    +      - /baz

  • tests/plugins/filter/basic/elements/output-include-with-indirect-deps.bst
    1
    +kind: filter
    
    2
    +
    
    3
    +depends:
    
    4
    +- filename: input-with-deps.bst
    
    5
    +  type: build



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