diff options
Diffstat (limited to 'tests/sources')
-rw-r--r-- | tests/sources/bzr.py | 5 | ||||
-rw-r--r-- | tests/sources/deb.py | 19 | ||||
-rw-r--r-- | tests/sources/git.py | 106 | ||||
-rw-r--r-- | tests/sources/local.py | 32 | ||||
-rw-r--r-- | tests/sources/patch.py | 24 | ||||
-rw-r--r-- | tests/sources/previous_source_access.py | 9 | ||||
-rw-r--r-- | tests/sources/previous_source_access/plugins/sources/foo_transform.py | 3 | ||||
-rw-r--r-- | tests/sources/remote.py | 44 | ||||
-rw-r--r-- | tests/sources/tar.py | 77 | ||||
-rw-r--r-- | tests/sources/zip.py | 28 |
10 files changed, 76 insertions, 271 deletions
diff --git a/tests/sources/bzr.py b/tests/sources/bzr.py index 7df4d7471..694b30a7f 100644 --- a/tests/sources/bzr.py +++ b/tests/sources/bzr.py @@ -31,10 +31,7 @@ def test_fetch_checkout(cli, tmpdir, datafiles): assert result.exit_code == 0 result = cli.run(project=project, args=["build", "target.bst"]) assert result.exit_code == 0 - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) assert result.exit_code == 0 # Assert we checked out the file as it was commited diff --git a/tests/sources/deb.py b/tests/sources/deb.py index 5d1fdcceb..656a65052 100644 --- a/tests/sources/deb.py +++ b/tests/sources/deb.py @@ -19,9 +19,7 @@ deb_name = "a_deb.deb" def generate_project(project_dir, tmpdir): project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump( - {"name": "foo", "aliases": {"tmpdir": "file:///" + str(tmpdir)}}, project_file - ) + _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": "file:///" + str(tmpdir)}}, project_file) def _copy_deb(start_location, tmpdir): @@ -102,10 +100,7 @@ def test_stage_default_basedir(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the content of the first directory is checked out (base-dir: '') @@ -133,10 +128,7 @@ def test_stage_no_basedir(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the full content of the tarball is checked out (base-dir: '') @@ -164,10 +156,7 @@ def test_stage_explicit_basedir(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the content of the first directory is checked out (base-dir: '') diff --git a/tests/sources/git.py b/tests/sources/git.py index 6a6f95364..fb8a30e3f 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -84,10 +84,7 @@ def test_submodule_fetch_checkout(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Assert we checked out both files at their expected location @@ -124,10 +121,7 @@ def test_submodule_fetch_source_enable_explicit(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Assert we checked out both files at their expected location @@ -164,10 +158,7 @@ def test_submodule_fetch_source_disable(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Assert we checked out both files at their expected location @@ -204,10 +195,7 @@ def test_submodule_fetch_submodule_does_override(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Assert we checked out both files at their expected location @@ -249,10 +237,7 @@ def test_submodule_fetch_submodule_individual_checkout(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Assert we checked out files at their expected location @@ -281,9 +266,7 @@ def test_submodule_fetch_submodule_individual_checkout_explicit(cli, tmpdir, dat # Add a submodule pointing to the one we created repo.add_submodule("subdir", "file://" + subrepo.repo, checkout=False) - ref = repo.add_submodule( - "othersubdir", "file://" + other_subrepo.repo, checkout=True - ) + ref = repo.add_submodule("othersubdir", "file://" + other_subrepo.repo, checkout=True) # Write out our test target element = { @@ -297,10 +280,7 @@ def test_submodule_fetch_submodule_individual_checkout_explicit(cli, tmpdir, dat result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Assert we checked out files at their expected location @@ -335,10 +315,7 @@ def test_submodule_fetch_project_override(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Assert we checked out both files at their expected location @@ -674,9 +651,7 @@ def test_track_invalid_submodule(cli, tmpdir, datafiles, fail): @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, "template")) @pytest.mark.parametrize("ref_format", ["sha1", "git-describe"]) -@pytest.mark.parametrize( - "tag,extra_commit", [(False, False), (True, False), (True, True)] -) +@pytest.mark.parametrize("tag,extra_commit", [(False, False), (True, False), (True, True)]) def test_track_fetch(cli, tmpdir, datafiles, ref_format, tag, extra_commit): project = str(datafiles) @@ -781,9 +756,7 @@ def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type): result = cli.run(project=project, args=["source", "track", "target.bst"]) result.assert_success() else: - result = cli.run( - project=project, args=["source", "track", "target.bst", "--deps", "all"] - ) + result = cli.run(project=project, args=["source", "track", "target.bst", "--deps", "all"]) result.assert_success() if ref_storage == "inline": @@ -805,31 +778,22 @@ def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type): result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - 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_success() if tag_type == "annotated": options = [] else: options = ["--tags"] - describe = subprocess.check_output( - ["git", "describe", *options], cwd=checkout, universal_newlines=True - ) + describe = subprocess.check_output(["git", "describe", *options], cwd=checkout, universal_newlines=True) assert describe.startswith("tag2-2-") describe_fp = subprocess.check_output( - ["git", "describe", "--first-parent", *options], - cwd=checkout, - universal_newlines=True, + ["git", "describe", "--first-parent", *options], cwd=checkout, universal_newlines=True, ) assert describe_fp.startswith("tag1-2-") - tags = subprocess.check_output( - ["git", "tag"], cwd=checkout, universal_newlines=True - ) + tags = subprocess.check_output(["git", "tag"], cwd=checkout, universal_newlines=True) tags = set(tags.splitlines()) assert tags == set(["tag1", "tag2"]) @@ -901,9 +865,7 @@ def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_ty result = cli.run(project=project, args=["source", "track", "target.bst"]) result.assert_success() else: - result = cli.run( - project=project, args=["source", "track", "target.bst", "--deps", "all"] - ) + result = cli.run(project=project, args=["source", "track", "target.bst", "--deps", "all"]) result.assert_success() if ref_storage == "inline": @@ -926,30 +888,21 @@ def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_ty result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - 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_success() if tag_type == "annotated": options = [] else: options = ["--tags"] - describe = subprocess.check_output( - ["git", "describe", *options], cwd=checkout, universal_newlines=True - ) + describe = subprocess.check_output(["git", "describe", *options], cwd=checkout, universal_newlines=True) assert describe.startswith("tag") - tags = subprocess.check_output( - ["git", "tag"], cwd=checkout, universal_newlines=True - ) + tags = subprocess.check_output(["git", "tag"], cwd=checkout, universal_newlines=True) tags = set(tags.splitlines()) assert tags == set(["tag"]) - rev_list = subprocess.check_output( - ["git", "rev-list", "--all"], cwd=checkout, universal_newlines=True - ) + rev_list = subprocess.check_output(["git", "rev-list", "--all"], cwd=checkout, universal_newlines=True) assert set(rev_list.splitlines()) == set([tagged_ref]) @@ -1013,29 +966,20 @@ def test_git_describe_relevant_history(cli, tmpdir, datafiles): element_path = os.path.join(project, "target.bst") _yaml.roundtrip_dump(element, element_path) - result = cli.run( - project=project, args=["source", "track", "target.bst", "--deps", "all"] - ) + result = cli.run(project=project, args=["source", "track", "target.bst", "--deps", "all"]) result.assert_success() checkout = os.path.join(str(tmpdir), "checkout") result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - 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_success() - describe = subprocess.check_output( - ["git", "describe"], cwd=checkout, universal_newlines=True - ) + describe = subprocess.check_output(["git", "describe"], cwd=checkout, universal_newlines=True) assert describe.startswith("tag1-2-") - rev_list = subprocess.check_output( - ["git", "rev-list", "--all"], cwd=checkout, universal_newlines=True - ) + rev_list = subprocess.check_output(["git", "rev-list", "--all"], cwd=checkout, universal_newlines=True) assert set(rev_list.splitlines()) == set([head, tagged_ref, branch_boundary]) @@ -1102,9 +1046,7 @@ def test_overwrite_rogue_tag_multiple_remotes(cli, tmpdir, datafiles): repodir, reponame = os.path.split(repo.repo) project_config = _yaml.load(os.path.join(project, "project.conf")) project_config["aliases"] = Node.from_dict({"repo": "http://example.com/"}) - project_config["mirrors"] = [ - {"name": "middle-earth", "aliases": {"repo": ["file://{}/".format(repodir)]}} - ] + project_config["mirrors"] = [{"name": "middle-earth", "aliases": {"repo": ["file://{}/".format(repodir)]}}] _yaml.roundtrip_dump(project_config, os.path.join(project, "project.conf")) repo.add_annotated_tag("tag", "tag") diff --git a/tests/sources/local.py b/tests/sources/local.py index 08c508bfe..da68f1f75 100644 --- a/tests/sources/local.py +++ b/tests/sources/local.py @@ -37,9 +37,7 @@ def test_non_regular_file_or_directory(cli, datafiles): elif os.path.isfile(localfile) and not os.path.islink(localfile): result.assert_success() else: - result.assert_main_error( - ErrorDomain.LOAD, LoadErrorReason.PROJ_PATH_INVALID_KIND - ) + result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.PROJ_PATH_INVALID_KIND) @pytest.mark.datafiles(os.path.join(DATA_DIR, "basic")) @@ -75,10 +73,7 @@ def test_stage_file(cli, tmpdir, datafiles): # Build, checkout result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the checkout contains the expected file @@ -93,10 +88,7 @@ def test_stage_directory(cli, tmpdir, datafiles): # Build, checkout result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the checkout contains the expected file and directory and other file @@ -121,10 +113,7 @@ def test_stage_symlink(cli, tmpdir, datafiles): # Build, checkout result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the checkout contains the expected file and directory and other file @@ -154,25 +143,18 @@ def test_stage_directory_symlink(cli, tmpdir, datafiles): # Build, checkout result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the checkout contains the expected directory and directory symlink assert os.path.exists(os.path.join(checkoutdir, "subdir", "anotherfile.txt")) - assert os.path.exists( - os.path.join(checkoutdir, "symlink-to-subdir", "anotherfile.txt") - ) + assert os.path.exists(os.path.join(checkoutdir, "symlink-to-subdir", "anotherfile.txt")) assert os.path.islink(os.path.join(checkoutdir, "symlink-to-subdir")) @pytest.mark.integration @pytest.mark.datafiles(os.path.join(DATA_DIR, "deterministic-umask")) -@pytest.mark.skipif( - not HAVE_SANDBOX, reason="Only available with a functioning sandbox" -) +@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox") def test_deterministic_source_umask(cli, tmpdir, datafiles): def create_test_file(*path, mode=0o644, content="content\n"): path = os.path.join(*path) diff --git a/tests/sources/patch.py b/tests/sources/patch.py index da93684db..64d082797 100644 --- a/tests/sources/patch.py +++ b/tests/sources/patch.py @@ -33,9 +33,7 @@ def test_non_regular_file_patch(cli, datafiles): if os.path.isfile(patch_path) and not os.path.islink(patch_path): result.assert_success() else: - result.assert_main_error( - ErrorDomain.LOAD, LoadErrorReason.PROJ_PATH_INVALID_KIND - ) + result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.PROJ_PATH_INVALID_KIND) @pytest.mark.datafiles(os.path.join(DATA_DIR, "basic")) @@ -70,10 +68,7 @@ def test_stage_and_patch(cli, tmpdir, datafiles): # Build, checkout result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Test the file.txt was patched and changed @@ -109,10 +104,7 @@ def test_stage_separate_patch_dir(cli, tmpdir, datafiles): # Track, fetch, build, checkout result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Test the file.txt was patched and changed @@ -128,10 +120,7 @@ def test_stage_multiple_patches(cli, tmpdir, datafiles): # Track, fetch, build, checkout result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Test the file.txt was patched and changed @@ -147,10 +136,7 @@ def test_patch_strip_level(cli, tmpdir, datafiles): # Track, fetch, build, checkout result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Test the file.txt was patched and changed diff --git a/tests/sources/previous_source_access.py b/tests/sources/previous_source_access.py index 3ff91b5fd..c42a9a6fb 100644 --- a/tests/sources/previous_source_access.py +++ b/tests/sources/previous_source_access.py @@ -7,9 +7,7 @@ import pytest from buildstream import _yaml from buildstream.testing import cli # pylint: disable=unused-import -DATA_DIR = os.path.join( - os.path.dirname(os.path.realpath(__file__)), "previous_source_access" -) +DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "previous_source_access") ################################################################## @@ -38,10 +36,7 @@ def test_custom_transform_source(cli, datafiles): # Ensure we get correct output from foo_transform cli.run(project=project, args=["build", "target.bst"]) destpath = os.path.join(cli.directory, "checkout") - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", destpath], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", destpath],) result.assert_success() # Assert that files from both sources exist, and that they have # the same content diff --git a/tests/sources/previous_source_access/plugins/sources/foo_transform.py b/tests/sources/previous_source_access/plugins/sources/foo_transform.py index d59eaeca7..9e6ef3ad4 100644 --- a/tests/sources/previous_source_access/plugins/sources/foo_transform.py +++ b/tests/sources/previous_source_access/plugins/sources/foo_transform.py @@ -80,8 +80,7 @@ class FooTransformSource(Source): def stage(self, directory): # Simply stage the "filetransform" file utils.safe_copy( - os.path.join(self.mirror, "filetransform"), - os.path.join(directory, "filetransform"), + os.path.join(self.mirror, "filetransform"), os.path.join(directory, "filetransform"), ) diff --git a/tests/sources/remote.py b/tests/sources/remote.py index 685f6bfba..a02601215 100644 --- a/tests/sources/remote.py +++ b/tests/sources/remote.py @@ -15,16 +15,12 @@ DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "remote",) def generate_project(project_dir, tmpdir): project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump( - {"name": "foo", "aliases": {"tmpdir": "file:///" + str(tmpdir)}}, project_file - ) + _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": "file:///" + str(tmpdir)}}, project_file) def generate_project_file_server(server, project_dir): project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump( - {"name": "foo", "aliases": {"tmpdir": server.base_url()}}, project_file - ) + _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": server.base_url()}}, project_file) # Test that without ref, consistency is set appropriately. @@ -74,10 +70,7 @@ def test_simple_file_build(cli, tmpdir, datafiles): result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Note that the url of the file in target.bst is actually /dir/file # but this tests confirms we take the basename @@ -104,10 +97,7 @@ def test_simple_file_custom_name_build(cli, tmpdir, datafiles): result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() assert not os.path.exists(os.path.join(checkoutdir, "file")) assert os.path.exists(os.path.join(checkoutdir, "custom-file")) @@ -120,9 +110,7 @@ def test_unique_key(cli, tmpdir, datafiles): """ project = str(datafiles) generate_project(project, tmpdir) - states = cli.get_element_states( - project, ["target.bst", "target-custom.bst", "target-custom-executable.bst"] - ) + states = cli.get_element_states(project, ["target.bst", "target-custom.bst", "target-custom-executable.bst"]) assert states["target.bst"] == "fetch needed" assert states["target-custom.bst"] == "fetch needed" assert states["target-custom-executable.bst"] == "fetch needed" @@ -131,9 +119,7 @@ def test_unique_key(cli, tmpdir, datafiles): cli.run(project=project, args=["source", "fetch", "target.bst"]) # We should download the file only once - states = cli.get_element_states( - project, ["target.bst", "target-custom.bst", "target-custom-executable.bst"] - ) + states = cli.get_element_states(project, ["target.bst", "target-custom.bst", "target-custom-executable.bst"]) assert states["target.bst"] == "buildable" assert states["target-custom.bst"] == "buildable" assert states["target-custom-executable.bst"] == "buildable" @@ -153,21 +139,12 @@ def test_executable(cli, tmpdir, datafiles): project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") - assert ( - cli.get_element_state(project, "target-custom-executable.bst") == "fetch needed" - ) + assert cli.get_element_state(project, "target-custom-executable.bst") == "fetch needed" # Try to fetch it cli.run(project=project, args=["build", "target-custom-executable.bst"]) cli.run( - project=project, - args=[ - "artifact", - "checkout", - "target-custom-executable.bst", - "--directory", - checkoutdir, - ], + project=project, args=["artifact", "checkout", "target-custom-executable.bst", "--directory", checkoutdir,], ) mode = os.stat(os.path.join(checkoutdir, "some-custom-file")).st_mode assert mode & stat.S_IEXEC @@ -200,10 +177,7 @@ def test_use_netrc(cli, datafiles, server_type, tmpdir): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() checkout_file = os.path.join(checkoutdir, "file") diff --git a/tests/sources/tar.py b/tests/sources/tar.py index cdd2328fd..ab493f5df 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -42,9 +42,7 @@ def _assemble_tar_lz(workingdir, srcdir, dstfile): def generate_project(project_dir, tmpdir): project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump( - {"name": "foo", "aliases": {"tmpdir": "file:///" + str(tmpdir)}}, project_file - ) + _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": "file:///" + str(tmpdir)}}, project_file) def generate_project_file_server(base_url, project_dir): @@ -124,10 +122,7 @@ def test_stage_default_basedir(cli, tmpdir, datafiles, srcdir): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the content of the first directory is checked out (base-dir: '*') @@ -156,10 +151,7 @@ def test_stage_no_basedir(cli, tmpdir, datafiles, srcdir): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the full content of the tarball is checked out (base-dir: '') @@ -188,10 +180,7 @@ def test_stage_explicit_basedir(cli, tmpdir, datafiles, srcdir): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the content of the first directory is checked out (base-dir: '*') @@ -214,15 +203,10 @@ def test_stage_contains_links(cli, tmpdir, datafiles): # Create a hardlink, we wont trust git to store that info for us os.makedirs( - os.path.join(str(datafiles), "content", "base-directory", "subdir2"), - exist_ok=True, - ) - file1 = os.path.join( - str(datafiles), "content", "base-directory", "subdir1", "file.txt" - ) - file2 = os.path.join( - str(datafiles), "content", "base-directory", "subdir2", "file.txt" + os.path.join(str(datafiles), "content", "base-directory", "subdir2"), exist_ok=True, ) + file1 = os.path.join(str(datafiles), "content", "base-directory", "subdir1", "file.txt") + file2 = os.path.join(str(datafiles), "content", "base-directory", "subdir2", "file.txt") os.link(file1, file2) _assemble_tar(os.path.join(str(datafiles), "content"), "base-directory", src_tar) @@ -234,10 +218,7 @@ def test_stage_contains_links(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the content of the first directory is checked out (base-dir: '*') @@ -266,10 +247,7 @@ def test_stage_default_basedir_lzip(cli, tmpdir, datafiles, srcdir): result.assert_success() result = cli.run(project=project, args=["build", "target-lz.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target-lz.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target-lz.bst", "--directory", checkoutdir],) result.assert_success() # Check that the content of the first directory is checked out (base-dir: '*') @@ -297,12 +275,7 @@ def test_read_only_dir(cli, tmpdir, datafiles, tar_name, base_dir): { "kind": "import", "sources": [ - { - "kind": "tar", - "url": "tmpdir:/{}".format(tar_file), - "ref": "foo", - "base-dir": base_dir, - } + {"kind": "tar", "url": "tmpdir:/{}".format(tar_file), "ref": "foo", "base-dir": base_dir,} ], }, bst_path, @@ -326,13 +299,9 @@ def test_read_only_dir(cli, tmpdir, datafiles, tar_name, base_dir): env = {"TMP": tmpdir_str} # Track, fetch, build, checkout - result = cli.run( - project=project, args=["source", "track", "target.bst"], env=env - ) + result = cli.run(project=project, args=["source", "track", "target.bst"], env=env) result.assert_success() - result = cli.run( - project=project, args=["source", "fetch", "target.bst"], env=env - ) + result = cli.run(project=project, args=["source", "fetch", "target.bst"], env=env) result.assert_success() result = cli.run(project=project, args=["build", "target.bst"], env=env) result.assert_success() @@ -382,10 +351,7 @@ def test_use_netrc(cli, datafiles, server_type, tmpdir): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() original_dir = os.path.join(str(datafiles), "content", "a") @@ -413,9 +379,7 @@ def test_netrc_already_specified_user(cli, datafiles, server_type, tmpdir): with create_file_server(server_type) as server: server.add_user("otheruser", "12345", file_server_files) parts = urllib.parse.urlsplit(server.base_url()) - base_url = urllib.parse.urlunsplit( - [parts[0], "otheruser@{}".format(parts[1]), *parts[2:]] - ) + base_url = urllib.parse.urlunsplit([parts[0], "otheruser@{}".format(parts[1]), *parts[2:]]) generate_project_file_server(base_url, project) src_tar = os.path.join(file_server_files, "a.tar.gz") @@ -440,9 +404,7 @@ def test_homeless_environment(cli, tmpdir, datafiles): _assemble_tar(os.path.join(str(datafiles), "content"), "a", src_tar) # Use a track, make sure the plugin tries to find a ~/.netrc - result = cli.run( - project=project, args=["source", "track", "target.bst"], env={"HOME": None} - ) + result = cli.run(project=project, args=["source", "track", "target.bst"], env={"HOME": None}) result.assert_success() @@ -472,9 +434,7 @@ def test_out_of_basedir_hardlinks(cli, tmpdir, datafiles): # attributes set with tarfile.open(src_tar, "r:gz") as tar: assert any( - member.islnk() - and member.path == "contents/to_extract/a" - and member.linkname == "contents/elsewhere/a" + member.islnk() and member.path == "contents/to_extract/a" and member.linkname == "contents/elsewhere/a" for member in tar.getmembers() ) @@ -485,10 +445,7 @@ def test_out_of_basedir_hardlinks(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() original_dir = os.path.join(str(datafiles), "contents", "to_extract") diff --git a/tests/sources/zip.py b/tests/sources/zip.py index d1b000167..0a5f6eed3 100644 --- a/tests/sources/zip.py +++ b/tests/sources/zip.py @@ -29,16 +29,12 @@ def _assemble_zip(workingdir, dstfile): def generate_project(project_dir, tmpdir): project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump( - {"name": "foo", "aliases": {"tmpdir": "file:///" + str(tmpdir)}}, project_file - ) + _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": "file:///" + str(tmpdir)}}, project_file) def generate_project_file_server(server, project_dir): project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump( - {"name": "foo", "aliases": {"tmpdir": server.base_url()}}, project_file - ) + _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": server.base_url()}}, project_file) # Test that without ref, consistency is set appropriately. @@ -112,10 +108,7 @@ def test_stage_default_basedir(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the content of the first directory is checked out (base-dir: '*') @@ -143,10 +136,7 @@ def test_stage_no_basedir(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the full content of the tarball is checked out (base-dir: '') @@ -174,10 +164,7 @@ def test_stage_explicit_basedir(cli, tmpdir, datafiles): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() # Check that the content of the first directory is checked out (base-dir: '*') @@ -219,10 +206,7 @@ def test_use_netrc(cli, datafiles, server_type, tmpdir): result.assert_success() result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() - result = cli.run( - project=project, - args=["artifact", "checkout", "target.bst", "--directory", checkoutdir], - ) + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir],) result.assert_success() original_dir = os.path.join(str(datafiles), "content", "a") |