Skip to content
Snippets Groups Projects
Commit 5044fd25 authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

tests/frontend/show.py: Test that strict dependencies behave as expected

This tests that the target which depends on a common dependency
strictly in non strict mode needs to be rebuilt after this common
dependency changes, while it is not the case when depending on the
same common target non strictly.

This is a regression test for #254
parent b082f9aa
No related branches found
No related tags found
Loading
...@@ -11,10 +11,8 @@ from buildstream._exceptions import ErrorDomain, LoadErrorReason ...@@ -11,10 +11,8 @@ from buildstream._exceptions import ErrorDomain, LoadErrorReason
from . import configure_project from . import configure_project
# Project directory # Project directory
DATA_DIR = os.path.join( TOP_DIR = os.path.dirname(os.path.realpath(__file__))
os.path.dirname(os.path.realpath(__file__)), DATA_DIR = os.path.join(TOP_DIR, "project")
"project",
)
@pytest.mark.datafiles(DATA_DIR) @pytest.mark.datafiles(DATA_DIR)
...@@ -371,3 +369,57 @@ def test_max_jobs(cli, datafiles, cli_value, config_value): ...@@ -371,3 +369,57 @@ def test_max_jobs(cli, datafiles, cli_value, config_value):
else: else:
# Check that we got the explicitly set value # Check that we got the explicitly set value
assert loaded_value == int(expected_value) assert loaded_value == int(expected_value)
# This tests that cache keys behave as expected when
# dependencies have been specified as `strict` and
# when building in strict mode.
#
# This test will:
#
# * Build the target once (and assert that it is cached)
# * Modify some local files which are imported
# by an import element which the target depends on
# * Assert that the cached state of the target element
# is as expected
#
# We run the test twice, once with an element which strict
# depends on the changing import element, and one which
# depends on it regularly.
#
@pytest.mark.datafiles(os.path.join(TOP_DIR, 'strict-depends'))
@pytest.mark.parametrize("target, expected_state", [
("non-strict-depends.bst", "cached"),
("strict-depends.bst", "waiting"),
])
def test_strict_dependencies(cli, datafiles, target, expected_state):
project = str(datafiles)
# Configure non strict mode, this will have
# an effect on the build and the `bst show`
# commands run via cli.get_element_states()
cli.configure({
'projects': {
'test': {
'strict': False
}
}
})
result = cli.run(project=project, silent=True, args=['build', target])
result.assert_success()
states = cli.get_element_states(project, target)
assert states['base.bst'] == 'cached'
assert states[target] == 'cached'
# Now modify the file, effectively causing the common base.bst
# dependency to change it's cache key
hello_path = os.path.join(project, 'files', 'hello.txt')
with open(hello_path, 'w') as f:
f.write("Goodbye")
# Now assert that we have the states we expect as a result
states = cli.get_element_states(project, target)
assert states['base.bst'] == 'buildable'
assert states[target] == expected_state
kind: import
sources:
- kind: local
path: files
kind: stack
build-depends:
- base.bst
kind: stack
build-depends:
- filename: base.bst
strict: true
pony
name: test
element-path: elements
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment