mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Add a test for repairing paths
This commit is contained in:
parent
a9d99ab55f
commit
832377bbd6
5 changed files with 56 additions and 8 deletions
|
@ -2,11 +2,9 @@ source common.sh
|
|||
|
||||
clearStore
|
||||
clearManifests
|
||||
clearCache
|
||||
|
||||
# Create the binary cache.
|
||||
cacheDir=$TEST_ROOT/binary-cache
|
||||
rm -rf "$cacheDir"
|
||||
|
||||
outPath=$(nix-build dependencies.nix --no-out-link)
|
||||
|
||||
nix-push --dest $cacheDir $outPath
|
||||
|
|
|
@ -29,6 +29,8 @@ export SHELL="@bash@"
|
|||
export version=@PACKAGE_VERSION@
|
||||
export system=@system@
|
||||
|
||||
cacheDir=$TEST_ROOT/binary-cache
|
||||
|
||||
readLink() {
|
||||
ls -l "$1" | sed 's/.*->\ //'
|
||||
}
|
||||
|
@ -55,6 +57,10 @@ clearManifests() {
|
|||
rm -f $NIX_STATE_DIR/manifests/*
|
||||
}
|
||||
|
||||
clearCache() {
|
||||
rm -rf "$cacheDir"
|
||||
}
|
||||
|
||||
startDaemon() {
|
||||
# Start the daemon, wait for the socket to appear. !!!
|
||||
# ‘nix-daemon’ should have an option to fork into the background.
|
||||
|
|
|
@ -4,13 +4,13 @@ check:
|
|||
nix_tests = \
|
||||
init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
|
||||
parallel.sh build-hook.sh substitutes.sh substitutes2.sh \
|
||||
fallback.sh nix-push.sh gc.sh gc-concurrent.sh verify.sh nix-pull.sh \
|
||||
fallback.sh nix-push.sh gc.sh gc-concurrent.sh nix-pull.sh \
|
||||
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
|
||||
gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \
|
||||
remote-store.sh export.sh export-graph.sh negative-caching.sh \
|
||||
binary-patching.sh timeout.sh secure-drv-outputs.sh nix-channel.sh \
|
||||
multiple-outputs.sh import-derivation.sh fetchurl.sh optimise-store.sh \
|
||||
binary-cache.sh nix-profile.sh
|
||||
binary-cache.sh nix-profile.sh repair.sh
|
||||
|
||||
install-tests += $(foreach x, $(nix_tests), tests/$(x))
|
||||
|
||||
|
|
47
tests/repair.sh
Normal file
47
tests/repair.sh
Normal file
|
@ -0,0 +1,47 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
path=$(nix-build dependencies.nix -o $TEST_ROOT/result)
|
||||
path2=$(nix-store -qR $path | grep input-2)
|
||||
|
||||
nix-store --verify --check-contents -v
|
||||
|
||||
hash=$(nix-hash $path2)
|
||||
|
||||
# Corrupt a path and check whether nix-build --repair can fix it.
|
||||
chmod u+w $path2
|
||||
touch $path2/bad
|
||||
|
||||
if nix-store --verify --check-contents -v; then
|
||||
echo "nix-store --verify succeeded unexpectedly" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if nix-store --verify --check-contents --repair; then
|
||||
echo "nix-store --verify --repair succeeded unexpectedly" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nix-build dependencies.nix -o $TEST_ROOT/result --repair
|
||||
|
||||
if [ "$(nix-hash $path2)" != "$hash" -o -e $path2/bad ]; then
|
||||
echo "path not repaired properly" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Corrupt a path that has a substitute and check whether nix-store
|
||||
# --verify can fix it.
|
||||
clearCache
|
||||
|
||||
nix-push --dest $cacheDir $path
|
||||
|
||||
chmod u+w $path2
|
||||
rm -rf $path2
|
||||
|
||||
nix-store --verify --check-contents --repair --option binary-caches "file://$cacheDir"
|
||||
|
||||
if [ "$(nix-hash $path2)" != "$hash" -o -e $path2/bad ]; then
|
||||
echo "path not repaired properly" >&2
|
||||
exit 1
|
||||
fi
|
|
@ -1,3 +0,0 @@
|
|||
source common.sh
|
||||
|
||||
nix-store --verify
|
Loading…
Reference in a new issue