Commit df17f602 authored by Jürg Billeter's avatar Jürg Billeter

tests: Do not rely on 'downloadable' status

This is in preparation for moving away from summary files.
parent 37e5362e
...@@ -79,12 +79,11 @@ def test_push_pull(cli, tmpdir, datafiles): ...@@ -79,12 +79,11 @@ def test_push_pull(cli, tmpdir, datafiles):
artifacts = os.path.join(cli.directory, 'artifacts') artifacts = os.path.join(cli.directory, 'artifacts')
shutil.rmtree(artifacts) shutil.rmtree(artifacts)
# Assert that we are now in a downloadable state, nothing # Assert that nothing is cached locally anymore
# is cached locally anymore
state = cli.get_element_state(project, 'target.bst') state = cli.get_element_state(project, 'target.bst')
assert state == 'downloadable' assert state != 'cached'
state = cli.get_element_state(base_project, 'target.bst') state = cli.get_element_state(base_project, 'target.bst')
assert state == 'downloadable' assert state != 'cached'
# Now try bst pull # Now try bst pull
result = cli.run(project=project, args=['pull', '--deps', 'all', 'target.bst']) result = cli.run(project=project, args=['pull', '--deps', 'all', 'target.bst'])
......
...@@ -66,10 +66,9 @@ def test_push_pull_all(cli, tmpdir, datafiles): ...@@ -66,10 +66,9 @@ def test_push_pull_all(cli, tmpdir, datafiles):
artifacts = os.path.join(cli.directory, 'artifacts') artifacts = os.path.join(cli.directory, 'artifacts')
shutil.rmtree(artifacts) shutil.rmtree(artifacts)
# Assert that we are now in a downloadable state, nothing # Assert that nothing is cached locally anymore
# is cached locally anymore
for element_name in all_elements: for element_name in all_elements:
assert cli.get_element_state(project, element_name) == 'downloadable' assert cli.get_element_state(project, element_name) != 'cached'
# Now try bst pull # Now try bst pull
result = cli.run(project=project, args=['pull', '--deps', 'all', 'target.bst']) result = cli.run(project=project, args=['pull', '--deps', 'all', 'target.bst'])
...@@ -83,7 +82,7 @@ def test_push_pull_all(cli, tmpdir, datafiles): ...@@ -83,7 +82,7 @@ def test_push_pull_all(cli, tmpdir, datafiles):
# Tests that: # Tests that:
# #
# * `bst build` pushes all build elements ONLY to configured 'push' cache # * `bst build` pushes all build elements ONLY to configured 'push' cache
# * `bst show` finds artifacts that are available only in the secondary cache # * `bst pull` finds artifacts that are available only in the secondary cache
# #
@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux') @pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
@pytest.mark.datafiles(DATA_DIR) @pytest.mark.datafiles(DATA_DIR)
...@@ -113,8 +112,16 @@ def test_pull_secondary_cache(cli, tmpdir, datafiles): ...@@ -113,8 +112,16 @@ def test_pull_secondary_cache(cli, tmpdir, datafiles):
artifacts = os.path.join(cli.directory, 'artifacts') artifacts = os.path.join(cli.directory, 'artifacts')
shutil.rmtree(artifacts) shutil.rmtree(artifacts)
# Assert that the element is 'downloadable', i.e. we found it in share2. # Assert that the element is not cached anymore.
assert cli.get_element_state(project, 'target.bst') == 'downloadable' assert cli.get_element_state(project, 'target.bst') != 'cached'
# Now try bst pull
result = cli.run(project=project, args=['pull', 'target.bst'])
result.assert_success()
# And assert that it's again in the local cache, without having built,
# i.e. we found it in share2.
assert cli.get_element_state(project, 'target.bst') == 'cached'
# Tests that: # Tests that:
...@@ -205,10 +212,9 @@ def test_push_pull_non_strict(cli, tmpdir, datafiles): ...@@ -205,10 +212,9 @@ def test_push_pull_non_strict(cli, tmpdir, datafiles):
artifacts = os.path.join(cli.directory, 'artifacts') artifacts = os.path.join(cli.directory, 'artifacts')
shutil.rmtree(artifacts) shutil.rmtree(artifacts)
# Assert that we are now in a downloadable state, nothing # Assert that nothing is cached locally anymore
# is cached locally anymore
for element_name in all_elements: for element_name in all_elements:
assert cli.get_element_state(project, element_name) == 'downloadable' assert cli.get_element_state(project, element_name) != 'cached'
# Add a file to force change in strict cache key of import-bin.bst # Add a file to force change in strict cache key of import-bin.bst
with open(os.path.join(str(project), 'files', 'bin-files', 'usr', 'bin', 'world'), 'w') as f: with open(os.path.join(str(project), 'files', 'bin-files', 'usr', 'bin', 'world'), 'w') as f:
...@@ -216,8 +222,8 @@ def test_push_pull_non_strict(cli, tmpdir, datafiles): ...@@ -216,8 +222,8 @@ def test_push_pull_non_strict(cli, tmpdir, datafiles):
# Assert that the workspaced element requires a rebuild # Assert that the workspaced element requires a rebuild
assert cli.get_element_state(project, 'import-bin.bst') == 'buildable' assert cli.get_element_state(project, 'import-bin.bst') == 'buildable'
# Assert that the target is still downloadable due to --no-strict # Assert that the target is still waiting due to --no-strict
assert cli.get_element_state(project, 'target.bst') == 'downloadable' assert cli.get_element_state(project, 'target.bst') == 'waiting'
# Now try bst pull # Now try bst pull
result = cli.run(project=project, args=['pull', '--deps', 'all', 'target.bst']) result = cli.run(project=project, args=['pull', '--deps', 'all', 'target.bst'])
...@@ -247,7 +253,7 @@ def test_push_pull_track_non_strict(cli, tmpdir, datafiles): ...@@ -247,7 +253,7 @@ def test_push_pull_track_non_strict(cli, tmpdir, datafiles):
# Assert that everything is now cached in the remote. # Assert that everything is now cached in the remote.
share.update_summary() share.update_summary()
all_elements = ['target.bst', 'import-bin.bst', 'import-dev.bst', 'compose-all.bst'] all_elements = {'target.bst', 'import-bin.bst', 'import-dev.bst', 'compose-all.bst'}
for element_name in all_elements: for element_name in all_elements:
assert_shared(cli, share, project, element_name) assert_shared(cli, share, project, element_name)
...@@ -257,10 +263,9 @@ def test_push_pull_track_non_strict(cli, tmpdir, datafiles): ...@@ -257,10 +263,9 @@ def test_push_pull_track_non_strict(cli, tmpdir, datafiles):
artifacts = os.path.join(cli.directory, 'artifacts') artifacts = os.path.join(cli.directory, 'artifacts')
shutil.rmtree(artifacts) shutil.rmtree(artifacts)
# Assert that we are now in a downloadable state, nothing # Assert that nothing is cached locally anymore
# is cached locally anymore
for element_name in all_elements: for element_name in all_elements:
assert cli.get_element_state(project, element_name) == 'downloadable' assert cli.get_element_state(project, element_name) != 'cached'
# Now try bst build with tracking and pulling. # Now try bst build with tracking and pulling.
# Tracking will be skipped for target.bst as it doesn't have any sources. # Tracking will be skipped for target.bst as it doesn't have any sources.
...@@ -270,3 +275,4 @@ def test_push_pull_track_non_strict(cli, tmpdir, datafiles): ...@@ -270,3 +275,4 @@ def test_push_pull_track_non_strict(cli, tmpdir, datafiles):
# the caches. # the caches.
result = cli.run(project=project, args=['build', '--track-all', 'target.bst']) result = cli.run(project=project, args=['build', '--track-all', 'target.bst'])
result.assert_success() result.assert_success()
assert set(result.get_pulled_elements()) == all_elements
...@@ -170,7 +170,7 @@ def test_push_after_pull(cli, tmpdir, datafiles): ...@@ -170,7 +170,7 @@ def test_push_after_pull(cli, tmpdir, datafiles):
assert_shared(cli, share1, project, 'target.bst') assert_shared(cli, share1, project, 'target.bst')
assert_not_shared(cli, share2, project, 'target.bst') assert_not_shared(cli, share2, project, 'target.bst')
assert cli.get_element_state(project, 'target.bst') == 'downloadable' assert cli.get_element_state(project, 'target.bst') != 'cached'
# Now run the build again. Correct `bst build` behaviour is to download the # Now run the build again. Correct `bst build` behaviour is to download the
# artifact from share1 but not push it back again. # artifact from share1 but not push it back again.
......
...@@ -337,7 +337,6 @@ class Cli(): ...@@ -337,7 +337,6 @@ class Cli():
'show', 'show',
'--deps', 'none', '--deps', 'none',
'--format', '%{state}', '--format', '%{state}',
'--downloadable',
element_name element_name
]) ])
result.assert_success() result.assert_success()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment