diff options
author | Chandan Singh <chandan@chandansingh.net> | 2019-10-26 19:07:03 +0100 |
---|---|---|
committer | Chandan Singh <chandan@chandansingh.net> | 2019-11-04 11:01:14 +0000 |
commit | 576be1fc19bb58d25309a911589ceb9f08f7812d (patch) | |
tree | ad72fe64328e2cedd5415dfaa6eb7dd7ecc5576d /tests/frontend | |
parent | 66045d9c817992dbce855d4217ff00970ae7ff79 (diff) | |
download | buildstream-576be1fc19bb58d25309a911589ceb9f08f7812d.tar.gz |
frontend: Remove tracking options from `bst build`
BREAKING CHANGE: Remove all tracking related options and flags from
`bst build` command, as discussed on mailing list previously.
See
https://mail.gnome.org/archives/buildstream-list/2019-October/msg00009.html
for the original proposal, and
https://mail.gnome.org/archives/buildstream-list/2019-October/msg00024.html
for a summary.
At the same time, remove use of the removed options from our test suite.
Diffstat (limited to 'tests/frontend')
-rw-r--r-- | tests/frontend/buildtrack.py | 402 | ||||
-rw-r--r-- | tests/frontend/completions.py | 4 | ||||
-rw-r--r-- | tests/frontend/pull.py | 46 | ||||
-rw-r--r-- | tests/frontend/workspace.py | 115 |
4 files changed, 54 insertions, 513 deletions
diff --git a/tests/frontend/buildtrack.py b/tests/frontend/buildtrack.py deleted file mode 100644 index ff3c53281..000000000 --- a/tests/frontend/buildtrack.py +++ /dev/null @@ -1,402 +0,0 @@ -# Pylint doesn't play well with fixtures and dependency injection from pytest -# pylint: disable=redefined-outer-name - -import os -import re -import shutil -import itertools - -import pytest - -from buildstream import _yaml -from buildstream.testing import create_repo -from buildstream.testing import cli # pylint: disable=unused-import -from buildstream._exceptions import ErrorDomain -from tests.testutils import generate_junction - -from . import configure_project - -# Project directory -DATA_DIR = os.path.join( - os.path.dirname(os.path.realpath(__file__)), - "project", -) - - -def create_element(repo, name, path, dependencies, ref=None): - element = { - 'kind': 'import', - 'sources': [ - repo.source_config(ref=ref) - ], - 'depends': dependencies - } - _yaml.roundtrip_dump(element, os.path.join(path, name)) - - -@pytest.mark.datafiles(os.path.join(DATA_DIR)) -@pytest.mark.parametrize("strict", [True, False], ids=["strict", "no-strict"]) -@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) -@pytest.mark.parametrize("track_targets,exceptions,tracked", [ - # Test with no exceptions - (['0.bst'], [], ['0.bst', '2.bst', '3.bst', '4.bst', '5.bst', '6.bst', '7.bst']), - (['3.bst'], [], ['3.bst', '4.bst', '5.bst', '6.bst']), - (['2.bst', '3.bst'], [], ['2.bst', '3.bst', '4.bst', '5.bst', '6.bst', '7.bst']), - - # Test excepting '2.bst' - (['0.bst'], ['2.bst'], ['0.bst', '3.bst', '4.bst', '5.bst', '6.bst']), - (['3.bst'], ['2.bst'], []), - (['2.bst', '3.bst'], ['2.bst'], ['3.bst', '4.bst', '5.bst', '6.bst']), - - # Test excepting '2.bst' and '3.bst' - (['0.bst'], ['2.bst', '3.bst'], ['0.bst']), - (['3.bst'], ['2.bst', '3.bst'], []), - (['2.bst', '3.bst'], ['2.bst', '3.bst'], []) -]) -def test_build_track(cli, datafiles, tmpdir, ref_storage, strict, - track_targets, exceptions, tracked): - project = str(datafiles) - dev_files_path = os.path.join(project, 'files', 'dev-files') - element_path = os.path.join(project, 'elements') - - repo = create_repo('git', str(tmpdir)) - ref = repo.create(dev_files_path) - - configure_project(project, { - 'ref-storage': ref_storage - }) - cli.configure({ - 'projects': { - 'test': { - 'strict': strict - } - } - }) - - create_elements = { - '0.bst': [ - '2.bst', - '3.bst' - ], - '2.bst': [ - '3.bst', - '7.bst' - ], - '3.bst': [ - '4.bst', - '5.bst', - '6.bst' - ], - '4.bst': [], - '5.bst': [], - '6.bst': [ - '5.bst' - ], - '7.bst': [] - } - - initial_project_refs = {} - for element, dependencies in create_elements.items(): - # Test the element inconsistency resolution by ensuring that - # only elements that aren't tracked have refs - if element in set(tracked): - # Elements which should not have a ref set - # - create_element(repo, element, element_path, dependencies) - elif ref_storage == 'project.refs': - # Store a ref in project.refs - # - create_element(repo, element, element_path, dependencies) - initial_project_refs[element] = [{'ref': ref}] - else: - # Store a ref in the element itself - # - create_element(repo, element, element_path, dependencies, ref=ref) - - # Generate initial project.refs - if ref_storage == 'project.refs': - project_refs = { - 'projects': { - 'test': initial_project_refs - } - } - _yaml.roundtrip_dump(project_refs, os.path.join(project, 'project.refs')) - - args = ['build'] - args += itertools.chain.from_iterable(zip(itertools.repeat('--track'), track_targets)) - args += itertools.chain.from_iterable(zip(itertools.repeat('--track-except'), exceptions)) - args += ['0.bst'] - - result = cli.run(project=project, silent=True, args=args) - result.assert_success() - - # Assert that the main target 0.bst is cached - assert cli.get_element_state(project, '0.bst') == 'cached' - - # Assert that we tracked exactly the elements we expected to - tracked_elements = result.get_tracked_elements() - assert set(tracked_elements) == set(tracked) - - # Delete element sources - source_dir = os.path.join(project, 'cache', 'sources') - shutil.rmtree(source_dir) - source_protos = os.path.join(project, 'cache', 'source_protos') - shutil.rmtree(source_protos) - - # Delete artifacts one by one and assert element states - for target in set(tracked): - cli.remove_artifact_from_cache(project, target) - - # Assert that it's tracked - assert cli.get_element_state(project, target) == 'fetch needed' - - # Assert there was a project.refs created, depending on the configuration - if ref_storage == 'project.refs': - assert os.path.exists(os.path.join(project, 'project.refs')) - else: - assert not os.path.exists(os.path.join(project, 'project.refs')) - - -# This tests a very specific scenario: -# -# o Local cache is empty -# o Strict mode is disabled -# o The build target has only build dependencies -# o The build is launched with --track-all -# -# In this scenario, we have encountered bugs where BuildStream returns -# successfully after tracking completes without ever pulling, fetching or -# building anything. -# -@pytest.mark.datafiles(DATA_DIR) -@pytest.mark.parametrize("strict", [True, False], ids=["strict", "no-strict"]) -@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) -def test_build_track_all(cli, tmpdir, datafiles, strict, ref_storage): - project = os.path.join(datafiles.dirname, datafiles.basename) - subproject_path = os.path.join(project, 'files', 'sub-project') - subproject_element_path = os.path.join(project, 'files', 'sub-project', 'elements') - junction_path = os.path.join(project, 'elements', 'junction.bst') - element_path = os.path.join(project, 'elements') - dev_files_path = os.path.join(project, 'files', 'dev-files') - - configure_project(project, { - 'ref-storage': ref_storage - }) - cli.configure({ - 'projects': { - 'test': { - 'strict': strict - } - } - }) - - # We need a repo for real trackable elements - repo = create_repo('git', str(tmpdir)) - ref = repo.create(dev_files_path) - - # Create a trackable element to depend on the cross junction element, - # this one has it's ref resolved already - create_element(repo, 'sub-target.bst', subproject_element_path, ['import-etc.bst'], ref=ref) - - # Create a trackable element to depend on the cross junction element - create_element(repo, 'target.bst', element_path, [ - { - 'junction': 'junction.bst', - 'filename': 'sub-target.bst' - } - ]) - - # Create a repo to hold the subproject and generate a junction element for it - generate_junction(tmpdir, subproject_path, junction_path, store_ref=False) - - # Now create a compose element at the top level - element = { - 'kind': 'compose', - 'depends': [ - { - 'filename': 'target.bst', - 'type': 'build' - } - ] - } - _yaml.roundtrip_dump(element, os.path.join(element_path, 'composed.bst')) - - # Track the junction itself first. - result = cli.run(project=project, args=['source', 'track', 'junction.bst']) - result.assert_success() - - # Build it with --track-all - result = cli.run(project=project, silent=True, args=['build', '--track-all', 'composed.bst']) - result.assert_success() - - # Assert that the main target is cached as a result - assert cli.get_element_state(project, 'composed.bst') == 'cached' - - -@pytest.mark.datafiles(os.path.join(DATA_DIR)) -@pytest.mark.parametrize("track_targets,exceptions,tracked", [ - # Test with no exceptions - (['0.bst'], [], ['0.bst', '2.bst', '3.bst', '4.bst', '5.bst', '6.bst', '7.bst']), - (['3.bst'], [], ['3.bst', '4.bst', '5.bst', '6.bst']), - (['2.bst', '3.bst'], [], ['2.bst', '3.bst', '4.bst', '5.bst', '6.bst', '7.bst']), - - # Test excepting '2.bst' - (['0.bst'], ['2.bst'], ['0.bst', '3.bst', '4.bst', '5.bst', '6.bst']), - (['3.bst'], ['2.bst'], []), - (['2.bst', '3.bst'], ['2.bst'], ['3.bst', '4.bst', '5.bst', '6.bst']), - - # Test excepting '2.bst' and '3.bst' - (['0.bst'], ['2.bst', '3.bst'], ['0.bst']), - (['3.bst'], ['2.bst', '3.bst'], []), - (['2.bst', '3.bst'], ['2.bst', '3.bst'], []) -]) -def test_build_track_update(cli, datafiles, tmpdir, track_targets, - exceptions, tracked): - project = str(datafiles) - dev_files_path = os.path.join(project, 'files', 'dev-files') - element_path = os.path.join(project, 'elements') - - repo = create_repo('git', str(tmpdir)) - ref = repo.create(dev_files_path) - - create_elements = { - '0.bst': [ - '2.bst', - '3.bst' - ], - '2.bst': [ - '3.bst', - '7.bst' - ], - '3.bst': [ - '4.bst', - '5.bst', - '6.bst' - ], - '4.bst': [], - '5.bst': [], - '6.bst': [ - '5.bst' - ], - '7.bst': [] - } - for element, dependencies in create_elements.items(): - # We set a ref for all elements, so that we ensure that we - # only track exactly those elements that we want to track, - # even if others can be tracked - create_element(repo, element, element_path, dependencies, ref=ref) - repo.add_commit() - - args = ['build'] - args += itertools.chain.from_iterable(zip(itertools.repeat('--track'), track_targets)) - args += itertools.chain.from_iterable(zip(itertools.repeat('--track-except'), exceptions)) - args += ['0.bst'] - - result = cli.run(project=project, silent=True, args=args) - tracked_elements = result.get_tracked_elements() - - assert set(tracked_elements) == set(tracked) - - -@pytest.mark.datafiles(os.path.join(DATA_DIR)) -@pytest.mark.parametrize("track_targets,exceptions", [ - # Test tracking the main target element, but excepting some of its - # children - (['0.bst'], ['6.bst']), - - # Test only tracking a child element - (['3.bst'], []), -]) -def test_build_track_inconsistent(cli, datafiles, tmpdir, - track_targets, exceptions): - project = str(datafiles) - dev_files_path = os.path.join(project, 'files', 'dev-files') - element_path = os.path.join(project, 'elements') - - repo = create_repo('git', str(tmpdir)) - repo.create(dev_files_path) - - create_elements = { - '0.bst': [ - '2.bst', - '3.bst' - ], - '2.bst': [ - '3.bst', - '7.bst' - ], - '3.bst': [ - '4.bst', - '5.bst', - '6.bst' - ], - '4.bst': [], - '5.bst': [], - '6.bst': [ - '5.bst' - ], - '7.bst': [] - } - for element, dependencies in create_elements.items(): - # We don't add refs so that all elements *have* to be tracked - create_element(repo, element, element_path, dependencies) - - args = ['build'] - args += itertools.chain.from_iterable(zip(itertools.repeat('--track'), track_targets)) - args += itertools.chain.from_iterable(zip(itertools.repeat('--track-except'), exceptions)) - args += ['0.bst'] - - result = cli.run(project=project, args=args, silent=True) - result.assert_main_error(ErrorDomain.PIPELINE, "inconsistent-pipeline") - - -# Assert that if a build element has a dependency in the tracking -# queue it does not start building before tracking finishes. -@pytest.mark.datafiles(os.path.join(DATA_DIR)) -@pytest.mark.parametrize("strict", ['--strict', '--no-strict']) -def test_build_track_track_first(cli, datafiles, tmpdir, strict): - project = str(datafiles) - dev_files_path = os.path.join(project, 'files', 'dev-files') - element_path = os.path.join(project, 'elements') - - repo = create_repo('git', str(tmpdir)) - ref = repo.create(dev_files_path) - - create_elements = { - '0.bst': [ - '1.bst' - ], - '1.bst': [], - '2.bst': [ - '0.bst' - ] - } - for element, dependencies in create_elements.items(): - # We set a ref so that 0.bst can already be built even if - # 1.bst has not been tracked yet. - create_element(repo, element, element_path, dependencies, ref=ref) - repo.add_commit() - - # Build 1.bst and 2.bst first so we have an artifact for them - args = [strict, 'build', '2.bst'] - result = cli.run(args=args, project=project, silent=True) - result.assert_success() - - # Test building 0.bst while tracking 1.bst - cli.remove_artifact_from_cache(project, '0.bst') - - args = [strict, 'build', '--track', '1.bst', '2.bst'] - result = cli.run(args=args, project=project, silent=True) - result.assert_success() - - # Assert that 1.bst successfully tracks before 0.bst builds - track_messages = re.finditer(r'\[track:1.bst\s*]', result.stderr) - build_0 = re.search(r'\[\s*build:0.bst\s*] START', result.stderr).start() - assert all(track_message.start() < build_0 for track_message in track_messages) - - # Assert that 2.bst is *only* rebuilt if we are in strict mode - build_2 = re.search(r'\[\s*build:2.bst\s*] START', result.stderr) - if strict == '--strict': - assert build_2 is not None - else: - assert build_2 is None diff --git a/tests/frontend/completions.py b/tests/frontend/completions.py index c88d0e0b9..5df873666 100644 --- a/tests/frontend/completions.py +++ b/tests/frontend/completions.py @@ -147,10 +147,6 @@ def test_commands(cli, cmd, word_idx, expected): # Test that options of subcommands also complete ('bst --no-colors build -', 3, ['--deps ', '-d ', - '--track ', '--track-all ', - '--track-except ', - '--track-cross-junctions ', '-J ', - '--track-save ', '--remote ', '-r ']), # Test the behavior of completing after an option that has a diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py index 2dee10ac0..234f1133d 100644 --- a/tests/frontend/pull.py +++ b/tests/frontend/pull.py @@ -264,52 +264,6 @@ def test_push_pull_non_strict(cli, tmpdir, datafiles): assert cli.get_element_state(project, 'target.bst') == 'cached' -# Regression test for https://gitlab.com/BuildStream/buildstream/issues/202 -@pytest.mark.datafiles(DATA_DIR) -def test_push_pull_track_non_strict(cli, tmpdir, datafiles): - project = str(datafiles) - - with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share: - - # First build the target element and push to the remote. - cli.configure({ - 'artifacts': {'url': share.repo, 'push': True}, - 'projects': { - 'test': {'strict': False} - } - }) - result = cli.run(project=project, args=['build', 'target.bst']) - result.assert_success() - assert cli.get_element_state(project, 'target.bst') == 'cached' - - # Assert that everything is now cached in the remote. - all_elements = {'target.bst', 'import-bin.bst', 'import-dev.bst', 'compose-all.bst'} - for element_name in all_elements: - assert_shared(cli, share, project, element_name) - - # Now we've pushed, delete the user's local artifact cache - # directory and try to redownload it from the share - # - casdir = os.path.join(cli.directory, 'cas') - shutil.rmtree(casdir) - artifactdir = os.path.join(cli.directory, 'artifacts') - shutil.rmtree(artifactdir) - - # Assert that nothing is cached locally anymore - for element_name in all_elements: - assert cli.get_element_state(project, element_name) != 'cached' - - # Now try bst build with tracking and pulling. - # Tracking will be skipped for target.bst as it doesn't have any sources. - # With the non-strict build plan target.bst immediately enters the pull queue. - # However, pulling has to be deferred until the dependencies have been - # tracked as the strict cache key needs to be calculated before querying - # the caches. - result = cli.run(project=project, args=['build', '--track-all', '--deps', 'all', 'target.bst']) - result.assert_success() - assert set(result.get_pulled_elements()) == all_elements - - @pytest.mark.datafiles(DATA_DIR) def test_push_pull_cross_junction(cli, tmpdir, datafiles): project = str(datafiles) diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py index b53a62da8..43cd6f381 100644 --- a/tests/frontend/workspace.py +++ b/tests/frontend/workspace.py @@ -67,7 +67,7 @@ class WorkspaceCreator(): self.workspace_cmd = os.path.join(self.project_path, 'workspace_cmd') - def create_workspace_element(self, kind, track, suffix='', workspace_dir=None, + def create_workspace_element(self, kind, suffix='', workspace_dir=None, element_attrs=None): element_name = 'workspace-test-{}{}.bst'.format(kind, suffix) element_path = os.path.join(self.project_path, 'elements') @@ -80,8 +80,6 @@ class WorkspaceCreator(): # the bin files, and then collect the initial ref. repo = create_repo(kind, str(self.tmpdir)) ref = repo.create(self.bin_files_path) - if track: - ref = None # Write out our test target element = { @@ -96,7 +94,7 @@ class WorkspaceCreator(): os.path.join(element_path, element_name)) return element_name, element_path, workspace_dir - def create_workspace_elements(self, kinds, track, suffixs=None, workspace_dir_usr=None, + def create_workspace_elements(self, kinds, suffixs=None, workspace_dir_usr=None, element_attrs=None): element_tuples = [] @@ -109,33 +107,28 @@ class WorkspaceCreator(): for suffix, kind in zip(suffixs, kinds): element_name, _, workspace_dir = \ - self.create_workspace_element(kind, track, suffix, workspace_dir_usr, + self.create_workspace_element(kind, suffix, workspace_dir_usr, element_attrs) element_tuples.append((element_name, workspace_dir)) - # Assert that there is no reference, a track & fetch is needed + # Assert that there is a fetch is needed states = self.cli.get_element_states(self.project_path, [ e for e, _ in element_tuples ]) - if track: - assert not any(states[e] != 'no reference' for e, _ in element_tuples) - else: - assert not any(states[e] != 'fetch needed' for e, _ in element_tuples) + assert not any(states[e] != 'fetch needed' for e, _ in element_tuples) return element_tuples - def open_workspaces(self, kinds, track, suffixs=None, workspace_dir=None, + def open_workspaces(self, kinds, suffixs=None, workspace_dir=None, element_attrs=None, no_checkout=False): - element_tuples = self.create_workspace_elements(kinds, track, suffixs, workspace_dir, + element_tuples = self.create_workspace_elements(kinds, suffixs, workspace_dir, element_attrs) os.makedirs(self.workspace_cmd, exist_ok=True) # Now open the workspace, this should have the effect of automatically # tracking & fetching the source from the repo. args = ['workspace', 'open'] - if track: - args.append('--track') if no_checkout: args.append('--no-checkout') if workspace_dir is not None: @@ -163,10 +156,10 @@ class WorkspaceCreator(): return element_tuples -def open_workspace(cli, tmpdir, datafiles, kind, track, suffix='', workspace_dir=None, +def open_workspace(cli, tmpdir, datafiles, kind, suffix='', workspace_dir=None, project_path=None, element_attrs=None, no_checkout=False): workspace_object = WorkspaceCreator(cli, tmpdir, datafiles, project_path) - workspaces = workspace_object.open_workspaces((kind, ), track, (suffix, ), workspace_dir, + workspaces = workspace_object.open_workspaces((kind, ), (suffix, ), workspace_dir, element_attrs, no_checkout) assert len(workspaces) == 1 element_name, workspace = workspaces[0] @@ -175,7 +168,7 @@ def open_workspace(cli, tmpdir, datafiles, kind, track, suffix='', workspace_dir @pytest.mark.datafiles(DATA_DIR) def test_open_bzr_customize(cli, tmpdir, datafiles): - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "bzr", False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "bzr") # Check that the .bzr dir exists bzrdir = os.path.join(workspace, ".bzr") @@ -195,7 +188,7 @@ def test_open_bzr_customize(cli, tmpdir, datafiles): def test_open_multi(cli, tmpdir, datafiles): workspace_object = WorkspaceCreator(cli, tmpdir, datafiles) - workspaces = workspace_object.open_workspaces(repo_kinds, False) + workspaces = workspace_object.open_workspaces(repo_kinds) for (elname, workspace), kind in zip(workspaces, repo_kinds): assert kind in elname @@ -214,7 +207,7 @@ def test_open_multi(cli, tmpdir, datafiles): def test_open_multi_unwritable(cli, tmpdir, datafiles): workspace_object = WorkspaceCreator(cli, tmpdir, datafiles) - element_tuples = workspace_object.create_workspace_elements(repo_kinds, False, repo_kinds) + element_tuples = workspace_object.create_workspace_elements(repo_kinds, repo_kinds) os.makedirs(workspace_object.workspace_cmd, exist_ok=True) # Now open the workspace, this should have the effect of automatically @@ -241,7 +234,7 @@ def test_open_multi_unwritable(cli, tmpdir, datafiles): def test_open_multi_with_directory(cli, tmpdir, datafiles): workspace_object = WorkspaceCreator(cli, tmpdir, datafiles) - element_tuples = workspace_object.create_workspace_elements(repo_kinds, False, repo_kinds) + element_tuples = workspace_object.create_workspace_elements(repo_kinds, repo_kinds) os.makedirs(workspace_object.workspace_cmd, exist_ok=True) # Now open the workspace, this should have the effect of automatically @@ -261,7 +254,7 @@ def test_open_defaultlocation(cli, tmpdir, datafiles): workspace_object = WorkspaceCreator(cli, tmpdir, datafiles) # pylint: disable=unbalanced-tuple-unpacking - ((element_name, workspace_dir), ) = workspace_object.create_workspace_elements(['git'], False, ['git']) + ((element_name, workspace_dir), ) = workspace_object.create_workspace_elements(['git'], ['git']) os.makedirs(workspace_object.workspace_cmd, exist_ok=True) # Now open the workspace, this should have the effect of automatically @@ -294,7 +287,7 @@ def test_open_defaultlocation_exists(cli, tmpdir, datafiles): workspace_object = WorkspaceCreator(cli, tmpdir, datafiles) # pylint: disable=unbalanced-tuple-unpacking - ((element_name, workspace_dir), ) = workspace_object.create_workspace_elements(['git'], False, ['git']) + ((element_name, workspace_dir), ) = workspace_object.create_workspace_elements(['git'], ['git']) os.makedirs(workspace_object.workspace_cmd, exist_ok=True) with open(workspace_dir, 'w') as fl: @@ -318,12 +311,12 @@ def test_open_defaultlocation_exists(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) def test_open_track(cli, tmpdir, datafiles): - open_workspace(cli, tmpdir, datafiles, 'git', True) + open_workspace(cli, tmpdir, datafiles, 'git') @pytest.mark.datafiles(DATA_DIR) def test_open_force(cli, tmpdir, datafiles): - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git') # Close the workspace result = cli.run(project=project, args=[ @@ -343,7 +336,7 @@ def test_open_force(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) def test_open_force_open(cli, tmpdir, datafiles): - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git') # Assert the workspace dir exists assert os.path.exists(workspace) @@ -358,7 +351,7 @@ def test_open_force_open(cli, tmpdir, datafiles): # Regression test for #1086. @pytest.mark.datafiles(DATA_DIR) def test_open_force_open_no_checkout(cli, tmpdir, datafiles): - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git') hello_path = os.path.join(workspace, 'hello.txt') # Assert the workspace dir exists @@ -382,7 +375,7 @@ def test_open_force_open_no_checkout(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) def test_open_force_different_workspace(cli, tmpdir, datafiles): - _, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False, "-alpha") + _, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', "-alpha") # Assert the workspace dir exists assert os.path.exists(workspace) @@ -392,7 +385,7 @@ def test_open_force_different_workspace(cli, tmpdir, datafiles): tmpdir = os.path.join(str(tmpdir), "-beta") shutil.move(hello_path, hello1_path) - element_name2, _, workspace2 = open_workspace(cli, tmpdir, datafiles, 'git', False, "-beta") + element_name2, _, workspace2 = open_workspace(cli, tmpdir, datafiles, 'git', "-beta") # Assert the workspace dir exists assert os.path.exists(workspace2) @@ -418,7 +411,7 @@ def test_open_force_different_workspace(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) def test_close(cli, tmpdir, datafiles): - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git') # Close the workspace result = cli.run(project=project, args=[ @@ -434,7 +427,7 @@ def test_close(cli, tmpdir, datafiles): def test_close_external_after_move_project(cli, tmpdir, datafiles): workspace_dir = os.path.join(str(tmpdir), "workspace") project_path = os.path.join(str(tmpdir), 'initial_project') - element_name, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', False, "", workspace_dir, project_path) + element_name, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', "", workspace_dir, project_path) assert os.path.exists(workspace_dir) moved_dir = os.path.join(str(tmpdir), 'external_project') shutil.move(project_path, moved_dir) @@ -454,7 +447,7 @@ def test_close_external_after_move_project(cli, tmpdir, datafiles): def test_close_internal_after_move_project(cli, tmpdir, datafiles): initial_dir = os.path.join(str(tmpdir), 'initial_project') initial_workspace = os.path.join(initial_dir, 'workspace') - element_name, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', False, + element_name, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', workspace_dir=initial_workspace, project_path=initial_dir) moved_dir = os.path.join(str(tmpdir), 'internal_project') shutil.move(initial_dir, moved_dir) @@ -473,7 +466,7 @@ def test_close_internal_after_move_project(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) def test_close_removed(cli, tmpdir, datafiles): - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git') # Remove it first, closing the workspace should work shutil.rmtree(workspace) @@ -490,7 +483,7 @@ def test_close_removed(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) def test_close_nonexistant_element(cli, tmpdir, datafiles): - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git') element_path = os.path.join(datafiles.dirname, datafiles.basename, 'elements', element_name) # First brutally remove the element.bst file, ensuring that @@ -513,9 +506,9 @@ def test_close_multiple(cli, tmpdir, datafiles): tmpdir_alpha = os.path.join(str(tmpdir), 'alpha') tmpdir_beta = os.path.join(str(tmpdir), 'beta') alpha, project, workspace_alpha = open_workspace( - cli, tmpdir_alpha, datafiles, 'git', False, suffix='-alpha') + cli, tmpdir_alpha, datafiles, 'git', suffix='-alpha') beta, project, workspace_beta = open_workspace( - cli, tmpdir_beta, datafiles, 'git', False, suffix='-beta') + cli, tmpdir_beta, datafiles, 'git', suffix='-beta') # Close the workspaces result = cli.run(project=project, args=[ @@ -533,9 +526,9 @@ def test_close_all(cli, tmpdir, datafiles): tmpdir_alpha = os.path.join(str(tmpdir), 'alpha') tmpdir_beta = os.path.join(str(tmpdir), 'beta') _, project, workspace_alpha = open_workspace( - cli, tmpdir_alpha, datafiles, 'git', False, suffix='-alpha') + cli, tmpdir_alpha, datafiles, 'git', suffix='-alpha') _, project, workspace_beta = open_workspace( - cli, tmpdir_beta, datafiles, 'git', False, suffix='-beta') + cli, tmpdir_beta, datafiles, 'git', suffix='-beta') # Close the workspaces result = cli.run(project=project, args=[ @@ -551,7 +544,7 @@ def test_close_all(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) def test_reset(cli, tmpdir, datafiles): # Open the workspace - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git') # Modify workspace shutil.rmtree(os.path.join(workspace, 'usr', 'bin')) @@ -572,7 +565,7 @@ def test_reset(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) def test_reset_soft(cli, tmpdir, datafiles): # Open the workspace - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git') assert cli.get_element_state(project, element_name) == 'buildable' @@ -627,9 +620,9 @@ def test_reset_multiple(cli, tmpdir, datafiles): tmpdir_alpha = os.path.join(str(tmpdir), 'alpha') tmpdir_beta = os.path.join(str(tmpdir), 'beta') alpha, project, workspace_alpha = open_workspace( - cli, tmpdir_alpha, datafiles, 'git', False, suffix='-alpha') + cli, tmpdir_alpha, datafiles, 'git', suffix='-alpha') beta, project, workspace_beta = open_workspace( - cli, tmpdir_beta, datafiles, 'git', False, suffix='-beta') + cli, tmpdir_beta, datafiles, 'git', suffix='-beta') # Modify workspaces shutil.rmtree(os.path.join(workspace_alpha, 'usr', 'bin')) @@ -653,9 +646,9 @@ def test_reset_all(cli, tmpdir, datafiles): tmpdir_alpha = os.path.join(str(tmpdir), 'alpha') tmpdir_beta = os.path.join(str(tmpdir), 'beta') _, project, workspace_alpha = open_workspace( - cli, tmpdir_alpha, datafiles, 'git', False, suffix='-alpha') + cli, tmpdir_alpha, datafiles, 'git', suffix='-alpha') _, project, workspace_beta = open_workspace( - cli, tmpdir_beta, datafiles, 'git', False, suffix='-beta') + cli, tmpdir_beta, datafiles, 'git', suffix='-beta') # Modify workspaces shutil.rmtree(os.path.join(workspace_alpha, 'usr', 'bin')) @@ -675,7 +668,7 @@ def test_reset_all(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) def test_list(cli, tmpdir, datafiles): - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git') # Now list the workspaces result = cli.run(project=project, args=[ @@ -785,7 +778,7 @@ def test_buildable_no_ref(cli, tmpdir, datafiles): @pytest.mark.parametrize("modification", [("addfile"), ("removefile"), ("modifyfile")]) @pytest.mark.parametrize("strict", [("strict"), ("non-strict")]) def test_detect_modifications(cli, tmpdir, datafiles, modification, strict): - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git') checkout = os.path.join(str(tmpdir), 'checkout') # Configure strict mode @@ -1055,7 +1048,7 @@ def test_list_supported_workspace(cli, tmpdir, datafiles, workspace_cfg, expecte @pytest.mark.datafiles(DATA_DIR) def test_inconsitent_pipeline_message(cli, tmpdir, datafiles): - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git') shutil.rmtree(workspace) @@ -1070,7 +1063,7 @@ def test_inconsitent_pipeline_message(cli, tmpdir, datafiles): def test_cache_key_workspace_in_dependencies(cli, tmpdir, datafiles, strict): checkout = os.path.join(str(tmpdir), 'checkout') element_name, project, workspace = open_workspace(cli, os.path.join(str(tmpdir), 'repo-a'), - datafiles, 'git', False) + datafiles, 'git') element_path = os.path.join(project, 'elements') back_dep_element_name = 'workspace-test-back-dep.bst' @@ -1153,7 +1146,7 @@ def test_multiple_failed_builds(cli, tmpdir, datafiles): } } element_name, project, _ = open_workspace(cli, tmpdir, datafiles, - "git", False, element_attrs=element_config) + "git", element_attrs=element_config) for _ in range(2): result = cli.run(project=project, args=["build", element_name]) @@ -1174,7 +1167,7 @@ def test_external_fetch(cli, datafiles, tmpdir_factory, subdir, guess_element): create_element_size(depend_element, str(datafiles), 'elements', [], 1024) element_name, project, workspace = open_workspace( - cli, tmpdir, datafiles, "git", False, no_checkout=True, + cli, tmpdir, datafiles, "git", no_checkout=True, element_attrs={'depends': [depend_element]} ) arg_elm = [element_name] if not guess_element else [] @@ -1201,7 +1194,7 @@ def test_external_fetch(cli, datafiles, tmpdir_factory, subdir, guess_element): def test_external_push_pull(cli, datafiles, tmpdir_factory, guess_element): # Pushing and pulling to/from an artifact cache works from an external workspace tmpdir = tmpdir_factory.mktemp('') - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "git") arg_elm = [element_name] if not guess_element else [] with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share: @@ -1226,7 +1219,7 @@ def test_external_push_pull(cli, datafiles, tmpdir_factory, guess_element): @pytest.mark.parametrize("guess_element", [True, False], ids=["guess", "no-guess"]) def test_external_track(cli, datafiles, tmpdir_factory, guess_element): tmpdir = tmpdir_factory.mktemp('') - element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", False) + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "git") element_file = os.path.join(str(datafiles), 'elements', element_name) arg_elm = [element_name] if not guess_element else [] @@ -1264,8 +1257,8 @@ def test_external_open_other(cli, datafiles, tmpdir_factory): tmpdir1 = tmpdir_factory.mktemp('') tmpdir2 = tmpdir_factory.mktemp('') # Making use of the assumption that it's the same project in both invocations of open_workspace - _, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", False, suffix="-alpha") - beta_element, _, beta_workspace = open_workspace(cli, tmpdir2, datafiles, "git", False, suffix="-beta") + _, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", suffix="-alpha") + beta_element, _, beta_workspace = open_workspace(cli, tmpdir2, datafiles, "git", suffix="-beta") # Closing the other element first, because I'm too lazy to create an # element without opening it @@ -1284,8 +1277,8 @@ def test_external_close_other(cli, datafiles, tmpdir_factory): tmpdir1 = tmpdir_factory.mktemp('') tmpdir2 = tmpdir_factory.mktemp('') # Making use of the assumption that it's the same project in both invocations of open_workspace - _, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", False, suffix="-alpha") - beta_element, _, _ = open_workspace(cli, tmpdir2, datafiles, "git", False, suffix="-beta") + _, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", suffix="-alpha") + beta_element, _, _ = open_workspace(cli, tmpdir2, datafiles, "git", suffix="-beta") result = cli.run(project=project, args=['-C', alpha_workspace, 'workspace', 'close', beta_element]) result.assert_success() @@ -1299,8 +1292,8 @@ def test_external_close_self(cli, datafiles, tmpdir_factory, guess_element): tmpdir1 = tmpdir_factory.mktemp('') tmpdir2 = tmpdir_factory.mktemp('') # Making use of the assumption that it's the same project in both invocations of open_workspace - alpha_element, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", False, suffix="-alpha") - _, _, _ = open_workspace(cli, tmpdir2, datafiles, "git", False, suffix="-beta") + alpha_element, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", suffix="-alpha") + _, _, _ = open_workspace(cli, tmpdir2, datafiles, "git", suffix="-beta") arg_elm = [alpha_element] if not guess_element else [] result = cli.run(project=project, args=['-C', alpha_workspace, 'workspace', 'close', *arg_elm]) @@ -1313,8 +1306,8 @@ def test_external_reset_other(cli, datafiles, tmpdir_factory): tmpdir1 = tmpdir_factory.mktemp('') tmpdir2 = tmpdir_factory.mktemp('') # Making use of the assumption that it's the same project in both invocations of open_workspace - _, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", False, suffix="-alpha") - beta_element, _, _ = open_workspace(cli, tmpdir2, datafiles, "git", False, suffix="-beta") + _, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", suffix="-alpha") + beta_element, _, _ = open_workspace(cli, tmpdir2, datafiles, "git", suffix="-beta") result = cli.run(project=project, args=['-C', alpha_workspace, 'workspace', 'reset', beta_element]) result.assert_success() @@ -1323,7 +1316,7 @@ def test_external_reset_other(cli, datafiles, tmpdir_factory): @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize("guess_element", [True, False], ids=["guess", "no-guess"]) def test_external_reset_self(cli, datafiles, tmpdir, guess_element): - element, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", False) + element, project, workspace = open_workspace(cli, tmpdir, datafiles, "git") arg_elm = [element] if not guess_element else [] # Command succeeds @@ -1339,7 +1332,7 @@ def test_external_reset_self(cli, datafiles, tmpdir, guess_element): def test_external_list(cli, datafiles, tmpdir_factory): tmpdir = tmpdir_factory.mktemp('') # Making use of the assumption that it's the same project in both invocations of open_workspace - _, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", False) + _, project, workspace = open_workspace(cli, tmpdir, datafiles, "git") result = cli.run(project=project, args=['-C', workspace, 'workspace', 'list']) result.assert_success() |