Skip to content

Commit

Permalink
More detailed test of softlink installation
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Mar 18, 2024
1 parent 1c95a02 commit 7636ae9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
Binary file modified testsuite/tests/install/softlinks/my_index/crate-0.1.0.tgz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ executables=['main']

[origin.'case(os)'.'...']
url = "file:../../../crate-0.1.0.tgz"
hashes = ["sha256:73d1455dd4b49ea598faa939557c15046db6c689552db03fd6a49c57d3cbc1b2"]
hashes = ["sha256:f3bd6b531710b41c9d62144b5a29fa0b4b78ab553c29957f41d4ca9075f5b0b8"]
55 changes: 52 additions & 3 deletions testsuite/tests/install/softlinks/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')

0 comments on commit 7636ae9

Please sign in to comment.