diff options
-rw-r--r-- | tests/sources/tar.py | 36 | ||||
-rw-r--r-- | tests/sources/tar/contains-links/content/base-directory/subdir1/file.txt | 1 | ||||
-rw-r--r-- | tests/sources/tar/contains-links/target.bst | 6 |
3 files changed, 43 insertions, 0 deletions
diff --git a/tests/sources/tar.py b/tests/sources/tar.py index f3f90d0f2..07d44be9e 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -185,3 +185,39 @@ def test_stage_explicit_basedir(cli, tmpdir, datafiles, srcdir): original_contents = _list_dir_contents(original_dir) checkout_contents = _list_dir_contents(checkoutdir) assert(checkout_contents == original_contents) + + +# Test that we succeed to extract tarballs with hardlinks when stripping the +# leading paths +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'contains-links')) +def test_stage_contains_links(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + generate_project(project, tmpdir) + checkoutdir = os.path.join(str(tmpdir), "checkout") + + # Create a local tar + src_tar = os.path.join(str(tmpdir), "a.tar.gz") + + # 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.link(file1, file2) + + _assemble_tar(os.path.join(str(datafiles), "content"), "base-directory", src_tar) + + # Track, fetch, build, checkout + result = cli.run(project=project, args=['track', 'target.bst']) + assert result.exit_code == 0 + result = cli.run(project=project, args=['fetch', 'target.bst']) + 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=['checkout', 'target.bst', checkoutdir]) + assert result.exit_code == 0 + + # Check that the content of the first directory is checked out (base-dir: '*') + original_dir = os.path.join(str(datafiles), "content", "base-directory") + original_contents = _list_dir_contents(original_dir) + checkout_contents = _list_dir_contents(checkoutdir) + assert(checkout_contents == original_contents) diff --git a/tests/sources/tar/contains-links/content/base-directory/subdir1/file.txt b/tests/sources/tar/contains-links/content/base-directory/subdir1/file.txt new file mode 100644 index 000000000..f62144808 --- /dev/null +++ b/tests/sources/tar/contains-links/content/base-directory/subdir1/file.txt @@ -0,0 +1 @@ +pony diff --git a/tests/sources/tar/contains-links/target.bst b/tests/sources/tar/contains-links/target.bst new file mode 100644 index 000000000..ad413a2f4 --- /dev/null +++ b/tests/sources/tar/contains-links/target.bst @@ -0,0 +1,6 @@ +kind: import +description: The kind of this element is irrelevant. +sources: +- kind: tar + url: tmpdir:/a.tar.gz + ref: foo |