Valentin David pushed to branch valentindavid/cli_integration_source_determinism at BuildStream / buildstream
Commits:
-
2f58ac27
by Valentin David at 2018-08-23T17:09:43Z
3 changed files:
Changes:
... | ... | @@ -2,7 +2,8 @@ import os |
2 | 2 |
import pytest
|
3 | 3 |
|
4 | 4 |
from buildstream import _yaml, utils
|
5 |
-from tests.testutils import cli, create_repo, ALL_REPO_KINDS
|
|
5 |
+from tests.testutils import create_repo, ALL_REPO_KINDS, remove_artifact_from_cache
|
|
6 |
+from tests.testutils import cli_integration as cli
|
|
6 | 7 |
|
7 | 8 |
|
8 | 9 |
DATA_DIR = os.path.join(
|
... | ... | @@ -28,7 +29,7 @@ def create_test_directory(*path, mode=0o644): |
28 | 29 |
@pytest.mark.integration
|
29 | 30 |
@pytest.mark.datafiles(DATA_DIR)
|
30 | 31 |
@pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS] + ['local'])
|
31 |
-def test_deterministic_source_umask(cli, tmpdir, datafiles, kind):
|
|
32 |
+def test_deterministic_source_umask(cli, tmpdir, datafiles, kind, integration_cache):
|
|
32 | 33 |
project = str(datafiles)
|
33 | 34 |
element_name = 'list'
|
34 | 35 |
element_path = os.path.join(project, 'elements', element_name)
|
... | ... | @@ -91,14 +92,14 @@ def test_deterministic_source_umask(cli, tmpdir, datafiles, kind): |
91 | 92 |
return f.read()
|
92 | 93 |
finally:
|
93 | 94 |
os.umask(old_umask)
|
94 |
- cli.remove_artifact_from_cache(project, element_name)
|
|
95 |
+ remove_artifact_from_cache(os.path.join(integration_cache, 'artifacts'), element_name)
|
|
95 | 96 |
|
96 | 97 |
assert get_value_for_umask(0o022) == get_value_for_umask(0o077)
|
97 | 98 |
|
98 | 99 |
|
99 | 100 |
@pytest.mark.integration
|
100 | 101 |
@pytest.mark.datafiles(DATA_DIR)
|
101 |
-def test_deterministic_source_local(cli, tmpdir, datafiles):
|
|
102 |
+def test_deterministic_source_local(cli, tmpdir, datafiles, integration_cache):
|
|
102 | 103 |
"""Only user rights should be considered for local source.
|
103 | 104 |
"""
|
104 | 105 |
project = str(datafiles)
|
... | ... | @@ -150,6 +151,6 @@ def test_deterministic_source_local(cli, tmpdir, datafiles): |
150 | 151 |
with open(os.path.join(checkoutdir, 'ls-l'), 'r') as f:
|
151 | 152 |
return f.read()
|
152 | 153 |
finally:
|
153 |
- cli.remove_artifact_from_cache(project, element_name)
|
|
154 |
+ remove_artifact_from_cache(os.path.join(integration_cache, 'artifacts'), element_name)
|
|
154 | 155 |
|
155 | 156 |
assert get_value_for_mask(0o7777) == get_value_for_mask(0o0700)
|
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 |
# William Salmon <will salmon codethink co uk>
|
24 | 24 |
#
|
25 | 25 |
|
26 |
-from .runcli import cli, cli_integration
|
|
26 |
+from .runcli import cli, cli_integration, remove_artifact_from_cache
|
|
27 | 27 |
from .repo import create_repo, ALL_REPO_KINDS
|
28 | 28 |
from .artifactshare import create_artifact_share
|
29 | 29 |
from .element_generators import create_element_size
|
... | ... | @@ -171,6 +171,13 @@ class Result(): |
171 | 171 |
return list(pulled)
|
172 | 172 |
|
173 | 173 |
|
174 |
+def remove_artifact_from_cache(root_cache, element_name):
|
|
175 |
+ cache_dir = os.path.join(root_cache, 'cas', 'refs', 'heads')
|
|
176 |
+ |
|
177 |
+ cache_dir = os.path.splitext(os.path.join(cache_dir, 'test', element_name))[0]
|
|
178 |
+ shutil.rmtree(cache_dir)
|
|
179 |
+ |
|
180 |
+ |
|
174 | 181 |
class Cli():
|
175 | 182 |
|
176 | 183 |
def __init__(self, directory, verbose=True, default_options=None):
|
... | ... | @@ -199,12 +206,7 @@ class Cli(): |
199 | 206 |
self.config[key] = val
|
200 | 207 |
|
201 | 208 |
def remove_artifact_from_cache(self, project, element_name):
|
202 |
- cache_dir = os.path.join(project, 'cache', 'artifacts')
|
|
203 |
- |
|
204 |
- cache_dir = os.path.join(cache_dir, 'cas', 'refs', 'heads')
|
|
205 |
- |
|
206 |
- cache_dir = os.path.splitext(os.path.join(cache_dir, 'test', element_name))[0]
|
|
207 |
- shutil.rmtree(cache_dir)
|
|
209 |
+ remove_artifact_from_cache(os.path.join(project, 'cache', 'artifacts'), element_name)
|
|
208 | 210 |
|
209 | 211 |
# run():
|
210 | 212 |
#
|