diff --git a/testsuite/tests/install/softlinks/my_index/crate-0.1.0.tgz b/testsuite/tests/install/softlinks/my_index/crate-0.1.0.tgz index 11effa04c..233270e6a 100644 Binary files a/testsuite/tests/install/softlinks/my_index/crate-0.1.0.tgz and b/testsuite/tests/install/softlinks/my_index/crate-0.1.0.tgz differ diff --git a/testsuite/tests/install/softlinks/my_index/index/cr/crate/crate-0.1.0.toml b/testsuite/tests/install/softlinks/my_index/index/cr/crate/crate-0.1.0.toml index dd47659fa..d2c6b2f02 100644 --- a/testsuite/tests/install/softlinks/my_index/index/cr/crate/crate-0.1.0.toml +++ b/testsuite/tests/install/softlinks/my_index/index/cr/crate/crate-0.1.0.toml @@ -8,4 +8,4 @@ executables=['main'] [origin.'case(os)'.'...'] url = "file:../../../crate-0.1.0.tgz" -hashes = ["sha256:73d1455dd4b49ea598faa939557c15046db6c689552db03fd6a49c57d3cbc1b2"] +hashes = ["sha256:f3bd6b531710b41c9d62144b5a29fa0b4b78ab553c29957f41d4ca9075f5b0b8"] diff --git a/testsuite/tests/install/softlinks/test.py b/testsuite/tests/install/softlinks/test.py index 43e3bafe5..d927d00e5 100644 --- a/testsuite/tests/install/softlinks/test.py +++ b/testsuite/tests/install/softlinks/test.py @@ -2,21 +2,43 @@ Test that binary files containing softlinks can be installed properly. The test crate contains all kinds of pernicious links (broken, recursive, etc.): -crate +crate/ ├── bin -> subdir/bin ├── broken -> missing +├── lib +│ ├── mock.so -> mock.so.0.0 +│ ├── mock.so.0 -> mock.so.0.0 +│ ├── mock.so.0.0 +│ ├── zzz.so -> mock.so +│ └── zzz.so.0 -> mock.so +├── order +│ ├── ab -> b +│ ├── af -> d/f +│ ├── b +│ ├── cb -> b +│ ├── d +│ │ └── f +│ └── zf -> d/f └── subdir ├── bin │ ├── loop -> ../../subdir │ └── x ├── parent -> .. └── self -> ../subdir + """ +import os +import shutil import sys -from drivers.alr import run_alr -from drivers.helpers import on_windows +from drivers.alr import crate_dirname, run_alr +from drivers.asserts import assert_contents +from drivers.helpers import contents, on_windows + + +def kind(file): + return (os.path.isfile(file), os.path.islink(file), os.path.isdir(file)) # Does not apply to Windows as it does not support softlinks @@ -27,5 +49,32 @@ # This command should succeed normally run_alr("install", "--prefix=install", "crate") +# Contents should be identical. For that, we first untar the crate and then +# directly compare with the destination. + +run_alr("get", "crate") # This merely untars and moves the whole dir in one step, + # so contents are not modified. +cratedir = crate_dirname("crate") +os.chdir(cratedir) +shutil.rmtree("alire") # Created by get +os.remove("alire.toml") # Created by get +items = contents(".") # Contents of the original crate +os.chdir("..") +os.chdir("install") # Contents of the install prefix + +for item in items: + orig = f"../{cratedir}/{item}" + whatis = kind(orig) + if os.path.islink(orig) and os.path.isdir(orig): + continue # We aren't yet able to copy those + if not os.path.exists (orig): + continue # Broken links, we don't copy them at all + assert os.path.exists(item), f"Missing expected entry {item}: {whatis}')" + assert kind(item) == kind(orig), \ + f"Unexpected kind for {item}: {kind(item)} != {kind(orig)}" + +# Cleanup +os.chdir("..") +shutil.rmtree(cratedir) print('SUCCESS')