diff options
Diffstat (limited to 'src/buildstream/testing/_sourcetests')
-rw-r--r-- | src/buildstream/testing/_sourcetests/build_checkout.py | 5 | ||||
-rw-r--r-- | src/buildstream/testing/_sourcetests/fetch.py | 12 | ||||
-rw-r--r-- | src/buildstream/testing/_sourcetests/mirror.py | 28 | ||||
-rw-r--r-- | src/buildstream/testing/_sourcetests/source_determinism.py | 13 | ||||
-rw-r--r-- | src/buildstream/testing/_sourcetests/track.py | 65 | ||||
-rw-r--r-- | src/buildstream/testing/_sourcetests/track_cross_junction.py | 22 | ||||
-rw-r--r-- | src/buildstream/testing/_sourcetests/utils.py | 11 | ||||
-rw-r--r-- | src/buildstream/testing/_sourcetests/workspace.py | 40 |
8 files changed, 42 insertions, 154 deletions
diff --git a/src/buildstream/testing/_sourcetests/build_checkout.py b/src/buildstream/testing/_sourcetests/build_checkout.py index e673702e2..d0abb0345 100644 --- a/src/buildstream/testing/_sourcetests/build_checkout.py +++ b/src/buildstream/testing/_sourcetests/build_checkout.py @@ -64,10 +64,7 @@ def test_fetch_build_checkout(cli, tmpdir, datafiles, strict, kind): # Now check it out result = cli.run( - project=project, - args=strict_args( - ["artifact", "checkout", element_name, "--directory", checkout], strict - ), + project=project, args=strict_args(["artifact", "checkout", element_name, "--directory", checkout], strict), ) result.assert_success() diff --git a/src/buildstream/testing/_sourcetests/fetch.py b/src/buildstream/testing/_sourcetests/fetch.py index fc95c6e5b..e07bf8824 100644 --- a/src/buildstream/testing/_sourcetests/fetch.py +++ b/src/buildstream/testing/_sourcetests/fetch.py @@ -85,19 +85,13 @@ def test_fetch_cross_junction(cli, tmpdir, datafiles, ref_storage, kind): update_project_configuration(project, {"ref-storage": ref_storage}) - generate_junction( - tmpdir, subproject_path, junction_path, store_ref=(ref_storage == "inline") - ) + generate_junction(tmpdir, subproject_path, junction_path, store_ref=(ref_storage == "inline")) if ref_storage == "project.refs": result = cli.run(project=project, args=["source", "track", "junction.bst"]) result.assert_success() - result = cli.run( - project=project, args=["source", "track", "junction.bst:import-etc.bst"] - ) + result = cli.run(project=project, args=["source", "track", "junction.bst:import-etc.bst"]) result.assert_success() - result = cli.run( - project=project, args=["source", "fetch", "junction.bst:import-etc.bst"] - ) + result = cli.run(project=project, args=["source", "fetch", "junction.bst:import-etc.bst"]) result.assert_success() diff --git a/src/buildstream/testing/_sourcetests/mirror.py b/src/buildstream/testing/_sourcetests/mirror.py index a28bf3c00..b907a6ee4 100644 --- a/src/buildstream/testing/_sourcetests/mirror.py +++ b/src/buildstream/testing/_sourcetests/mirror.py @@ -163,17 +163,11 @@ def test_mirror_from_includes(cli, tmpdir, datafiles, kind): config_project_dir = str(tmpdir.join("config")) os.makedirs(config_project_dir, exist_ok=True) config_project = {"name": "config"} - _yaml.roundtrip_dump( - config_project, os.path.join(config_project_dir, "project.conf") - ) - extra_mirrors = { - "mirrors": [{"name": "middle-earth", "aliases": {alias: [mirror_map + "/"],}}] - } + _yaml.roundtrip_dump(config_project, os.path.join(config_project_dir, "project.conf")) + extra_mirrors = {"mirrors": [{"name": "middle-earth", "aliases": {alias: [mirror_map + "/"],}}]} _yaml.roundtrip_dump(extra_mirrors, os.path.join(config_project_dir, "mirrors.yml")) generate_junction( - str(tmpdir.join("config_repo")), - config_project_dir, - os.path.join(element_dir, "config.bst"), + str(tmpdir.join("config_repo")), config_project_dir, os.path.join(element_dir, "config.bst"), ) _set_project_includes_and_aliases( @@ -217,22 +211,14 @@ def test_mirror_junction_from_includes(cli, tmpdir, datafiles, kind): config_project_dir = str(tmpdir.join("config")) os.makedirs(config_project_dir, exist_ok=True) config_project = {"name": "config"} - _yaml.roundtrip_dump( - config_project, os.path.join(config_project_dir, "project.conf") - ) - extra_mirrors = { - "mirrors": [{"name": "middle-earth", "aliases": {alias: [mirror_map + "/"],}}] - } + _yaml.roundtrip_dump(config_project, os.path.join(config_project_dir, "project.conf")) + extra_mirrors = {"mirrors": [{"name": "middle-earth", "aliases": {alias: [mirror_map + "/"],}}]} _yaml.roundtrip_dump(extra_mirrors, os.path.join(config_project_dir, "mirrors.yml")) generate_junction( - str(tmpdir.join("config_repo")), - config_project_dir, - os.path.join(element_dir, "config.bst"), + str(tmpdir.join("config_repo")), config_project_dir, os.path.join(element_dir, "config.bst"), ) - _set_project_includes_and_aliases( - project_dir, ["config.bst:mirrors.yml"], {alias: upstream_map + "/"} - ) + _set_project_includes_and_aliases(project_dir, ["config.bst:mirrors.yml"], {alias: upstream_map + "/"}) # Now make the upstream unavailable. os.rename(upstream_repo.repo, "{}.bak".format(upstream_repo.repo)) diff --git a/src/buildstream/testing/_sourcetests/source_determinism.py b/src/buildstream/testing/_sourcetests/source_determinism.py index 465afa23b..d829984a8 100644 --- a/src/buildstream/testing/_sourcetests/source_determinism.py +++ b/src/buildstream/testing/_sourcetests/source_determinism.py @@ -49,12 +49,8 @@ def create_test_directory(*path, mode=0o644): @pytest.mark.integration @pytest.mark.datafiles(DATA_DIR) -@pytest.mark.skipif( - not HAVE_SANDBOX, reason="Only available with a functioning sandbox" -) -@pytest.mark.skipif( - HAVE_SANDBOX == "buildbox", reason="Not working with BuildBox, Must Fix" -) +@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox") +@pytest.mark.skipif(HAVE_SANDBOX == "buildbox", reason="Not working with BuildBox, Must Fix") def test_deterministic_source_umask(cli, tmpdir, datafiles, kind): project = str(datafiles) element_name = "list.bst" @@ -96,10 +92,7 @@ def test_deterministic_source_umask(cli, tmpdir, datafiles, kind): result = cli.run(project=project, args=["build", element_name]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", element_name, "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkoutdir],) result.assert_success() with open(os.path.join(checkoutdir, "ls-l"), "r") as f: diff --git a/src/buildstream/testing/_sourcetests/track.py b/src/buildstream/testing/_sourcetests/track.py index c857e246d..8c54f6259 100644 --- a/src/buildstream/testing/_sourcetests/track.py +++ b/src/buildstream/testing/_sourcetests/track.py @@ -138,18 +138,14 @@ def test_track_recurse(cli, tmpdir, datafiles, kind, amount): assert states[element_name] == "no reference" # Now first try to track it - result = cli.run( - project=project, args=["source", "track", "--deps", "all", last_element_name] - ) + result = cli.run(project=project, args=["source", "track", "--deps", "all", last_element_name]) result.assert_success() # And now fetch it: The Source has probably already cached the # latest ref locally, but it is not required to have cached # the associated content of the latest ref at track time, that # is the job of fetch. - result = cli.run( - project=project, args=["source", "fetch", "--deps", "all", last_element_name] - ) + result = cli.run(project=project, args=["source", "fetch", "--deps", "all", last_element_name]) result.assert_success() # Assert that the base is buildable and the rest are waiting @@ -177,9 +173,7 @@ def test_track_recurse_except(cli, tmpdir, datafiles, kind): # Write out our test targets generate_element(repo, os.path.join(element_path, element_dep_name)) - generate_element( - repo, os.path.join(element_path, element_target_name), dep_name=element_dep_name - ) + generate_element(repo, os.path.join(element_path, element_target_name), dep_name=element_dep_name) # Assert that a fetch is needed states = cli.get_element_states(project, [element_target_name]) @@ -188,16 +182,7 @@ def test_track_recurse_except(cli, tmpdir, datafiles, kind): # Now first try to track it result = cli.run( - project=project, - args=[ - "source", - "track", - "--deps", - "all", - "--except", - element_dep_name, - element_target_name, - ], + project=project, args=["source", "track", "--deps", "all", "--except", element_dep_name, element_target_name,], ) result.assert_success() @@ -205,9 +190,7 @@ def test_track_recurse_except(cli, tmpdir, datafiles, kind): # latest ref locally, but it is not required to have cached # the associated content of the latest ref at track time, that # is the job of fetch. - result = cli.run( - project=project, args=["source", "fetch", "--deps", "none", element_target_name] - ) + result = cli.run(project=project, args=["source", "fetch", "--deps", "none", element_target_name]) result.assert_success() # Assert that the dependency is buildable and the target is waiting @@ -233,25 +216,17 @@ def test_cross_junction(cli, tmpdir, datafiles, ref_storage, kind): generate_element(repo, repo_element_path) generate_junction( - str(tmpdir.join("junction_repo")), - subproject_path, - junction_path, - store_ref=False, + str(tmpdir.join("junction_repo")), subproject_path, junction_path, store_ref=False, ) # Track the junction itself first. result = cli.run(project=project, args=["source", "track", "junction.bst"]) result.assert_success() - assert ( - cli.get_element_state(project, "junction.bst:import-etc-repo.bst") - == "no reference" - ) + assert cli.get_element_state(project, "junction.bst:import-etc-repo.bst") == "no reference" # Track the cross junction element. -J is not given, it is implied. - result = cli.run( - project=project, args=["source", "track", "junction.bst:import-etc-repo.bst"] - ) + result = cli.run(project=project, args=["source", "track", "junction.bst:import-etc-repo.bst"]) if ref_storage == "inline": # This is not allowed to track cross junction without project.refs. @@ -259,10 +234,7 @@ def test_cross_junction(cli, tmpdir, datafiles, ref_storage, kind): else: result.assert_success() - assert ( - cli.get_element_state(project, "junction.bst:import-etc-repo.bst") - == "buildable" - ) + assert cli.get_element_state(project, "junction.bst:import-etc-repo.bst") == "buildable" assert os.path.exists(os.path.join(project, "project.refs")) @@ -354,10 +326,7 @@ def test_track_include_junction(cli, tmpdir, datafiles, ref_storage, kind): _yaml.roundtrip_dump(sources, os.path.join(sub_element_path, "sources.yml")) generate_junction( - str(tmpdir.join("junction_repo")), - subproject_path, - junction_path, - store_ref=True, + str(tmpdir.join("junction_repo")), subproject_path, junction_path, store_ref=True, ) result = cli.run(project=project, args=["source", "track", "junction.bst"]) @@ -374,10 +343,7 @@ def test_track_include_junction(cli, tmpdir, datafiles, ref_storage, kind): # FIXME: We should expect an error. But only a warning is emitted # result.assert_main_error(ErrorDomain.SOURCE, 'tracking-junction-fragment') - assert ( - "junction.bst:elements/sources.yml: Cannot track source in a fragment from a junction" - in result.stderr - ) + assert "junction.bst:elements/sources.yml: Cannot track source in a fragment from a junction" in result.stderr else: assert os.path.exists(os.path.join(project, "project.refs")) @@ -401,15 +367,10 @@ def test_track_junction_included(cli, tmpdir, datafiles, ref_storage, kind): subproject_path = os.path.join(project, "files", "sub-project") junction_path = os.path.join(element_path, "junction.bst") - update_project_configuration( - project, {"ref-storage": ref_storage, "(@)": ["junction.bst:test.yml"]} - ) + update_project_configuration(project, {"ref-storage": ref_storage, "(@)": ["junction.bst:test.yml"]}) generate_junction( - str(tmpdir.join("junction_repo")), - subproject_path, - junction_path, - store_ref=False, + str(tmpdir.join("junction_repo")), subproject_path, junction_path, store_ref=False, ) result = cli.run(project=project, args=["source", "track", "junction.bst"]) diff --git a/src/buildstream/testing/_sourcetests/track_cross_junction.py b/src/buildstream/testing/_sourcetests/track_cross_junction.py index 470b67e8d..e69e25be9 100644 --- a/src/buildstream/testing/_sourcetests/track_cross_junction.py +++ b/src/buildstream/testing/_sourcetests/track_cross_junction.py @@ -115,15 +115,11 @@ def test_cross_junction_multiple_projects(cli, tmpdir, kind): # Create junctions for projects a and b in main. junction_a = "{}.bst".format(project_a) junction_a_path = os.path.join(project, "elements", junction_a) - generate_junction( - tmpdir.join("repo_a"), project_a_path, junction_a_path, store_ref=False - ) + generate_junction(tmpdir.join("repo_a"), project_a_path, junction_a_path, store_ref=False) junction_b = "{}.bst".format(project_b) junction_b_path = os.path.join(project, "elements", junction_b) - generate_junction( - tmpdir.join("repo_b"), project_b_path, junction_b_path, store_ref=False - ) + generate_junction(tmpdir.join("repo_b"), project_b_path, junction_b_path, store_ref=False) # Track the junctions. result = cli.run(project=project, args=["source", "track", junction_a, junction_b]) @@ -138,15 +134,7 @@ def test_cross_junction_multiple_projects(cli, tmpdir, kind): # Track without following junctions. But explicitly also track the elements in project a. result = cli.run( - project=project, - args=[ - "source", - "track", - "--deps", - "all", - all_bst, - "{}:{}".format(junction_a, stack_a), - ], + project=project, args=["source", "track", "--deps", "all", all_bst, "{}:{}".format(junction_a, stack_a),], ) result.assert_success() @@ -169,9 +157,7 @@ def test_track_exceptions(cli, tmpdir, kind): junction_a = "{}.bst".format(project_a) junction_a_path = os.path.join(project, "elements", junction_a) - generate_junction( - tmpdir.join("repo_a"), project_a_path, junction_a_path, store_ref=False - ) + generate_junction(tmpdir.join("repo_a"), project_a_path, junction_a_path, store_ref=False) result = cli.run(project=project, args=["source", "track", junction_a]) result.assert_success() diff --git a/src/buildstream/testing/_sourcetests/utils.py b/src/buildstream/testing/_sourcetests/utils.py index ca245a57d..1ceefa3ce 100644 --- a/src/buildstream/testing/_sourcetests/utils.py +++ b/src/buildstream/testing/_sourcetests/utils.py @@ -28,10 +28,7 @@ try: import pytest except ImportError: module_name = globals()["__name__"] - msg = ( - "Could not import pytest:\n" - "To use the {} module, you must have pytest installed.".format(module_name) - ) + msg = "Could not import pytest:\n" "To use the {} module, you must have pytest installed.".format(module_name) raise ImportError(msg) from buildstream import _yaml @@ -77,11 +74,7 @@ def add_plugins_conf(project, plugin_kind): if plugin_package is not None: project_conf["plugins"] = [ - { - "origin": "pip", - "package-name": plugin_package, - "sources": {plugin_kind: 0,}, - }, + {"origin": "pip", "package-name": plugin_package, "sources": {plugin_kind: 0,},}, ] _yaml.roundtrip_dump(project_conf, project_conf_file) diff --git a/src/buildstream/testing/_sourcetests/workspace.py b/src/buildstream/testing/_sourcetests/workspace.py index 7cc308006..149723069 100644 --- a/src/buildstream/testing/_sourcetests/workspace.py +++ b/src/buildstream/testing/_sourcetests/workspace.py @@ -49,9 +49,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, element_attrs=None - ): + def create_workspace_element(self, kind, track, suffix="", workspace_dir=None, element_attrs=None): element_name = "workspace-test-{}{}.bst".format(kind, suffix) element_path = os.path.join(self.project_path, "elements") if not workspace_dir: @@ -73,9 +71,7 @@ class WorkspaceCreator: _yaml.roundtrip_dump(element, 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, element_attrs=None - ): + def create_workspace_elements(self, kinds, track, suffixs=None, workspace_dir_usr=None, element_attrs=None): element_tuples = [] @@ -92,9 +88,7 @@ class WorkspaceCreator: element_tuples.append((element_name, workspace_dir)) # Assert that there is no reference, a track & fetch is needed - states = self.cli.get_element_states( - self.project_path, [e for e, _ in element_tuples] - ) + 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: @@ -103,18 +97,10 @@ class WorkspaceCreator: return element_tuples def open_workspaces( - self, - kinds, - track, - suffixs=None, - workspace_dir=None, - element_attrs=None, - no_checkout=False, + self, kinds, track, suffixs=None, workspace_dir=None, element_attrs=None, no_checkout=False, ): - element_tuples = self.create_workspace_elements( - kinds, track, suffixs, workspace_dir, element_attrs - ) + element_tuples = self.create_workspace_elements(kinds, track, suffixs, workspace_dir, element_attrs) os.makedirs(self.workspace_cmd, exist_ok=True) # Now open the workspace, this should have the effect of automatically @@ -129,20 +115,14 @@ class WorkspaceCreator: _, workspace_dir = element_tuples[0] args.extend(["--directory", workspace_dir]) - args.extend( - [element_name for element_name, workspace_dir_suffix in element_tuples] - ) - result = self.cli.run( - cwd=self.workspace_cmd, project=self.project_path, args=args - ) + args.extend([element_name for element_name, workspace_dir_suffix in element_tuples]) + result = self.cli.run(cwd=self.workspace_cmd, project=self.project_path, args=args) result.assert_success() if not no_checkout: # Assert that we are now buildable because the source is now cached. - states = self.cli.get_element_states( - self.project_path, [e for e, _ in element_tuples] - ) + states = self.cli.get_element_states(self.project_path, [e for e, _ in element_tuples]) assert not any(states[e] != "buildable" for e, _ in element_tuples) # Check that the executable hello file is found in each workspace @@ -166,9 +146,7 @@ def open_workspace( no_checkout=False, ): workspace_object = WorkspaceCreator(cli, tmpdir, datafiles, project_path) - workspaces = workspace_object.open_workspaces( - (kind,), track, (suffix,), workspace_dir, element_attrs, no_checkout - ) + workspaces = workspace_object.open_workspaces((kind,), track, (suffix,), workspace_dir, element_attrs, no_checkout) assert len(workspaces) == 1 element_name, workspace = workspaces[0] return element_name, workspace_object.project_path, workspace |