diff options
Diffstat (limited to 'tests/frontend/buildcheckout.py')
-rw-r--r-- | tests/frontend/buildcheckout.py | 144 |
1 files changed, 26 insertions, 118 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index f3080269d..7772c48ef 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -33,12 +33,7 @@ def strict_args(args, strict): @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize( "strict,hardlinks", - [ - ("strict", "copies"), - ("strict", "hardlinks"), - ("non-strict", "copies"), - ("non-strict", "hardlinks"), - ], + [("strict", "copies"), ("strict", "hardlinks"), ("non-strict", "copies"), ("non-strict", "hardlinks"),], ) def test_build_checkout(datafiles, cli, strict, hardlinks): project = str(datafiles) @@ -115,9 +110,7 @@ def test_build_invalid_suffix_dep(datafiles, cli, strict, hardlinks): project = str(datafiles) # target2.bst depends on an element called target.foo - result = cli.run( - project=project, args=strict_args(["build", "target2.bst"], strict) - ) + result = cli.run(project=project, args=strict_args(["build", "target2.bst"], strict)) result.assert_main_error(ErrorDomain.LOAD, "bad-element-suffix") @@ -134,9 +127,7 @@ def test_build_invalid_filename_chars(datafiles, cli): } _yaml.roundtrip_dump(element, os.path.join(project, "elements", element_name)) - result = cli.run( - project=project, args=strict_args(["build", element_name], "non-strict") - ) + result = cli.run(project=project, args=strict_args(["build", element_name], "non-strict")) result.assert_main_error(ErrorDomain.LOAD, "bad-characters-in-name") @@ -154,10 +145,7 @@ def test_build_invalid_filename_chars_dep(datafiles, cli): } _yaml.roundtrip_dump(element, os.path.join(project, "elements", element_name)) - result = cli.run( - project=project, - args=strict_args(["build", "invalid-chars-in-dep.bst"], "non-strict"), - ) + result = cli.run(project=project, args=strict_args(["build", "invalid-chars-in-dep.bst"], "non-strict"),) result.assert_main_error(ErrorDomain.LOAD, "bad-characters-in-name") @@ -179,16 +167,7 @@ def test_build_checkout_deps(datafiles, cli, deps): # Now check it out result = cli.run( - project=project, - args=[ - "artifact", - "checkout", - element_name, - "--deps", - deps, - "--directory", - checkout, - ], + project=project, args=["artifact", "checkout", element_name, "--deps", deps, "--directory", checkout,], ) result.assert_success() @@ -220,10 +199,7 @@ def test_build_checkout_unbuilt(datafiles, cli): checkout = os.path.join(cli.directory, "checkout") # Check that checking out an unbuilt element fails nicely - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkout], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkout],) result.assert_main_error(ErrorDomain.STREAM, "uncached-checkout-attempt") @@ -246,10 +222,7 @@ def test_build_checkout_compression_no_tar(datafiles, cli): ] result = cli.run(project=project, args=checkout_args) - assert ( - "ERROR: --compression can only be provided if --tar is provided" - in result.stderr - ) + assert "ERROR: --compression can only be provided if --tar is provided" in result.stderr assert result.exit_code != 0 @@ -466,10 +439,7 @@ def test_build_checkout_invalid_ref(datafiles, cli): ] result = cli.run(project=project, args=checkout_args) - assert ( - "Error while staging dependencies into a sandbox: 'No artifacts to stage'" - in result.stderr - ) + assert "Error while staging dependencies into a sandbox: 'No artifacts to stage'" in result.stderr @pytest.mark.datafiles(DATA_DIR) @@ -613,9 +583,7 @@ def test_build_checkout_tarball_links(datafiles, cli): # of the symlink and the test therefore doesn't have the correct content os.symlink( os.path.join("..", "basicfile"), - os.path.join( - project, "files", "files-and-links", "basicfolder", "basicsymlink" - ), + os.path.join(project, "files", "files-and-links", "basicfolder", "basicsymlink"), ) result = cli.run(project=project, args=["build", "import-links.bst"]) @@ -632,10 +600,7 @@ def test_build_checkout_tarball_links(datafiles, cli): tar = tarfile.open(name=checkout, mode="r:") tar.extractall(extract) - assert ( - open(os.path.join(extract, "basicfolder", "basicsymlink")).read() - == "file contents\n" - ) + assert open(os.path.join(extract, "basicfolder", "basicsymlink")).read() == "file contents\n" @pytest.mark.datafiles(DATA_DIR) @@ -648,9 +613,7 @@ def test_build_checkout_links(datafiles, cli): # of the symlink and the test therefore doesn't have the correct content os.symlink( os.path.join("..", "basicfile"), - os.path.join( - project, "files", "files-and-links", "basicfolder", "basicsymlink" - ), + os.path.join(project, "files", "files-and-links", "basicfolder", "basicsymlink"), ) result = cli.run(project=project, args=["build", "import-links.bst"]) @@ -671,10 +634,7 @@ def test_build_checkout_links(datafiles, cli): result = cli.run(project=project, args=checkout_args) result.assert_success() - assert ( - open(os.path.join(checkout, "basicfolder", "basicsymlink")).read() - == "file contents\n" - ) + assert open(os.path.join(checkout, "basicfolder", "basicsymlink")).read() == "file contents\n" @pytest.mark.datafiles(DATA_DIR) @@ -836,9 +796,7 @@ def test_unfetched_junction(cli, tmpdir, datafiles, ref_storage): 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 # @@ -891,10 +849,7 @@ def test_build_checkout_junction(cli, tmpdir, datafiles): assert cli.get_element_state(project, "junction-dep.bst") == "cached" # Now check it out - result = cli.run( - project=project, - args=["artifact", "checkout", "junction-dep.bst", "--directory", checkout], - ) + result = cli.run(project=project, args=["artifact", "checkout", "junction-dep.bst", "--directory", checkout],) result.assert_success() # Assert the content of /etc/animal.conf @@ -934,10 +889,7 @@ def test_build_checkout_junction_default_targets(cli, tmpdir, datafiles): assert cli.get_element_state(project, "junction-dep.bst") == "cached" # Now check it out - result = cli.run( - project=project, - args=["artifact", "checkout", "junction-dep.bst", "--directory", checkout], - ) + result = cli.run(project=project, args=["artifact", "checkout", "junction-dep.bst", "--directory", checkout],) result.assert_success() # Assert the content of /etc/animal.conf @@ -970,10 +922,7 @@ def test_build_checkout_workspaced_junction(cli, tmpdir, datafiles): # Now open a workspace on the junction # - result = cli.run( - project=project, - args=["workspace", "open", "--directory", workspace, "junction.bst"], - ) + result = cli.run(project=project, args=["workspace", "open", "--directory", workspace, "junction.bst"],) result.assert_success() filename = os.path.join(workspace, "files", "etc-files", "etc", "animal.conf") @@ -996,10 +945,7 @@ def test_build_checkout_workspaced_junction(cli, tmpdir, datafiles): assert cli.get_element_state(project, "junction-dep.bst") == "cached" # Now check it out - result = cli.run( - project=project, - args=["artifact", "checkout", "junction-dep.bst", "--directory", checkout], - ) + result = cli.run(project=project, args=["artifact", "checkout", "junction-dep.bst", "--directory", checkout],) result.assert_success() # Assert the workspace modified content of /etc/animal.conf @@ -1023,14 +969,7 @@ def test_build_checkout_cross_junction(datafiles, cli, tmpdir): result.assert_success() result = cli.run( - project=project, - args=[ - "artifact", - "checkout", - "junction.bst:import-etc.bst", - "--directory", - checkout, - ], + project=project, args=["artifact", "checkout", "junction.bst:import-etc.bst", "--directory", checkout,], ) result.assert_success() @@ -1063,10 +1002,7 @@ def test_build_junction_short_notation(cli, tmpdir, datafiles): assert cli.get_element_state(project, "junction-dep.bst") == "cached" # Now check it out - result = cli.run( - project=project, - args=["artifact", "checkout", "junction-dep.bst", "--directory", checkout], - ) + result = cli.run(project=project, args=["artifact", "checkout", "junction-dep.bst", "--directory", checkout],) result.assert_success() # Assert the content of /etc/animal.conf @@ -1105,10 +1041,7 @@ def test_build_junction_short_notation_filename(cli, tmpdir, datafiles): assert cli.get_element_state(project, "junction-dep.bst") == "cached" # Now check it out - result = cli.run( - project=project, - args=["artifact", "checkout", "junction-dep.bst", "--directory", checkout], - ) + result = cli.run(project=project, args=["artifact", "checkout", "junction-dep.bst", "--directory", checkout],) result.assert_success() # Assert the content of /etc/animal.conf @@ -1133,9 +1066,7 @@ def test_build_junction_short_notation_with_junction(cli, tmpdir, datafiles): # colon (:) as the separator element = { "kind": "stack", - "depends": [ - {"filename": "junction.bst:import-etc.bst", "junction": "junction.bst",} - ], + "depends": [{"filename": "junction.bst:import-etc.bst", "junction": "junction.bst",}], } _yaml.roundtrip_dump(element, element_path) @@ -1202,30 +1133,17 @@ def test_partial_artifact_checkout_fetch(cli, datafiles, tmpdir): # A push artifact cache means we have to pull to push to them, so # delete some blobs from that CAS such that we have to fetch - digest = utils.sha256sum( - os.path.join(project, "files", "bin-files", "usr", "bin", "hello") - ) + digest = utils.sha256sum(os.path.join(project, "files", "bin-files", "usr", "bin", "hello")) objpath = os.path.join(cli.directory, "cas", "objects", digest[:2], digest[2:]) os.unlink(objpath) # Verify that the build-only dependency is not (complete) in the local cache - result = cli.run( - project=project, - args=["artifact", "checkout", input_name, "--directory", checkout_dir], - ) + result = cli.run(project=project, args=["artifact", "checkout", input_name, "--directory", checkout_dir],) result.assert_main_error(ErrorDomain.STREAM, "uncached-checkout-attempt") # Verify that the pull method fetches relevant artifacts in order to stage result = cli.run( - project=project, - args=[ - "artifact", - "checkout", - "--pull", - input_name, - "--directory", - checkout_dir, - ], + project=project, args=["artifact", "checkout", "--pull", input_name, "--directory", checkout_dir,], ) result.assert_success() @@ -1244,17 +1162,7 @@ def test_partial_checkout_fail(tmpdir, datafiles, cli): cli.configure({"artifacts": {"url": share.repo, "push": True}}) res = cli.run( - project=project, - args=[ - "artifact", - "checkout", - "--pull", - build_elt, - "--directory", - checkout_dir, - ], + project=project, args=["artifact", "checkout", "--pull", build_elt, "--directory", checkout_dir,], ) res.assert_main_error(ErrorDomain.STREAM, "uncached-checkout-attempt") - assert re.findall( - r"Remote \((\S+)\) does not have artifact (\S+) cached", res.stderr - ) + assert re.findall(r"Remote \((\S+)\) does not have artifact (\S+) cached", res.stderr) |