diff options
Diffstat (limited to 'tests/frontend/show.py')
-rw-r--r-- | tests/frontend/show.py | 156 |
1 files changed, 29 insertions, 127 deletions
diff --git a/tests/frontend/show.py b/tests/frontend/show.py index a54d625ea..a686dbd2d 100644 --- a/tests/frontend/show.py +++ b/tests/frontend/show.py @@ -29,24 +29,14 @@ DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)),) ) def test_show(cli, datafiles, target, fmt, expected): project = str(datafiles) - result = cli.run( - project=project, - silent=True, - args=["show", "--deps", "none", "--format", fmt, target], - ) + result = cli.run(project=project, silent=True, args=["show", "--deps", "none", "--format", fmt, target],) result.assert_success() if result.output.strip() != expected: - raise AssertionError( - "Expected output:\n{}\nInstead received output:\n{}".format( - expected, result.output - ) - ) + raise AssertionError("Expected output:\n{}\nInstead received output:\n{}".format(expected, result.output)) -@pytest.mark.datafiles( - os.path.join(os.path.dirname(os.path.realpath(__file__)), "invalid_element_path",) -) +@pytest.mark.datafiles(os.path.join(os.path.dirname(os.path.realpath(__file__)), "invalid_element_path",)) def test_show_invalid_element_path(cli, datafiles): project = str(datafiles) cli.run(project=project, silent=True, args=["show", "foo.bst"]) @@ -77,16 +67,8 @@ def test_show_fail(cli, datafiles): @pytest.mark.parametrize( "target,except_,expected", [ - ( - "target.bst", - "import-bin.bst", - ["import-dev.bst", "compose-all.bst", "target.bst"], - ), - ( - "target.bst", - "import-dev.bst", - ["import-bin.bst", "compose-all.bst", "target.bst"], - ), + ("target.bst", "import-bin.bst", ["import-dev.bst", "compose-all.bst", "target.bst"],), + ("target.bst", "import-dev.bst", ["import-bin.bst", "compose-all.bst", "target.bst"],), ("target.bst", "compose-all.bst", ["import-bin.bst", "target.bst"]), ("compose-all.bst", "import-bin.bst", ["import-dev.bst", "compose-all.bst"]), ], @@ -96,27 +78,14 @@ def test_show_except_simple(cli, datafiles, target, except_, expected): result = cli.run( project=project, silent=True, - args=[ - "show", - "--deps", - "all", - "--format", - "%{name}", - "--except", - except_, - target, - ], + args=["show", "--deps", "all", "--format", "%{name}", "--except", except_, target,], ) result.assert_success() results = result.output.strip().splitlines() if results != expected: - raise AssertionError( - "Expected elements:\n{}\nInstead received elements:\n{}".format( - expected, results - ) - ) + raise AssertionError("Expected elements:\n{}\nInstead received elements:\n{}".format(expected, results)) # This test checks various constructions of a pipeline @@ -200,22 +169,14 @@ def test_show_except_simple(cli, datafiles, target, except_, expected): ], ), # Test one target and excepting two elements - ( - ["build.bst"], - ["unrelated-1.bst", "unrelated-2.bst"], - ["first-level-1.bst", "build.bst",], - ), + (["build.bst"], ["unrelated-1.bst", "unrelated-2.bst"], ["first-level-1.bst", "build.bst",],), ], ) def test_show_except(cli, datafiles, targets, exceptions, expected): basedir = str(datafiles) results = cli.get_pipeline(basedir, targets, except_=exceptions, scope="all") if results != expected: - raise AssertionError( - "Expected elements:\n{}\nInstead received elements:\n{}".format( - expected, results - ) - ) + raise AssertionError("Expected elements:\n{}\nInstead received elements:\n{}".format(expected, results)) ############################################################### @@ -271,13 +232,9 @@ def test_target_is_dependency(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "project")) @pytest.mark.parametrize("ref_storage", [("inline"), ("project.refs")]) -@pytest.mark.parametrize( - "element_name", ["junction-dep.bst", "junction.bst:import-etc.bst"] -) +@pytest.mark.parametrize("element_name", ["junction-dep.bst", "junction.bst:import-etc.bst"]) @pytest.mark.parametrize("workspaced", [True, False], ids=["workspace", "no-workspace"]) -def test_unfetched_junction( - cli, tmpdir, datafiles, ref_storage, element_name, workspaced -): +def test_unfetched_junction(cli, tmpdir, datafiles, ref_storage, element_name, workspaced): project = str(datafiles) subproject_path = os.path.join(project, "files", "sub-project") junction_path = os.path.join(project, "elements", "junction.bst") @@ -286,9 +243,7 @@ def test_unfetched_junction( configure_project(project, {"ref-storage": ref_storage}) # Create a repo to hold the subproject and generate a junction element for it - ref = generate_junction( - tmpdir, subproject_path, junction_path, store_ref=(ref_storage == "inline") - ) + ref = generate_junction(tmpdir, subproject_path, junction_path, store_ref=(ref_storage == "inline")) # Create a stack element to depend on a cross junction element # @@ -309,14 +264,7 @@ def test_unfetched_junction( result = cli.run( project=project, silent=True, - args=[ - "workspace", - "open", - "--no-checkout", - "--directory", - subproject_path, - "junction.bst", - ], + args=["workspace", "open", "--no-checkout", "--directory", subproject_path, "junction.bst",], ) result.assert_success() @@ -352,26 +300,15 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage, workspaced): result = cli.run( project=project, silent=True, - args=[ - "workspace", - "open", - "--no-checkout", - "--directory", - subproject_path, - "junction.bst", - ], + args=["workspace", "open", "--no-checkout", "--directory", subproject_path, "junction.bst",], ) result.assert_success() # Assert the correct error when trying to show the pipeline - dep_result = cli.run( - project=project, silent=True, args=["show", "junction-dep.bst"] - ) + dep_result = cli.run(project=project, silent=True, args=["show", "junction-dep.bst"]) # Assert the correct error when trying to show the pipeline - etc_result = cli.run( - project=project, silent=True, args=["show", "junction.bst:import-etc.bst"] - ) + etc_result = cli.run(project=project, silent=True, args=["show", "junction.bst:import-etc.bst"]) # If a workspace is open, no ref is needed if workspaced: @@ -384,18 +321,12 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage, workspaced): provenance = ref_node.get_provenance() assert str(provenance) in dep_result.stderr - dep_result.assert_main_error( - ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT - ) - etc_result.assert_main_error( - ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT - ) + dep_result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT) + etc_result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT) @pytest.mark.datafiles(os.path.join(DATA_DIR, "project")) -@pytest.mark.parametrize( - "element_name", ["junction-dep.bst", "junction.bst:import-etc.bst"] -) +@pytest.mark.parametrize("element_name", ["junction-dep.bst", "junction.bst:import-etc.bst"]) @pytest.mark.parametrize("workspaced", [True, False], ids=["workspace", "no-workspace"]) def test_fetched_junction(cli, tmpdir, datafiles, element_name, workspaced): project = str(datafiles) @@ -415,9 +346,7 @@ def test_fetched_junction(cli, tmpdir, datafiles, element_name, workspaced): } _yaml.roundtrip_dump(element, element_path) - result = cli.run( - project=project, silent=True, args=["source", "fetch", "junction.bst"] - ) + result = cli.run(project=project, silent=True, args=["source", "fetch", "junction.bst"]) result.assert_success() # Open a workspace if we're testing workspaced behavior @@ -425,23 +354,12 @@ def test_fetched_junction(cli, tmpdir, datafiles, element_name, workspaced): result = cli.run( project=project, silent=True, - args=[ - "workspace", - "open", - "--no-checkout", - "--directory", - subproject_path, - "junction.bst", - ], + args=["workspace", "open", "--no-checkout", "--directory", subproject_path, "junction.bst",], ) result.assert_success() # Assert the correct error when trying to show the pipeline - result = cli.run( - project=project, - silent=True, - args=["show", "--format", "%{name}-%{state}", element_name], - ) + result = cli.run(project=project, silent=True, args=["show", "--format", "%{name}-%{state}", element_name],) results = result.output.strip().splitlines() assert "junction.bst:import-etc.bst-buildable" in results @@ -464,9 +382,7 @@ def test_exceed_max_recursion_depth(cli, tmpdir, dependency_depth): """ os.mkdir(project_path) - result = cli.run( - silent=True, args=["init", "--project-name", project_name, project_path] - ) + result = cli.run(silent=True, args=["init", "--project-name", project_name, project_path]) result.assert_success() sourcefiles_path = os.path.join(project_path, "files") @@ -481,20 +397,14 @@ def test_exceed_max_recursion_depth(cli, tmpdir, dependency_depth): } if i == 0: del element["depends"] - _yaml.roundtrip_dump( - element, os.path.join(element_path, "element{}.bst".format(str(i))) - ) + _yaml.roundtrip_dump(element, os.path.join(element_path, "element{}.bst".format(str(i)))) source = os.path.join(sourcefiles_path, "source{}".format(str(i))) open(source, "x").close() assert os.path.exists(source) setup_test() - result = cli.run( - project=project_path, - silent=True, - args=["show", "element{}.bst".format(str(dependency_depth))], - ) + result = cli.run(project=project_path, silent=True, args=["show", "element{}.bst".format(str(dependency_depth))],) recursion_limit = sys.getrecursionlimit() if dependency_depth <= recursion_limit: @@ -523,19 +433,13 @@ def test_format_deps(cli, datafiles, dep_kind, expected_deps): project = str(datafiles) target = "checkout-deps.bst" result = cli.run( - project=project, - silent=True, - args=["show", "--deps", "none", "--format", "%{name}: " + dep_kind, target], + project=project, silent=True, args=["show", "--deps", "none", "--format", "%{name}: " + dep_kind, target], ) result.assert_success() expected = "{name}: {deps}".format(name=target, deps=expected_deps) if result.output.strip() != expected: - raise AssertionError( - "Expected output:\n{}\nInstead received output:\n{}".format( - expected, result.output - ) - ) + raise AssertionError("Expected output:\n{}\nInstead received output:\n{}".format(expected, result.output)) # This tests the resolved value of the 'max-jobs' variable, @@ -544,8 +448,7 @@ def test_format_deps(cli, datafiles, dep_kind, expected_deps): # @pytest.mark.datafiles(os.path.join(DATA_DIR, "project")) @pytest.mark.parametrize( - "cli_value, config_value", - [(None, None), (None, "16"), ("16", None), ("5", "16"), ("0", "16"), ("16", "0"),], + "cli_value, config_value", [(None, None), (None, "16"), ("16", None), ("5", "16"), ("0", "16"), ("16", "0"),], ) def test_max_jobs(cli, datafiles, cli_value, config_value): project = str(datafiles) @@ -599,8 +502,7 @@ def test_max_jobs(cli, datafiles, cli_value, config_value): # @pytest.mark.datafiles(os.path.join(DATA_DIR, "strict-depends")) @pytest.mark.parametrize( - "target, expected_state", - [("non-strict-depends.bst", "cached"), ("strict-depends.bst", "waiting"),], + "target, expected_state", [("non-strict-depends.bst", "cached"), ("strict-depends.bst", "waiting"),], ) def test_strict_dependencies(cli, datafiles, target, expected_state): project = str(datafiles) |