diff options
author | Jürg Billeter <j@bitron.ch> | 2018-09-24 16:02:38 +0000 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2018-09-24 16:02:38 +0000 |
commit | a76339deb7303901e8602635523b1776b4a1bb0c (patch) | |
tree | f5ea23d1c0b657cbb5ece3261bd68c7b4f9669f4 | |
parent | 1b2aed400e776eb2fdb0d601cc2c98899716a6ef (diff) | |
parent | 86ea1173a485024a3f241263814632a70c43b867 (diff) | |
download | buildstream-a76339deb7303901e8602635523b1776b4a1bb0c.tar.gz |
Merge branch 'juerg/rebuild' into 'master'
element.py: Fix cache check in non-strict mode
Closes #607
See merge request BuildStream/buildstream!822
-rw-r--r-- | buildstream/element.py | 2 | ||||
-rw-r--r-- | tests/frontend/project/elements/rebuild-target.bst | 4 | ||||
-rw-r--r-- | tests/frontend/rebuild.py | 36 |
3 files changed, 41 insertions, 1 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index 602bf01cc..f9e3c191b 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -2084,7 +2084,7 @@ class Element(Plugin): # # Raises an error if the artifact is not cached. # - def __assert_cached(self, keystrength=_KeyStrength.STRONG): + def __assert_cached(self, keystrength=None): assert self.__is_cached(keystrength=keystrength), "{}: Missing artifact {}".format( self, self._get_brief_display_key()) diff --git a/tests/frontend/project/elements/rebuild-target.bst b/tests/frontend/project/elements/rebuild-target.bst new file mode 100644 index 000000000..49a02c217 --- /dev/null +++ b/tests/frontend/project/elements/rebuild-target.bst @@ -0,0 +1,4 @@ +kind: compose + +build-depends: +- target.bst diff --git a/tests/frontend/rebuild.py b/tests/frontend/rebuild.py new file mode 100644 index 000000000..d93aac0dc --- /dev/null +++ b/tests/frontend/rebuild.py @@ -0,0 +1,36 @@ +import os +import pytest +from tests.testutils import cli + +# Project directory +DATA_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "project", +) + + +def strict_args(args, strict): + if strict != "strict": + return ['--no-strict'] + args + return args + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("strict", ["strict", "non-strict"]) +def test_rebuild(datafiles, cli, strict): + project = os.path.join(datafiles.dirname, datafiles.basename) + checkout = os.path.join(cli.directory, 'checkout') + + # First build intermediate target.bst + result = cli.run(project=project, args=strict_args(['build', 'target.bst'], strict)) + result.assert_success() + + # Modify base import + with open(os.path.join(project, 'files', 'dev-files', 'usr', 'include', 'new.h'), "w") as f: + f.write("#define NEW") + + # Rebuild base import and build top-level rebuild-target.bst + # In non-strict mode, this does not rebuild intermediate target.bst, + # which means that a weakly cached target.bst will be staged as dependency. + result = cli.run(project=project, args=strict_args(['build', 'rebuild-target.bst'], strict)) + result.assert_success() |