Loading tests/integration/source-determinism.py +6 −5 Original line number Original line Diff line number Diff line Loading @@ -2,7 +2,8 @@ import os import pytest import pytest from buildstream import _yaml, utils from buildstream import _yaml, utils from tests.testutils import cli, create_repo, ALL_REPO_KINDS from tests.testutils import create_repo, ALL_REPO_KINDS, remove_artifact_from_cache from tests.testutils import cli_integration as cli DATA_DIR = os.path.join( DATA_DIR = os.path.join( Loading @@ -28,7 +29,7 @@ def create_test_directory(*path, mode=0o644): @pytest.mark.integration @pytest.mark.integration @pytest.mark.datafiles(DATA_DIR) @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS] + ['local']) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS] + ['local']) def test_deterministic_source_umask(cli, tmpdir, datafiles, kind): def test_deterministic_source_umask(cli, tmpdir, datafiles, kind, integration_cache): project = str(datafiles) project = str(datafiles) element_name = 'list' element_name = 'list' element_path = os.path.join(project, 'elements', element_name) element_path = os.path.join(project, 'elements', element_name) Loading Loading @@ -91,14 +92,14 @@ def test_deterministic_source_umask(cli, tmpdir, datafiles, kind): return f.read() return f.read() finally: finally: os.umask(old_umask) os.umask(old_umask) cli.remove_artifact_from_cache(project, element_name) remove_artifact_from_cache(os.path.join(integration_cache, 'artifacts'), element_name) assert get_value_for_umask(0o022) == get_value_for_umask(0o077) assert get_value_for_umask(0o022) == get_value_for_umask(0o077) @pytest.mark.integration @pytest.mark.integration @pytest.mark.datafiles(DATA_DIR) @pytest.mark.datafiles(DATA_DIR) def test_deterministic_source_local(cli, tmpdir, datafiles): def test_deterministic_source_local(cli, tmpdir, datafiles, integration_cache): """Only user rights should be considered for local source. """Only user rights should be considered for local source. """ """ project = str(datafiles) project = str(datafiles) Loading Loading @@ -150,6 +151,6 @@ def test_deterministic_source_local(cli, tmpdir, datafiles): with open(os.path.join(checkoutdir, 'ls-l'), 'r') as f: with open(os.path.join(checkoutdir, 'ls-l'), 'r') as f: return f.read() return f.read() finally: finally: cli.remove_artifact_from_cache(project, element_name) remove_artifact_from_cache(os.path.join(integration_cache, 'artifacts'), element_name) assert get_value_for_mask(0o7777) == get_value_for_mask(0o0700) assert get_value_for_mask(0o7777) == get_value_for_mask(0o0700) tests/testutils/__init__.py +1 −1 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,7 @@ # William Salmon <will.salmon@codethink.co.uk> # William Salmon <will.salmon@codethink.co.uk> # # from .runcli import cli, cli_integration from .runcli import cli, cli_integration, remove_artifact_from_cache from .repo import create_repo, ALL_REPO_KINDS from .repo import create_repo, ALL_REPO_KINDS from .artifactshare import create_artifact_share from .artifactshare import create_artifact_share from .element_generators import create_element_size from .element_generators import create_element_size Loading tests/testutils/runcli.py +8 −6 Original line number Original line Diff line number Diff line Loading @@ -171,6 +171,13 @@ class Result(): return list(pulled) return list(pulled) def remove_artifact_from_cache(root_cache, element_name): cache_dir = os.path.join(root_cache, 'cas', 'refs', 'heads') cache_dir = os.path.splitext(os.path.join(cache_dir, 'test', element_name))[0] shutil.rmtree(cache_dir) class Cli(): class Cli(): def __init__(self, directory, verbose=True, default_options=None): def __init__(self, directory, verbose=True, default_options=None): Loading Loading @@ -199,12 +206,7 @@ class Cli(): self.config[key] = val self.config[key] = val def remove_artifact_from_cache(self, project, element_name): def remove_artifact_from_cache(self, project, element_name): cache_dir = os.path.join(project, 'cache', 'artifacts') remove_artifact_from_cache(os.path.join(project, 'cache')) cache_dir = os.path.join(cache_dir, 'cas', 'refs', 'heads') cache_dir = os.path.splitext(os.path.join(cache_dir, 'test', element_name))[0] shutil.rmtree(cache_dir) # run(): # run(): # # Loading Loading
tests/integration/source-determinism.py +6 −5 Original line number Original line Diff line number Diff line Loading @@ -2,7 +2,8 @@ import os import pytest import pytest from buildstream import _yaml, utils from buildstream import _yaml, utils from tests.testutils import cli, create_repo, ALL_REPO_KINDS from tests.testutils import create_repo, ALL_REPO_KINDS, remove_artifact_from_cache from tests.testutils import cli_integration as cli DATA_DIR = os.path.join( DATA_DIR = os.path.join( Loading @@ -28,7 +29,7 @@ def create_test_directory(*path, mode=0o644): @pytest.mark.integration @pytest.mark.integration @pytest.mark.datafiles(DATA_DIR) @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS] + ['local']) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS] + ['local']) def test_deterministic_source_umask(cli, tmpdir, datafiles, kind): def test_deterministic_source_umask(cli, tmpdir, datafiles, kind, integration_cache): project = str(datafiles) project = str(datafiles) element_name = 'list' element_name = 'list' element_path = os.path.join(project, 'elements', element_name) element_path = os.path.join(project, 'elements', element_name) Loading Loading @@ -91,14 +92,14 @@ def test_deterministic_source_umask(cli, tmpdir, datafiles, kind): return f.read() return f.read() finally: finally: os.umask(old_umask) os.umask(old_umask) cli.remove_artifact_from_cache(project, element_name) remove_artifact_from_cache(os.path.join(integration_cache, 'artifacts'), element_name) assert get_value_for_umask(0o022) == get_value_for_umask(0o077) assert get_value_for_umask(0o022) == get_value_for_umask(0o077) @pytest.mark.integration @pytest.mark.integration @pytest.mark.datafiles(DATA_DIR) @pytest.mark.datafiles(DATA_DIR) def test_deterministic_source_local(cli, tmpdir, datafiles): def test_deterministic_source_local(cli, tmpdir, datafiles, integration_cache): """Only user rights should be considered for local source. """Only user rights should be considered for local source. """ """ project = str(datafiles) project = str(datafiles) Loading Loading @@ -150,6 +151,6 @@ def test_deterministic_source_local(cli, tmpdir, datafiles): with open(os.path.join(checkoutdir, 'ls-l'), 'r') as f: with open(os.path.join(checkoutdir, 'ls-l'), 'r') as f: return f.read() return f.read() finally: finally: cli.remove_artifact_from_cache(project, element_name) remove_artifact_from_cache(os.path.join(integration_cache, 'artifacts'), element_name) assert get_value_for_mask(0o7777) == get_value_for_mask(0o0700) assert get_value_for_mask(0o7777) == get_value_for_mask(0o0700)
tests/testutils/__init__.py +1 −1 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,7 @@ # William Salmon <will.salmon@codethink.co.uk> # William Salmon <will.salmon@codethink.co.uk> # # from .runcli import cli, cli_integration from .runcli import cli, cli_integration, remove_artifact_from_cache from .repo import create_repo, ALL_REPO_KINDS from .repo import create_repo, ALL_REPO_KINDS from .artifactshare import create_artifact_share from .artifactshare import create_artifact_share from .element_generators import create_element_size from .element_generators import create_element_size Loading
tests/testutils/runcli.py +8 −6 Original line number Original line Diff line number Diff line Loading @@ -171,6 +171,13 @@ class Result(): return list(pulled) return list(pulled) def remove_artifact_from_cache(root_cache, element_name): cache_dir = os.path.join(root_cache, 'cas', 'refs', 'heads') cache_dir = os.path.splitext(os.path.join(cache_dir, 'test', element_name))[0] shutil.rmtree(cache_dir) class Cli(): class Cli(): def __init__(self, directory, verbose=True, default_options=None): def __init__(self, directory, verbose=True, default_options=None): Loading Loading @@ -199,12 +206,7 @@ class Cli(): self.config[key] = val self.config[key] = val def remove_artifact_from_cache(self, project, element_name): def remove_artifact_from_cache(self, project, element_name): cache_dir = os.path.join(project, 'cache', 'artifacts') remove_artifact_from_cache(os.path.join(project, 'cache')) cache_dir = os.path.join(cache_dir, 'cas', 'refs', 'heads') cache_dir = os.path.splitext(os.path.join(cache_dir, 'test', element_name))[0] shutil.rmtree(cache_dir) # run(): # run(): # # Loading