mirror of
https://github.com/NixOS/nix
synced 2025-07-07 14:21:48 +02:00
Merge remote-tracking branch 'upstream/master' into support-hardlinks-in-tarballs
This commit is contained in:
commit
86420753ec
583 changed files with 11313 additions and 16547 deletions
|
@ -31,7 +31,7 @@ test "$hash1" = "sha256:$hash2"
|
|||
|
||||
#### New style commands
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
(
|
||||
path1=$(nix store add ./dummy)
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
sed -e "s|@localstatedir@|$TEST_ROOT/profile-var|g" -e "s|@coreutils@|$coreutils|g" < ../../scripts/nix-profile.sh.in > $TEST_ROOT/nix-profile.sh
|
||||
sed -e "s|@localstatedir@|$TEST_ROOT/profile-var|g" -e "s|@coreutils@|$coreutils|g" < ../../scripts/nix-profile.sh.in > "$TEST_ROOT"/nix-profile.sh
|
||||
|
||||
user=$(whoami)
|
||||
rm -rf $TEST_HOME $TEST_ROOT/profile-var
|
||||
mkdir -p $TEST_HOME
|
||||
rm -rf "$TEST_HOME" "$TEST_ROOT/profile-var"
|
||||
mkdir -p "$TEST_HOME"
|
||||
USER=$user $SHELL -e -c ". $TEST_ROOT/nix-profile.sh; set"
|
||||
USER=$user $SHELL -e -c ". $TEST_ROOT/nix-profile.sh" # test idempotency
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
TODO_NixOS
|
||||
|
||||
clearStoreIfPossible
|
||||
clearCacheCache
|
||||
|
||||
# Fails without remote builders
|
||||
|
@ -12,7 +14,7 @@ clearCacheCache
|
|||
outPath=$(nix-build --store "file://$cacheDir" --builders 'auto - - 1 1' -j0 dependencies.nix)
|
||||
|
||||
# Test that the path exactly exists in the destination store.
|
||||
nix path-info --store "file://$cacheDir" $outPath
|
||||
nix path-info --store "file://$cacheDir" "$outPath"
|
||||
|
||||
# Succeeds without any build capability because no-op
|
||||
nix-build --store "file://$cacheDir" -j0 dependencies.nix
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
needLocalStore "'--no-require-sigs' can’t be used with the daemon"
|
||||
|
||||
# We can produce drvs directly into the binary cache
|
||||
|
@ -14,9 +16,9 @@ clearStore
|
|||
clearCache
|
||||
outPath=$(nix-build dependencies.nix --no-out-link)
|
||||
|
||||
nix copy --to file://$cacheDir $outPath
|
||||
nix copy --to "file://$cacheDir" "$outPath"
|
||||
|
||||
readarray -t paths < <(nix path-info --all --json --store file://$cacheDir | jq 'keys|sort|.[]' -r)
|
||||
readarray -t paths < <(nix path-info --all --json --store "file://$cacheDir" | jq 'keys|sort|.[]' -r)
|
||||
[[ "${#paths[@]}" -eq 3 ]]
|
||||
for path in "${paths[@]}"; do
|
||||
[[ "$path" =~ -dependencies-input-0$ ]] \
|
||||
|
@ -25,16 +27,16 @@ for path in "${paths[@]}"; do
|
|||
done
|
||||
|
||||
# Test copying build logs to the binary cache.
|
||||
expect 1 nix log --store file://$cacheDir $outPath 2>&1 | grep 'is not available'
|
||||
nix store copy-log --to file://$cacheDir $outPath
|
||||
nix log --store file://$cacheDir $outPath | grep FOO
|
||||
rm -rf $TEST_ROOT/var/log/nix
|
||||
expect 1 nix log $outPath 2>&1 | grep 'is not available'
|
||||
nix log --substituters file://$cacheDir $outPath | grep FOO
|
||||
expect 1 nix log --store "file://$cacheDir" "$outPath" 2>&1 | grep 'is not available'
|
||||
nix store copy-log --to "file://$cacheDir" "$outPath"
|
||||
nix log --store "file://$cacheDir" "$outPath" | grep FOO
|
||||
rm -rf "$TEST_ROOT/var/log/nix"
|
||||
expect 1 nix log "$outPath" 2>&1 | grep 'is not available'
|
||||
nix log --substituters "file://$cacheDir" "$outPath" | grep FOO
|
||||
|
||||
# Test copying build logs from the binary cache.
|
||||
nix store copy-log --from file://$cacheDir $(nix-store -qd $outPath)^'*'
|
||||
nix log $outPath | grep FOO
|
||||
nix store copy-log --from "file://$cacheDir" "$(nix-store -qd "$outPath")"^'*'
|
||||
nix log "$outPath" | grep FOO
|
||||
|
||||
basicDownloadTests() {
|
||||
# No uploading tests bcause upload with force HTTP doesn't work.
|
||||
|
@ -46,15 +48,15 @@ basicDownloadTests() {
|
|||
|
||||
nix-env --substituters "file://$cacheDir" -f dependencies.nix -qas \* | grep -- "---"
|
||||
|
||||
nix-store --substituters "file://$cacheDir" --no-require-sigs -r $outPath
|
||||
nix-store --substituters "file://$cacheDir" --no-require-sigs -r "$outPath"
|
||||
|
||||
[ -x $outPath/program ]
|
||||
[ -x "$outPath/program" ]
|
||||
|
||||
|
||||
# But with the right configuration, "nix-env -qas" should also work.
|
||||
clearStore
|
||||
clearCacheCache
|
||||
echo "WantMassQuery: 1" >> $cacheDir/nix-cache-info
|
||||
echo "WantMassQuery: 1" >> "$cacheDir/nix-cache-info"
|
||||
|
||||
nix-env --substituters "file://$cacheDir" -f dependencies.nix -qas \* | grep -- "--S"
|
||||
nix-env --substituters "file://$cacheDir" -f dependencies.nix -qas \* | grep -- "--S"
|
||||
|
@ -62,12 +64,12 @@ basicDownloadTests() {
|
|||
x=$(nix-env -f dependencies.nix -qas \* --prebuilt-only)
|
||||
[ -z "$x" ]
|
||||
|
||||
nix-store --substituters "file://$cacheDir" --no-require-sigs -r $outPath
|
||||
nix-store --substituters "file://$cacheDir" --no-require-sigs -r "$outPath"
|
||||
|
||||
nix-store --check-validity $outPath
|
||||
nix-store -qR $outPath | grep input-2
|
||||
nix-store --check-validity "$outPath"
|
||||
nix-store -qR "$outPath" | grep input-2
|
||||
|
||||
echo "WantMassQuery: 0" >> $cacheDir/nix-cache-info
|
||||
echo "WantMassQuery: 0" >> "$cacheDir/nix-cache-info"
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,22 +85,22 @@ basicDownloadTests
|
|||
# Test whether Nix notices if the NAR doesn't match the hash in the NAR info.
|
||||
clearStore
|
||||
|
||||
nar=$(ls $cacheDir/nar/*.nar.xz | head -n1)
|
||||
mv $nar $nar.good
|
||||
mkdir -p $TEST_ROOT/empty
|
||||
nix-store --dump $TEST_ROOT/empty | xz > $nar
|
||||
nar=$(find "$cacheDir/nar/" -type f -name "*.nar.xz" | head -n1)
|
||||
mv "$nar" "$nar".good
|
||||
mkdir -p "$TEST_ROOT/empty"
|
||||
nix-store --dump "$TEST_ROOT/empty" | xz > "$nar"
|
||||
|
||||
expect 1 nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result 2>&1 | tee $TEST_ROOT/log
|
||||
grepQuiet "hash mismatch" $TEST_ROOT/log
|
||||
expect 1 nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o "$TEST_ROOT/result" 2>&1 | tee "$TEST_ROOT/log"
|
||||
grepQuiet "hash mismatch" "$TEST_ROOT/log"
|
||||
|
||||
mv $nar.good $nar
|
||||
mv "$nar".good "$nar"
|
||||
|
||||
|
||||
# Test whether this unsigned cache is rejected if the user requires signed caches.
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
if nix-store --substituters "file://$cacheDir" -r $outPath; then
|
||||
if nix-store --substituters "file://$cacheDir" -r "$outPath"; then
|
||||
echo "unsigned binary cache incorrectly accepted"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -107,131 +109,134 @@ fi
|
|||
# Test whether fallback works if a NAR has disappeared. This does not require --fallback.
|
||||
clearStore
|
||||
|
||||
mv $cacheDir/nar $cacheDir/nar2
|
||||
mv "$cacheDir/nar" "$cacheDir/nar2"
|
||||
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o "$TEST_ROOT/result"
|
||||
|
||||
mv $cacheDir/nar2 $cacheDir/nar
|
||||
mv "$cacheDir/nar2" "$cacheDir/nar"
|
||||
|
||||
|
||||
# Test whether fallback works if a NAR is corrupted. This does require --fallback.
|
||||
clearStore
|
||||
|
||||
mv $cacheDir/nar $cacheDir/nar2
|
||||
mkdir $cacheDir/nar
|
||||
for i in $(cd $cacheDir/nar2 && echo *); do touch $cacheDir/nar/$i; done
|
||||
mv "$cacheDir/nar" "$cacheDir/nar2"
|
||||
mkdir "$cacheDir/nar"
|
||||
for i in $(cd "$cacheDir/nar2" && echo *); do touch "$cacheDir"/nar/"$i"; done
|
||||
|
||||
(! nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result)
|
||||
(! nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o "$TEST_ROOT/result")
|
||||
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result --fallback
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o "$TEST_ROOT/result" --fallback
|
||||
|
||||
rm -rf $cacheDir/nar
|
||||
mv $cacheDir/nar2 $cacheDir/nar
|
||||
rm -rf "$cacheDir/nar"
|
||||
mv "$cacheDir/nar2" "$cacheDir/nar"
|
||||
|
||||
|
||||
# Test whether building works if the binary cache contains an
|
||||
# incomplete closure.
|
||||
clearStore
|
||||
|
||||
rm -v $(grep -l "StorePath:.*dependencies-input-2" $cacheDir/*.narinfo)
|
||||
rm -v "$(grep -l "StorePath:.*dependencies-input-2" "$cacheDir"/*.narinfo)"
|
||||
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result 2>&1 | tee $TEST_ROOT/log
|
||||
grepQuiet "copying path.*input-0" $TEST_ROOT/log
|
||||
grepQuiet "copying path.*input-2" $TEST_ROOT/log
|
||||
grepQuiet "copying path.*top" $TEST_ROOT/log
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o "$TEST_ROOT/result" 2>&1 | tee "$TEST_ROOT/log"
|
||||
grepQuiet "copying path.*input-0" "$TEST_ROOT/log"
|
||||
grepQuiet "copying path.*input-2" "$TEST_ROOT/log"
|
||||
grepQuiet "copying path.*top" "$TEST_ROOT/log"
|
||||
|
||||
|
||||
# Idem, but without cached .narinfo.
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result 2>&1 | tee $TEST_ROOT/log
|
||||
grepQuiet "don't know how to build" $TEST_ROOT/log
|
||||
grepQuiet "building.*input-1" $TEST_ROOT/log
|
||||
grepQuiet "building.*input-2" $TEST_ROOT/log
|
||||
grepQuiet "copying path.*input-0" $TEST_ROOT/log
|
||||
grepQuiet "copying path.*top" $TEST_ROOT/log
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o "$TEST_ROOT/result" 2>&1 | tee "$TEST_ROOT/log"
|
||||
grepQuiet "don't know how to build" "$TEST_ROOT/log"
|
||||
grepQuiet "building.*input-1" "$TEST_ROOT/log"
|
||||
grepQuiet "building.*input-2" "$TEST_ROOT/log"
|
||||
grepQuiet "copying path.*input-0" "$TEST_ROOT/log"
|
||||
grepQuiet "copying path.*top" "$TEST_ROOT/log"
|
||||
|
||||
|
||||
# Create a signed binary cache.
|
||||
clearCache
|
||||
clearCacheCache
|
||||
|
||||
nix key generate-secret --key-name test.nixos.org-1 > $TEST_ROOT/sk1
|
||||
publicKey=$(nix key convert-secret-to-public < $TEST_ROOT/sk1)
|
||||
nix key generate-secret --key-name test.nixos.org-1 > "$TEST_ROOT/sk1"
|
||||
publicKey=$(nix key convert-secret-to-public < "$TEST_ROOT/sk1")
|
||||
|
||||
nix key generate-secret --key-name test.nixos.org-1 > $TEST_ROOT/sk2
|
||||
badKey=$(nix key convert-secret-to-public < $TEST_ROOT/sk2)
|
||||
nix key generate-secret --key-name test.nixos.org-1 > "$TEST_ROOT/sk2"
|
||||
badKey=$(nix key convert-secret-to-public < "$TEST_ROOT/sk2")
|
||||
|
||||
nix key generate-secret --key-name foo.nixos.org-1 > $TEST_ROOT/sk3
|
||||
otherKey=$(nix key convert-secret-to-public < $TEST_ROOT/sk3)
|
||||
nix key generate-secret --key-name foo.nixos.org-1 > "$TEST_ROOT/sk3"
|
||||
otherKey=$(nix key convert-secret-to-public < "$TEST_ROOT/sk3")
|
||||
|
||||
_NIX_FORCE_HTTP= nix copy --to file://$cacheDir?secret-key=$TEST_ROOT/sk1 $outPath
|
||||
_NIX_FORCE_HTTP='' nix copy --to "file://$cacheDir"?secret-key="$TEST_ROOT"/sk1 "$outPath"
|
||||
|
||||
|
||||
# Downloading should fail if we don't provide a key.
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
(! nix-store -r $outPath --substituters "file://$cacheDir")
|
||||
(! nix-store -r "$outPath" --substituters "file://$cacheDir")
|
||||
|
||||
|
||||
# And it should fail if we provide an incorrect key.
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
(! nix-store -r $outPath --substituters "file://$cacheDir" --trusted-public-keys "$badKey")
|
||||
(! nix-store -r "$outPath" --substituters "file://$cacheDir" --trusted-public-keys "$badKey")
|
||||
|
||||
|
||||
# It should succeed if we provide the correct key.
|
||||
nix-store -r $outPath --substituters "file://$cacheDir" --trusted-public-keys "$otherKey $publicKey"
|
||||
nix-store -r "$outPath" --substituters "file://$cacheDir" --trusted-public-keys "$otherKey $publicKey"
|
||||
|
||||
|
||||
# It should fail if we corrupt the .narinfo.
|
||||
clearStore
|
||||
|
||||
cacheDir2=$TEST_ROOT/binary-cache-2
|
||||
rm -rf $cacheDir2
|
||||
cp -r $cacheDir $cacheDir2
|
||||
rm -rf "$cacheDir2"
|
||||
cp -r "$cacheDir" "$cacheDir2"
|
||||
|
||||
for i in $cacheDir2/*.narinfo; do
|
||||
grep -v References $i > $i.tmp
|
||||
mv $i.tmp $i
|
||||
for i in "$cacheDir2"/*.narinfo; do
|
||||
grep -v References "$i" > "$i".tmp
|
||||
mv "$i".tmp "$i"
|
||||
done
|
||||
|
||||
clearCacheCache
|
||||
|
||||
(! nix-store -r $outPath --substituters "file://$cacheDir2" --trusted-public-keys "$publicKey")
|
||||
(! nix-store -r "$outPath" --substituters "file://$cacheDir2" --trusted-public-keys "$publicKey")
|
||||
|
||||
# If we provide a bad and a good binary cache, it should succeed.
|
||||
|
||||
nix-store -r $outPath --substituters "file://$cacheDir2 file://$cacheDir" --trusted-public-keys "$publicKey"
|
||||
nix-store -r "$outPath" --substituters "file://$cacheDir2 file://$cacheDir" --trusted-public-keys "$publicKey"
|
||||
|
||||
|
||||
unset _NIX_FORCE_HTTP
|
||||
|
||||
|
||||
# Test 'nix verify --all' on a binary cache.
|
||||
nix store verify -vvvvv --all --store file://$cacheDir --no-trust
|
||||
nix store verify -vvvvv --all --store "file://$cacheDir" --no-trust
|
||||
|
||||
|
||||
# Test local NAR caching.
|
||||
narCache=$TEST_ROOT/nar-cache
|
||||
rm -rf $narCache
|
||||
mkdir $narCache
|
||||
rm -rf "$narCache"
|
||||
mkdir "$narCache"
|
||||
|
||||
[[ $(nix store cat --store "file://$cacheDir?local-nar-cache=$narCache" $outPath/foobar) = FOOBAR ]]
|
||||
[[ $(nix store cat --store "file://$cacheDir?local-nar-cache=$narCache" "$outPath/foobar") = FOOBAR ]]
|
||||
|
||||
rm -rfv "$cacheDir/nar"
|
||||
|
||||
[[ $(nix store cat --store "file://$cacheDir?local-nar-cache=$narCache" $outPath/foobar) = FOOBAR ]]
|
||||
[[ $(nix store cat --store "file://$cacheDir?local-nar-cache=$narCache" "$outPath/foobar") = FOOBAR ]]
|
||||
|
||||
(! nix store cat --store file://$cacheDir $outPath/foobar)
|
||||
(! nix store cat --store "file://$cacheDir" "$outPath/foobar")
|
||||
|
||||
|
||||
# Test NAR listing generation.
|
||||
clearCache
|
||||
|
||||
|
||||
# preserve quotes variables in the single-quoted string
|
||||
# shellcheck disable=SC2016
|
||||
outPath=$(nix-build --no-out-link -E '
|
||||
with import ./config.nix;
|
||||
mkDerivation {
|
||||
|
@ -240,16 +245,18 @@ outPath=$(nix-build --no-out-link -E '
|
|||
}
|
||||
')
|
||||
|
||||
nix copy --to file://$cacheDir?write-nar-listing=1 $outPath
|
||||
nix copy --to "file://$cacheDir"?write-nar-listing=1 "$outPath"
|
||||
|
||||
diff -u \
|
||||
<(jq -S < $cacheDir/$(basename $outPath | cut -c1-32).ls) \
|
||||
<(jq -S < "$cacheDir/$(basename "$outPath" | cut -c1-32).ls") \
|
||||
<(echo '{"version":1,"root":{"type":"directory","entries":{"bar":{"type":"regular","size":4,"narOffset":232},"link":{"type":"symlink","target":"xyzzy"}}}}' | jq -S)
|
||||
|
||||
|
||||
# Test debug info index generation.
|
||||
clearCache
|
||||
|
||||
# preserve quotes variables in the single-quoted string
|
||||
# shellcheck disable=SC2016
|
||||
outPath=$(nix-build --no-out-link -E '
|
||||
with import ./config.nix;
|
||||
mkDerivation {
|
||||
|
@ -258,14 +265,16 @@ outPath=$(nix-build --no-out-link -E '
|
|||
}
|
||||
')
|
||||
|
||||
nix copy --to "file://$cacheDir?index-debug-info=1&compression=none" $outPath
|
||||
nix copy --to "file://$cacheDir?index-debug-info=1&compression=none" "$outPath"
|
||||
|
||||
diff -u \
|
||||
<(cat $cacheDir/debuginfo/02623eda209c26a59b1a8638ff7752f6b945c26b.debug | jq -S) \
|
||||
<(jq -S < "$cacheDir"/debuginfo/02623eda209c26a59b1a8638ff7752f6b945c26b.debug) \
|
||||
<(echo '{"archive":"../nar/100vxs724qr46phz8m24iswmg9p3785hsyagz0kchf6q6gf06sw6.nar","member":"lib/debug/.build-id/02/623eda209c26a59b1a8638ff7752f6b945c26b.debug"}' | jq -S)
|
||||
|
||||
# Test against issue https://github.com/NixOS/nix/issues/3964
|
||||
#
|
||||
|
||||
# preserve quotes variables in the single-quoted string
|
||||
# shellcheck disable=SC2016
|
||||
expr='
|
||||
with import ./config.nix;
|
||||
mkDerivation {
|
||||
|
@ -275,22 +284,22 @@ expr='
|
|||
}
|
||||
'
|
||||
outPath=$(nix-build --no-out-link -E "$expr")
|
||||
docPath=$(nix-store -q --references $outPath)
|
||||
docPath=$(nix-store -q --references "$outPath")
|
||||
|
||||
# $ nix-store -q --tree $outPath
|
||||
# ...-multi-output
|
||||
# +---...-multi-output-doc
|
||||
|
||||
nix copy --to "file://$cacheDir" $outPath
|
||||
nix copy --to "file://$cacheDir" "$outPath"
|
||||
|
||||
hashpart() {
|
||||
basename "$1" | cut -c1-32
|
||||
}
|
||||
|
||||
# break the closure of out by removing doc
|
||||
rm $cacheDir/$(hashpart $docPath).narinfo
|
||||
rm "$cacheDir/$(hashpart "$docPath")".narinfo
|
||||
|
||||
nix-store --delete $outPath $docPath
|
||||
nix-store --delete "$outPath" "$docPath"
|
||||
# -vvv is the level that logs during the loop
|
||||
timeout 60 nix-build --no-out-link -E "$expr" --option substituters "file://$cacheDir" \
|
||||
--option trusted-binary-caches "file://$cacheDir" --no-require-sigs
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
clearCache
|
||||
|
||||
|
@ -9,15 +11,15 @@ cacheURI="file://$cacheDir?compression=br"
|
|||
|
||||
outPath=$(nix-build dependencies.nix --no-out-link)
|
||||
|
||||
nix copy --to $cacheURI $outPath
|
||||
nix copy --to "$cacheURI" "$outPath"
|
||||
|
||||
HASH=$(nix hash path $outPath)
|
||||
HASH=$(nix hash path "$outPath")
|
||||
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
nix copy --from $cacheURI $outPath --no-check-sigs
|
||||
nix copy --from "$cacheURI" "$outPath" --no-check-sigs
|
||||
|
||||
HASH2=$(nix hash path $outPath)
|
||||
HASH2=$(nix hash path "$outPath")
|
||||
|
||||
[[ $HASH = $HASH2 ]]
|
||||
[[ $HASH == "$HASH2" ]]
|
||||
|
|
|
@ -2,29 +2,29 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
# https://github.com/NixOS/nix/issues/6572
|
||||
issue_6572_independent_outputs() {
|
||||
nix build -f multiple-outputs.nix --json independent --no-link > $TEST_ROOT/independent.json
|
||||
nix build -f multiple-outputs.nix --json independent --no-link > "$TEST_ROOT"/independent.json
|
||||
|
||||
# Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
|
||||
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
nix-store --delete "$(jq -r <$TEST_ROOT/independent.json .[0].outputs.first)"
|
||||
nix-store --delete "$(jq -r <"$TEST_ROOT"/independent.json .[0].outputs.first)"
|
||||
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
|
||||
cmp $p <<EOF
|
||||
cmp "$p" <<EOF
|
||||
first
|
||||
second
|
||||
EOF
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
nix-store --delete "$(jq -r <$TEST_ROOT/independent.json .[0].outputs.second)"
|
||||
nix-store --delete "$(jq -r <"$TEST_ROOT"/independent.json .[0].outputs.second)"
|
||||
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
|
||||
cmp $p <<EOF
|
||||
cmp "$p" <<EOF
|
||||
first
|
||||
second
|
||||
EOF
|
||||
|
@ -36,16 +36,16 @@ issue_6572_independent_outputs
|
|||
# https://github.com/NixOS/nix/issues/6572
|
||||
issue_6572_dependent_outputs() {
|
||||
|
||||
nix build -f multiple-outputs.nix --json a --no-link > $TEST_ROOT/a.json
|
||||
nix build -f multiple-outputs.nix --json a --no-link > "$TEST_ROOT"/a.json
|
||||
|
||||
# # Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
|
||||
p=$(nix build -f multiple-outputs.nix use-a --no-link --print-out-paths)
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
nix-store --delete "$(jq -r <$TEST_ROOT/a.json .[0].outputs.second)"
|
||||
nix-store --delete "$(jq -r <"$TEST_ROOT"/a.json .[0].outputs.second)"
|
||||
p=$(nix build -f multiple-outputs.nix use-a --no-link --print-out-paths)
|
||||
cmp $p <<EOF
|
||||
cmp "$p" <<EOF
|
||||
first
|
||||
second
|
||||
EOF
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
###################################################
|
||||
# Check that --dry-run isn't confused with read-only mode
|
||||
# https://github.com/NixOS/nix/issues/1795
|
||||
|
@ -35,17 +37,17 @@ clearStore
|
|||
clearCache
|
||||
|
||||
RESULT=$TEST_ROOT/result-link
|
||||
rm -f $RESULT
|
||||
rm -f "$RESULT"
|
||||
|
||||
nix-build dependencies.nix -o $RESULT --dry-run
|
||||
nix-build dependencies.nix -o "$RESULT" --dry-run
|
||||
|
||||
[[ ! -h $RESULT ]] || fail "nix-build --dry-run created output link"
|
||||
|
||||
nix build -f dependencies.nix -o $RESULT --dry-run
|
||||
nix build -f dependencies.nix -o "$RESULT" --dry-run
|
||||
|
||||
[[ ! -h $RESULT ]] || fail "nix build --dry-run created output link"
|
||||
|
||||
nix build -f dependencies.nix -o $RESULT
|
||||
nix build -f dependencies.nix -o "$RESULT"
|
||||
|
||||
[[ -h $RESULT ]]
|
||||
|
||||
|
@ -58,12 +60,12 @@ RES=$(nix build -f dependencies.nix --dry-run --json)
|
|||
|
||||
if [[ -z "${NIX_TESTS_CA_BY_DEFAULT-}" ]]; then
|
||||
echo "$RES" | jq '.[0] | [
|
||||
(.drvPath | test("'$NIX_STORE_DIR'.*\\.drv")),
|
||||
(.outputs.out | test("'$NIX_STORE_DIR'"))
|
||||
(.drvPath | test("'"$NIX_STORE_DIR"'.*\\.drv")),
|
||||
(.outputs.out | test("'"$NIX_STORE_DIR"'"))
|
||||
] | all'
|
||||
else
|
||||
echo "$RES" | jq '.[0] | [
|
||||
(.drvPath | test("'$NIX_STORE_DIR'.*\\.drv")),
|
||||
(.drvPath | test("'"$NIX_STORE_DIR"'.*\\.drv")),
|
||||
.outputs.out == null
|
||||
] | all'
|
||||
fi
|
||||
|
|
|
@ -23,7 +23,7 @@ EOF
|
|||
chmod +x "$TEST_ROOT/post-build-hook.sh"
|
||||
rm -f "$TEST_ROOT/post-hook-counter"
|
||||
|
||||
echo "post-build-hook = $TEST_ROOT/post-build-hook.sh" >> "$NIX_CONF_DIR/nix.conf"
|
||||
echo "post-build-hook = $TEST_ROOT/post-build-hook.sh" >> "$test_nix_conf"
|
||||
}
|
||||
|
||||
registerBuildHook
|
||||
|
|
|
@ -4,6 +4,7 @@ source common.sh
|
|||
|
||||
enableFeatures "daemon-trust-override"
|
||||
|
||||
TODO_NixOS
|
||||
restartDaemon
|
||||
|
||||
requireSandboxSupport
|
||||
|
|
|
@ -4,6 +4,8 @@ source common.sh
|
|||
|
||||
enableFeatures "daemon-trust-override"
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
restartDaemon
|
||||
|
||||
# Remote doesn't trust us
|
||||
|
|
|
@ -4,6 +4,7 @@ source common.sh
|
|||
|
||||
enableFeatures "daemon-trust-override"
|
||||
|
||||
TODO_NixOS
|
||||
restartDaemon
|
||||
|
||||
# Remote doesn't trusts us, but this is fine because we are only
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
# Make sure that 'nix build' returns all outputs by default.
|
||||
nix build -f multiple-outputs.nix --json a b --no-link | jq --exit-status '
|
||||
|
|
|
@ -26,7 +26,8 @@ copyAttr () {
|
|||
# Note: to copy CA derivations, we need to copy the realisations, which
|
||||
# currently requires naming the installables, not just the derivation output
|
||||
# path.
|
||||
nix copy --to file://$cacheDir "${args[@]}"
|
||||
|
||||
nix copy --to "file://$cacheDir" "${args[@]}"
|
||||
}
|
||||
|
||||
testRemoteCacheFor () {
|
||||
|
@ -35,7 +36,7 @@ testRemoteCacheFor () {
|
|||
copyAttr "$derivationPath" 1
|
||||
clearStore
|
||||
# Check nothing gets built.
|
||||
buildAttr "$derivationPath" 1 --option substituters file://$cacheDir --no-require-sigs |& grepQuietInverse " will be built:"
|
||||
buildAttr "$derivationPath" 1 --option substituters "file://$cacheDir" --no-require-sigs |& grepQuietInverse " will be built:"
|
||||
}
|
||||
|
||||
testRemoteCache () {
|
||||
|
@ -48,4 +49,4 @@ testRemoteCache () {
|
|||
}
|
||||
|
||||
clearStore
|
||||
testRemoteCache
|
||||
testRemoteCache
|
||||
|
|
|
@ -20,11 +20,11 @@ testDeterministicCA () {
|
|||
|
||||
testCutoffFor () {
|
||||
local out1 out2
|
||||
out1=$(buildAttr $1 1)
|
||||
out1=$(buildAttr "$1" 1)
|
||||
# The seed only changes the root derivation, and not it's output, so the
|
||||
# dependent derivations should only need to be built once.
|
||||
buildAttr rootCA 2
|
||||
out2=$(buildAttr $1 2 -j0)
|
||||
out2=$(buildAttr "$1" 2 -j0)
|
||||
test "$out1" == "$out2"
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ testGC () {
|
|||
nix-instantiate ./content-addressed.nix -A rootCA --arg seed 5
|
||||
nix-collect-garbage --option keep-derivations true
|
||||
clearStore
|
||||
buildAttr rootCA 1 --out-link $TEST_ROOT/rootCA
|
||||
buildAttr rootCA 1 --out-link "$TEST_ROOT"/rootCA
|
||||
nix-collect-garbage
|
||||
buildAttr rootCA 1 -j0
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ testNixCommand () {
|
|||
testNormalization () {
|
||||
clearStore
|
||||
outPath=$(buildAttr rootCA 1)
|
||||
test "$(stat -c %Y $outPath)" -eq 1
|
||||
test "$(stat -c %Y "$outPath")" -eq 1
|
||||
}
|
||||
|
||||
clearStore
|
||||
|
|
|
@ -2,4 +2,6 @@ source ../common.sh
|
|||
|
||||
enableFeatures "ca-derivations"
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
restartDaemon
|
||||
|
|
|
@ -1,29 +1,31 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
source common.sh
|
||||
|
||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||
|
||||
drvPath=$(nix-instantiate ../simple.nix)
|
||||
|
||||
nix derivation show $drvPath | jq .[] > $TEST_HOME/simple.json
|
||||
nix derivation show "$drvPath" | jq .[] > "$TEST_HOME"/simple.json
|
||||
|
||||
drvPath2=$(nix derivation add < $TEST_HOME/simple.json)
|
||||
drvPath2=$(nix derivation add < "$TEST_HOME"/simple.json)
|
||||
|
||||
[[ "$drvPath" = "$drvPath2" ]]
|
||||
|
||||
# Content-addressed derivations can be renamed.
|
||||
jq '.name = "foo"' < $TEST_HOME/simple.json > $TEST_HOME/foo.json
|
||||
drvPath3=$(nix derivation add --dry-run < $TEST_HOME/foo.json)
|
||||
jq '.name = "foo"' < "$TEST_HOME"/simple.json > "$TEST_HOME"/foo.json
|
||||
drvPath3=$(nix derivation add --dry-run < "$TEST_HOME"/foo.json)
|
||||
# With --dry-run nothing is actually written
|
||||
[[ ! -e "$drvPath3" ]]
|
||||
|
||||
# But the JSON is rejected without the experimental feature
|
||||
expectStderr 1 nix derivation add < $TEST_HOME/foo.json --experimental-features nix-command | grepQuiet "experimental Nix feature 'ca-derivations' is disabled"
|
||||
expectStderr 1 nix derivation add < "$TEST_HOME"/foo.json --experimental-features nix-command | grepQuiet "experimental Nix feature 'ca-derivations' is disabled"
|
||||
|
||||
# Without --dry-run it is actually written
|
||||
drvPath4=$(nix derivation add < $TEST_HOME/foo.json)
|
||||
drvPath4=$(nix derivation add < "$TEST_HOME"/foo.json)
|
||||
[[ "$drvPath4" = "$drvPath3" ]]
|
||||
[[ -e "$drvPath3" ]]
|
||||
|
||||
# The modified derivation read back as JSON matches
|
||||
nix derivation show $drvPath3 | jq .[] > $TEST_HOME/foo-read.json
|
||||
diff $TEST_HOME/foo.json $TEST_HOME/foo-read.json
|
||||
nix derivation show "$drvPath3" | jq .[] > "$TEST_HOME"/foo-read.json
|
||||
diff "$TEST_HOME"/foo.json "$TEST_HOME"/foo-read.json
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source ./common.sh
|
||||
|
||||
requireDaemonNewerThan "2.4pre20210625"
|
||||
|
@ -5,7 +7,7 @@ requireDaemonNewerThan "2.4pre20210625"
|
|||
export REMOTE_STORE_DIR="$TEST_ROOT/remote_store"
|
||||
export REMOTE_STORE="file://$REMOTE_STORE_DIR"
|
||||
|
||||
rm -rf $REMOTE_STORE_DIR
|
||||
rm -rf "$REMOTE_STORE_DIR"
|
||||
clearStore
|
||||
|
||||
# Build dep1 and push that to the binary cache.
|
||||
|
|
|
@ -15,13 +15,13 @@ testOneCopy () {
|
|||
rm -rf "$REMOTE_STORE_DIR"
|
||||
|
||||
attrPath="$1"
|
||||
nix copy --to $REMOTE_STORE "$attrPath" --file ./content-addressed.nix
|
||||
nix copy --to "$REMOTE_STORE" "$attrPath" --file ./content-addressed.nix
|
||||
|
||||
ensureCorrectlyCopied "$attrPath"
|
||||
|
||||
# Ensure that we can copy back what we put in the store
|
||||
clearStore
|
||||
nix copy --from $REMOTE_STORE \
|
||||
nix copy --from "$REMOTE_STORE" \
|
||||
--file ./content-addressed.nix "$attrPath" \
|
||||
--no-check-sigs
|
||||
}
|
||||
|
|
|
@ -4,4 +4,4 @@ source common.sh
|
|||
|
||||
FLAKE_PATH=path:$PWD
|
||||
|
||||
nix run --no-write-lock-file $FLAKE_PATH#runnable
|
||||
nix run --no-write-lock-file "$FLAKE_PATH#runnable"
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearCache
|
||||
|
||||
nix-store --generate-binary-cache-key cache1.example.org $TEST_ROOT/sk1 $TEST_ROOT/pk1
|
||||
pk1=$(cat $TEST_ROOT/pk1)
|
||||
nix-store --generate-binary-cache-key cache1.example.org "$TEST_ROOT/sk1" "$TEST_ROOT/pk1"
|
||||
pk1=$(cat "$TEST_ROOT/pk1")
|
||||
|
||||
export REMOTE_STORE_DIR="$TEST_ROOT/remote_store"
|
||||
export REMOTE_STORE="file://$REMOTE_STORE_DIR"
|
||||
|
@ -19,16 +21,16 @@ testOneCopy () {
|
|||
rm -rf "$REMOTE_STORE_DIR"
|
||||
|
||||
attrPath="$1"
|
||||
nix copy -vvvv --to $REMOTE_STORE "$attrPath" --file ./content-addressed.nix \
|
||||
nix copy -vvvv --to "$REMOTE_STORE" "$attrPath" --file ./content-addressed.nix \
|
||||
--secret-key-files "$TEST_ROOT/sk1" --show-trace
|
||||
|
||||
ensureCorrectlyCopied "$attrPath"
|
||||
|
||||
# Ensure that we can copy back what we put in the store
|
||||
clearStore
|
||||
nix copy --from $REMOTE_STORE \
|
||||
nix copy --from "$REMOTE_STORE" \
|
||||
--file ./content-addressed.nix "$attrPath" \
|
||||
--trusted-public-keys $pk1
|
||||
--trusted-public-keys "$pk1"
|
||||
}
|
||||
|
||||
for attrPath in rootCA dependentCA transitivelyDependentCA dependentNonCA dependentFixedOutput; do
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
# shellcheck disable=SC1111
|
||||
needLocalStore "“--no-require-sigs” can’t be used with the daemon"
|
||||
|
||||
rm -rf $TEST_ROOT/binary_cache
|
||||
rm -rf "$TEST_ROOT/binary_cache"
|
||||
|
||||
export REMOTE_STORE_DIR=$TEST_ROOT/binary_cache
|
||||
export REMOTE_STORE=file://$REMOTE_STORE_DIR
|
||||
|
@ -17,11 +18,11 @@ buildDrvs () {
|
|||
|
||||
# Populate the remote cache
|
||||
clearStore
|
||||
nix copy --to $REMOTE_STORE --file ./content-addressed.nix
|
||||
nix copy --to "$REMOTE_STORE" --file ./content-addressed.nix
|
||||
|
||||
# Restart the build on an empty store, ensuring that we don't build
|
||||
clearStore
|
||||
buildDrvs --substitute --substituters $REMOTE_STORE --no-require-sigs -j0 transitivelyDependentCA
|
||||
buildDrvs --substitute --substituters "$REMOTE_STORE" --no-require-sigs -j0 transitivelyDependentCA
|
||||
# Check that the thing we’ve just substituted has its realisation stored
|
||||
nix realisation info --file ./content-addressed.nix transitivelyDependentCA
|
||||
# Check that its dependencies have it too
|
||||
|
@ -63,9 +64,9 @@ clearStore
|
|||
# Add the realisations of rootCA to the cachecache
|
||||
clearCacheCache
|
||||
export _NIX_FORCE_HTTP=1
|
||||
buildDrvs --substitute --substituters $REMOTE_STORE --no-require-sigs -j0
|
||||
buildDrvs --substitute --substituters "$REMOTE_STORE" --no-require-sigs -j0
|
||||
# Try rebuilding, but remove the realisations from the remote cache to force
|
||||
# using the cachecache
|
||||
clearStore
|
||||
rm $REMOTE_STORE_DIR/realisations/*
|
||||
buildDrvs --substitute --substituters $REMOTE_STORE --no-require-sigs -j0
|
||||
rm "$REMOTE_STORE_DIR"/realisations/*
|
||||
buildDrvs --substitute --substituters "$REMOTE_STORE" --no-require-sigs -j0
|
||||
|
|
|
@ -2,20 +2,23 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
rm -rf $TEST_ROOT/case
|
||||
rm -rf "$TEST_ROOT/case"
|
||||
|
||||
opts="--option use-case-hack true"
|
||||
opts=("--option" "use-case-hack" "true")
|
||||
|
||||
# Check whether restoring and dumping a NAR that contains case
|
||||
# collisions is round-tripping, even on a case-insensitive system.
|
||||
nix-store $opts --restore $TEST_ROOT/case < case.nar
|
||||
nix-store $opts --dump $TEST_ROOT/case > $TEST_ROOT/case.nar
|
||||
cmp case.nar $TEST_ROOT/case.nar
|
||||
[ "$(nix-hash $opts --type sha256 $TEST_ROOT/case)" = "$(nix-hash --flat --type sha256 case.nar)" ]
|
||||
|
||||
nix-store "${opts[@]}" --restore "$TEST_ROOT/case" < case.nar
|
||||
nix-store "${opts[@]}" --dump "$TEST_ROOT/case" > "$TEST_ROOT/case.nar"
|
||||
cmp case.nar "$TEST_ROOT/case.nar"
|
||||
[ "$(nix-hash "${opts[@]}" --type sha256 "$TEST_ROOT/case")" = "$(nix-hash --flat --type sha256 case.nar)" ]
|
||||
|
||||
# Check whether we detect true collisions (e.g. those remaining after
|
||||
# removal of the suffix).
|
||||
touch "$TEST_ROOT/case/xt_CONNMARK.h~nix~case~hack~3"
|
||||
(! nix-store $opts --dump $TEST_ROOT/case > /dev/null)
|
||||
(! nix-store "${opts[@]}" --dump "$TEST_ROOT/case" > /dev/null)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Test the function for lang.sh
|
||||
source common.sh
|
||||
|
||||
source lang/framework.sh
|
||||
source characterisation/framework.sh
|
||||
|
||||
# We are testing this, so don't want outside world to affect us.
|
||||
unset _NIX_TEST_ACCEPT
|
77
tests/functional/characterisation/framework.sh
Normal file
77
tests/functional/characterisation/framework.sh
Normal file
|
@ -0,0 +1,77 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
# Golden test support
|
||||
#
|
||||
# Test that the output of the given test matches what is expected. If
|
||||
# `_NIX_TEST_ACCEPT` is non-empty also update the expected output so
|
||||
# that next time the test succeeds.
|
||||
function diffAndAcceptInner() {
|
||||
local -r testName=$1
|
||||
local -r got="$2"
|
||||
local -r expected="$3"
|
||||
|
||||
# Absence of expected file indicates empty output expected.
|
||||
if test -e "$expected"; then
|
||||
local -r expectedOrEmpty="$expected"
|
||||
else
|
||||
local -r expectedOrEmpty=characterisation/empty
|
||||
fi
|
||||
|
||||
# Diff so we get a nice message
|
||||
if ! diff --color=always --unified "$expectedOrEmpty" "$got"; then
|
||||
echo "FAIL: evaluation result of $testName not as expected"
|
||||
# shellcheck disable=SC2034
|
||||
badDiff=1
|
||||
fi
|
||||
|
||||
# Update expected if `_NIX_TEST_ACCEPT` is non-empty.
|
||||
if test -n "${_NIX_TEST_ACCEPT-}"; then
|
||||
cp "$got" "$expected"
|
||||
# Delete empty expected files to avoid bloating the repo with
|
||||
# empty files.
|
||||
if ! test -s "$expected"; then
|
||||
rm "$expected"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function characterisationTestExit() {
|
||||
# Make sure shellcheck knows all these will be defined by the caller
|
||||
: "${badDiff?} ${badExitCode?}"
|
||||
|
||||
if test -n "${_NIX_TEST_ACCEPT-}"; then
|
||||
if (( "$badDiff" )); then
|
||||
set +x
|
||||
echo 'Output did mot match, but accepted output as the persisted expected output.'
|
||||
echo 'That means the next time the tests are run, they should pass.'
|
||||
set -x
|
||||
else
|
||||
set +x
|
||||
echo 'NOTE: Environment variable _NIX_TEST_ACCEPT is defined,'
|
||||
echo 'indicating the unexpected output should be accepted as the expected output going forward,'
|
||||
echo 'but no tests had unexpected output so there was no expected output to update.'
|
||||
set -x
|
||||
fi
|
||||
if (( "$badExitCode" )); then
|
||||
exit "$badExitCode"
|
||||
else
|
||||
skipTest "regenerating golden masters"
|
||||
fi
|
||||
else
|
||||
if (( "$badDiff" )); then
|
||||
set +x
|
||||
echo ''
|
||||
echo 'You can rerun this test with:'
|
||||
echo ''
|
||||
echo " _NIX_TEST_ACCEPT=1 make tests/functional/${TEST_NAME}.test"
|
||||
echo ''
|
||||
echo 'to regenerate the files containing the expected output,'
|
||||
echo 'and then view the git diff to decide whether a change is'
|
||||
echo 'good/intentional or bad/unintentional.'
|
||||
echo 'If the diff contains arbitrary or impure information,'
|
||||
echo 'please improve the normalization that the test applies to the output.'
|
||||
set -x
|
||||
fi
|
||||
exit $(( "$badExitCode" + "$badDiff" ))
|
||||
fi
|
||||
}
|
|
@ -2,54 +2,61 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
RESULT=$TEST_ROOT/result
|
||||
|
||||
dep=$(nix-build -o $RESULT check-refs.nix -A dep)
|
||||
dep=$(nix-build -o "$RESULT" check-refs.nix -A dep)
|
||||
|
||||
# test1 references dep, not itself.
|
||||
test1=$(nix-build -o $RESULT check-refs.nix -A test1)
|
||||
nix-store -q --references $test1 | grepQuietInverse $test1
|
||||
nix-store -q --references $test1 | grepQuiet $dep
|
||||
test1=$(nix-build -o "$RESULT" check-refs.nix -A test1)
|
||||
nix-store -q --references "$test1" | grepQuietInverse "$test1"
|
||||
nix-store -q --references "$test1" | grepQuiet "$dep"
|
||||
|
||||
# test2 references src, not itself nor dep.
|
||||
test2=$(nix-build -o $RESULT check-refs.nix -A test2)
|
||||
nix-store -q --references $test2 | grepQuietInverse $test2
|
||||
nix-store -q --references $test2 | grepQuietInverse $dep
|
||||
nix-store -q --references $test2 | grepQuiet aux-ref
|
||||
test2=$(nix-build -o "$RESULT" check-refs.nix -A test2)
|
||||
nix-store -q --references "$test2" | grepQuietInverse "$test2"
|
||||
nix-store -q --references "$test2" | grepQuietInverse "$dep"
|
||||
nix-store -q --references "$test2" | grepQuiet aux-ref
|
||||
|
||||
# test3 should fail (unallowed ref).
|
||||
(! nix-build -o $RESULT check-refs.nix -A test3)
|
||||
(! nix-build -o "$RESULT" check-refs.nix -A test3)
|
||||
|
||||
# test4 should succeed.
|
||||
nix-build -o $RESULT check-refs.nix -A test4
|
||||
nix-build -o "$RESULT" check-refs.nix -A test4
|
||||
|
||||
# test5 should succeed.
|
||||
nix-build -o $RESULT check-refs.nix -A test5
|
||||
nix-build -o "$RESULT" check-refs.nix -A test5
|
||||
|
||||
# test6 should fail (unallowed self-ref).
|
||||
(! nix-build -o $RESULT check-refs.nix -A test6)
|
||||
(! nix-build -o "$RESULT" check-refs.nix -A test6)
|
||||
|
||||
# test7 should succeed (allowed self-ref).
|
||||
nix-build -o $RESULT check-refs.nix -A test7
|
||||
nix-build -o "$RESULT" check-refs.nix -A test7
|
||||
|
||||
# test8 should fail (toFile depending on derivation output).
|
||||
(! nix-build -o $RESULT check-refs.nix -A test8)
|
||||
(! nix-build -o "$RESULT" check-refs.nix -A test8)
|
||||
|
||||
# test9 should fail (disallowed reference).
|
||||
(! nix-build -o $RESULT check-refs.nix -A test9)
|
||||
(! nix-build -o "$RESULT" check-refs.nix -A test9)
|
||||
|
||||
# test10 should succeed (no disallowed references).
|
||||
nix-build -o $RESULT check-refs.nix -A test10
|
||||
nix-build -o "$RESULT" check-refs.nix -A test10
|
||||
|
||||
if isDaemonNewer 2.12pre20230103; then
|
||||
if ! isDaemonNewer 2.16.0; then
|
||||
enableFeatures discard-references
|
||||
restartDaemon
|
||||
if ! isTestOnNixOS; then
|
||||
# If we have full control over our store, we can test some more things.
|
||||
|
||||
if isDaemonNewer 2.12pre20230103; then
|
||||
if ! isDaemonNewer 2.16.0; then
|
||||
enableFeatures discard-references
|
||||
restartDaemon
|
||||
fi
|
||||
|
||||
# test11 should succeed.
|
||||
test11=$(nix-build -o "$RESULT" check-refs.nix -A test11)
|
||||
[[ -z $(nix-store -q --references "$test11") ]]
|
||||
fi
|
||||
|
||||
# test11 should succeed.
|
||||
test11=$(nix-build -o $RESULT check-refs.nix -A test11)
|
||||
[[ -z $(nix-store -q --references "$test11") ]]
|
||||
fi
|
||||
|
|
|
@ -2,17 +2,17 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
RESULT=$TEST_ROOT/result
|
||||
|
||||
nix-build -o $RESULT check-reqs.nix -A test1
|
||||
nix-build -o "$RESULT" check-reqs.nix -A test1
|
||||
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test2)
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test3)
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test4) 2>&1 | grepQuiet 'check-reqs-dep1'
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test4) 2>&1 | grepQuiet 'check-reqs-dep2'
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test5)
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test6)
|
||||
(! nix-build -o "$RESULT" check-reqs.nix -A test2)
|
||||
(! nix-build -o "$RESULT" check-reqs.nix -A test3)
|
||||
(! nix-build -o "$RESULT" check-reqs.nix -A test4) 2>&1 | grepQuiet 'check-reqs-dep1'
|
||||
(! nix-build -o "$RESULT" check-reqs.nix -A test4) 2>&1 | grepQuiet 'check-reqs-dep2'
|
||||
(! nix-build -o "$RESULT" check-reqs.nix -A test5)
|
||||
(! nix-build -o "$RESULT" check-reqs.nix -A test6)
|
||||
|
||||
nix-build -o $RESULT check-reqs.nix -A test7
|
||||
nix-build -o "$RESULT" check-reqs.nix -A test7
|
||||
|
|
|
@ -15,6 +15,8 @@ checkBuildTempDirRemoved ()
|
|||
# written to build temp directories to verify created by this instance
|
||||
checkBuildId=$(date +%s%N)
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
nix-build dependencies.nix --no-out-link
|
||||
|
@ -46,7 +48,10 @@ test_custom_build_dir() {
|
|||
--no-out-link --keep-failed --option build-dir "$TEST_ROOT/custom-build-dir" 2> $TEST_ROOT/log || status=$?
|
||||
[ "$status" = "100" ]
|
||||
[[ 1 == "$(count "$customBuildDir/nix-build-"*)" ]]
|
||||
local buildDir="$customBuildDir/nix-build-"*
|
||||
local buildDir="$customBuildDir/nix-build-"*""
|
||||
if [[ -e $buildDir/build ]]; then
|
||||
buildDir=$buildDir/build
|
||||
fi
|
||||
grep $checkBuildId $buildDir/checkBuildId
|
||||
}
|
||||
test_custom_build_dir
|
||||
|
@ -76,6 +81,8 @@ grep 'may not be deterministic' $TEST_ROOT/log
|
|||
[ "$status" = "104" ]
|
||||
if checkBuildTempDirRemoved $TEST_ROOT/log; then false; fi
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
path=$(nix-build check.nix -A fetchurl --no-out-link)
|
||||
|
|
|
@ -2,34 +2,34 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
echo example > $TEST_ROOT/example.txt
|
||||
mkdir -p $TEST_ROOT/x
|
||||
echo example > "$TEST_ROOT"/example.txt
|
||||
mkdir -p "$TEST_ROOT/x"
|
||||
|
||||
export NIX_STORE_DIR=/nix2/store
|
||||
|
||||
CORRECT_PATH=$(cd $TEST_ROOT && nix-store --store ./x --add example.txt)
|
||||
CORRECT_PATH=$(cd "$TEST_ROOT" && nix-store --store ./x --add example.txt)
|
||||
|
||||
[[ $CORRECT_PATH =~ ^/nix2/store/.*-example.txt$ ]]
|
||||
|
||||
PATH1=$(cd $TEST_ROOT && nix path-info --store ./x $CORRECT_PATH)
|
||||
[ $CORRECT_PATH == $PATH1 ]
|
||||
PATH1=$(cd "$TEST_ROOT" && nix path-info --store ./x "$CORRECT_PATH")
|
||||
[ "$CORRECT_PATH" == "$PATH1" ]
|
||||
|
||||
PATH2=$(nix path-info --store "$TEST_ROOT/x" $CORRECT_PATH)
|
||||
[ $CORRECT_PATH == $PATH2 ]
|
||||
PATH2=$(nix path-info --store "$TEST_ROOT/x" "$CORRECT_PATH")
|
||||
[ "$CORRECT_PATH" == "$PATH2" ]
|
||||
|
||||
PATH3=$(nix path-info --store "local?root=$TEST_ROOT/x" $CORRECT_PATH)
|
||||
[ $CORRECT_PATH == $PATH3 ]
|
||||
PATH3=$(nix path-info --store "local?root=$TEST_ROOT/x" "$CORRECT_PATH")
|
||||
[ "$CORRECT_PATH" == "$PATH3" ]
|
||||
|
||||
# Ensure store info trusted works with local store
|
||||
nix --store $TEST_ROOT/x store info --json | jq -e '.trusted'
|
||||
nix --store "$TEST_ROOT/x" store info --json | jq -e '.trusted'
|
||||
|
||||
# Test building in a chroot store.
|
||||
if canUseSandbox; then
|
||||
|
||||
flakeDir=$TEST_ROOT/flake
|
||||
mkdir -p $flakeDir
|
||||
mkdir -p "$flakeDir"
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = inputs: rec {
|
||||
packages.$system.default = import ./simple.nix;
|
||||
|
@ -37,11 +37,14 @@ if canUseSandbox; then
|
|||
}
|
||||
EOF
|
||||
|
||||
cp simple.nix shell.nix simple.builder.sh config.nix $flakeDir/
|
||||
cp simple.nix shell.nix simple.builder.sh config.nix "$flakeDir/"
|
||||
|
||||
outPath=$(nix build --print-out-paths --no-link --sandbox-paths '/nix? /bin? /lib? /lib64? /usr?' --store $TEST_ROOT/x path:$flakeDir)
|
||||
TODO_NixOS
|
||||
|
||||
outPath=$(nix build --print-out-paths --no-link --sandbox-paths '/nix? /bin? /lib? /lib64? /usr?' --store "$TEST_ROOT/x" path:"$flakeDir")
|
||||
|
||||
[[ $outPath =~ ^/nix2/store/.*-simple$ ]]
|
||||
|
||||
[[ $(cat $TEST_ROOT/x/nix/store/$(basename $outPath)/hello) = 'Hello World!' ]]
|
||||
base=$(basename "$outPath")
|
||||
[[ $(cat "$TEST_ROOT"/x/nix/store/"$base"/hello) = 'Hello World!' ]]
|
||||
fi
|
||||
|
|
|
@ -1,5 +1,31 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
# for shellcheck
|
||||
: "${test_nix_conf_dir?}" "${test_nix_conf?}"
|
||||
|
||||
if isTestOnNixOS; then
|
||||
|
||||
mkdir -p "$test_nix_conf_dir" "$TEST_HOME"
|
||||
|
||||
export NIX_USER_CONF_FILES="$test_nix_conf_dir/nix.conf"
|
||||
mkdir -p "$test_nix_conf_dir" "$TEST_HOME"
|
||||
! test -e "$test_nix_conf"
|
||||
cat > "$test_nix_conf_dir/nix.conf" <<EOF
|
||||
# TODO: this is not needed for all tests and prevents stable commands from be tested in isolation
|
||||
experimental-features = nix-command flakes
|
||||
flake-registry = $TEST_ROOT/registry.json
|
||||
show-trace = true
|
||||
EOF
|
||||
|
||||
# When we're doing everything in the same store, we need to bring
|
||||
# dependencies into context.
|
||||
sed -i "$(dirname "${BASH_SOURCE[0]}")"/../config.nix \
|
||||
-e 's^\(shell\) = "/nix/store/\([^/]*\)/\(.*\)";^\1 = builtins.appendContext "/nix/store/\2" { "/nix/store/\2".path = true; } + "/\3";^' \
|
||||
-e 's^\(path\) = "/nix/store/\([^/]*\)/\(.*\)";^\1 = builtins.appendContext "/nix/store/\2" { "/nix/store/\2".path = true; } + "/\3";^' \
|
||||
;
|
||||
|
||||
else
|
||||
|
||||
test -n "$TEST_ROOT"
|
||||
# We would delete any daemon socket, so let's stop the daemon first.
|
||||
killDaemon
|
||||
|
@ -13,7 +39,7 @@ mkdir "$TEST_HOME"
|
|||
|
||||
mkdir "$NIX_STORE_DIR"
|
||||
mkdir "$NIX_LOCALSTATE_DIR"
|
||||
mkdir -p "$NIX_LOG_DIR"/drvs
|
||||
mkdir -p "$NIX_LOG_DIR/drvs"
|
||||
mkdir "$NIX_STATE_DIR"
|
||||
mkdir "$NIX_CONF_DIR"
|
||||
|
||||
|
@ -41,3 +67,5 @@ EOF
|
|||
nix-store --init
|
||||
# Sanity check
|
||||
test -e "$NIX_STATE_DIR"/db/db.sqlite
|
||||
|
||||
fi # !isTestOnNixOS
|
||||
|
|
20
tests/functional/common/paths.sh
Normal file
20
tests/functional/common/paths.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
commonDir="$(readlink -f "$(dirname "${BASH_SOURCE[0]-$0}")")"
|
||||
|
||||
# Since this is a generated file
|
||||
# shellcheck disable=SC1091
|
||||
source "$commonDir/subst-vars.sh"
|
||||
# Make sure shellcheck knows this will be defined by the above generated snippet
|
||||
: "${bindir?}"
|
||||
|
||||
export PATH="$bindir:$PATH"
|
||||
|
||||
if [[ -n "${NIX_CLIENT_PACKAGE:-}" ]]; then
|
||||
export PATH="$NIX_CLIENT_PACKAGE/bin":$PATH
|
||||
fi
|
||||
|
||||
DAEMON_PATH="$PATH"
|
||||
if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
|
||||
DAEMON_PATH="${NIX_DAEMON_PACKAGE}/bin:$DAEMON_PATH"
|
||||
fi
|
|
@ -1,11 +1,14 @@
|
|||
# NOTE: instances of @variable@ are substituted as defined in /mk/templates.mk
|
||||
|
||||
export PATH=@bindir@:$PATH
|
||||
if [[ -z "${COMMON_SUBST_VARS_SH_SOURCED-}" ]]; then
|
||||
|
||||
COMMON_SUBST_VARS_SH_SOURCED=1
|
||||
|
||||
bindir=@bindir@
|
||||
export coreutils=@coreutils@
|
||||
#lsof=@lsof@
|
||||
|
||||
export dot=@dot@
|
||||
export SHELL="@bash@"
|
||||
export PAGER=cat
|
||||
export busybox="@sandbox_shell@"
|
||||
|
||||
|
@ -13,3 +16,10 @@ export version=@PACKAGE_VERSION@
|
|||
export system=@system@
|
||||
|
||||
export BUILD_SHARED_LIBS=@BUILD_SHARED_LIBS@
|
||||
|
||||
if ! isTestOnNixOS; then
|
||||
export SHELL="@bash@"
|
||||
export PATH=@bindir@:$PATH
|
||||
fi
|
||||
|
||||
fi
|
||||
|
|
4
tests/functional/common/test-root.sh
Normal file
4
tests/functional/common/test-root.sh
Normal file
|
@ -0,0 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
TEST_ROOT=$(realpath "${TMPDIR:-/tmp}/nix-test")/${TEST_NAME:-default/tests\/functional//}
|
||||
export TEST_ROOT
|
|
@ -6,36 +6,55 @@ if [[ -z "${COMMON_VARS_AND_FUNCTIONS_SH_SOURCED-}" ]]; then
|
|||
|
||||
COMMON_VARS_AND_FUNCTIONS_SH_SOURCED=1
|
||||
|
||||
isTestOnNixOS() {
|
||||
[[ "${isTestOnNixOS:-}" == 1 ]]
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "unexpected fatal error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
set +x
|
||||
|
||||
commonDir="$(readlink -f "$(dirname "${BASH_SOURCE[0]-$0}")")"
|
||||
|
||||
source "$commonDir/subst-vars.sh"
|
||||
# Make sure shellcheck knows all these will be defined by the above generated snippet
|
||||
: "${PATH?} ${coreutils?} ${dot?} ${SHELL?} ${PAGER?} ${busybox?} ${version?} ${system?} ${BUILD_SHARED_LIBS?}"
|
||||
: "${bindir?} ${coreutils?} ${dot?} ${SHELL?} ${PAGER?} ${busybox?} ${version?} ${system?} ${BUILD_SHARED_LIBS?}"
|
||||
|
||||
source "$commonDir/paths.sh"
|
||||
source "$commonDir/test-root.sh"
|
||||
|
||||
test_nix_conf_dir=$TEST_ROOT/etc
|
||||
test_nix_conf=$test_nix_conf_dir/nix.conf
|
||||
|
||||
export TEST_ROOT=$(realpath ${TMPDIR:-/tmp}/nix-test)/${TEST_NAME:-default/tests\/functional//}
|
||||
export NIX_STORE_DIR
|
||||
if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store 2> /dev/null); then
|
||||
# Maybe the build directory is symlinked.
|
||||
export NIX_IGNORE_SYMLINK_STORE=1
|
||||
NIX_STORE_DIR=$TEST_ROOT/store
|
||||
fi
|
||||
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
|
||||
export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
|
||||
export NIX_STATE_DIR=$TEST_ROOT/var/nix
|
||||
export NIX_CONF_DIR=$TEST_ROOT/etc
|
||||
export NIX_DAEMON_SOCKET_PATH=$TEST_ROOT/dSocket
|
||||
unset NIX_USER_CONF_FILES
|
||||
export _NIX_TEST_SHARED=$TEST_ROOT/shared
|
||||
if [[ -n $NIX_STORE ]]; then
|
||||
export _NIX_TEST_NO_SANDBOX=1
|
||||
fi
|
||||
export _NIX_IN_TEST=$TEST_ROOT/shared
|
||||
export _NIX_TEST_NO_LSOF=1
|
||||
export NIX_REMOTE=${NIX_REMOTE_-}
|
||||
unset NIX_PATH
|
||||
export TEST_HOME=$TEST_ROOT/test-home
|
||||
|
||||
if ! isTestOnNixOS; then
|
||||
export NIX_STORE_DIR
|
||||
if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store 2> /dev/null); then
|
||||
# Maybe the build directory is symlinked.
|
||||
export NIX_IGNORE_SYMLINK_STORE=1
|
||||
NIX_STORE_DIR=$TEST_ROOT/store
|
||||
fi
|
||||
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
|
||||
export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
|
||||
export NIX_STATE_DIR=$TEST_ROOT/var/nix
|
||||
export NIX_CONF_DIR=$test_nix_conf_dir
|
||||
export NIX_DAEMON_SOCKET_PATH=$TEST_ROOT/dSocket
|
||||
unset NIX_USER_CONF_FILES
|
||||
export _NIX_TEST_SHARED=$TEST_ROOT/shared
|
||||
if [[ -n $NIX_STORE ]]; then
|
||||
export _NIX_TEST_NO_SANDBOX=1
|
||||
fi
|
||||
export _NIX_IN_TEST=$TEST_ROOT/shared
|
||||
export _NIX_TEST_NO_LSOF=1
|
||||
export NIX_REMOTE=${NIX_REMOTE_-}
|
||||
|
||||
fi # ! isTestOnNixOS
|
||||
|
||||
unset NIX_PATH
|
||||
export HOME=$TEST_HOME
|
||||
unset XDG_STATE_HOME
|
||||
unset XDG_DATA_HOME
|
||||
|
@ -43,14 +62,6 @@ unset XDG_CONFIG_HOME
|
|||
unset XDG_CONFIG_DIRS
|
||||
unset XDG_CACHE_HOME
|
||||
|
||||
if [[ -n "${NIX_CLIENT_PACKAGE:-}" ]]; then
|
||||
export PATH="$NIX_CLIENT_PACKAGE/bin":$PATH
|
||||
fi
|
||||
DAEMON_PATH="$PATH"
|
||||
if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
|
||||
DAEMON_PATH="${NIX_DAEMON_PACKAGE}/bin:$DAEMON_PATH"
|
||||
fi
|
||||
|
||||
export IMPURE_VAR1=foo
|
||||
export IMPURE_VAR2=bar
|
||||
|
||||
|
@ -65,7 +76,25 @@ clearProfiles() {
|
|||
rm -rf "$profiles"
|
||||
}
|
||||
|
||||
# Clear the store, but do not fail if we're in an environment where we can't.
|
||||
# This allows the test to run in a NixOS test environment, where we use the system store.
|
||||
# See doc/manual/src/contributing/testing.md / Running functional tests on NixOS.
|
||||
clearStoreIfPossible() {
|
||||
if isTestOnNixOS; then
|
||||
echo "clearStoreIfPossible: Not clearing store, because we're on NixOS. Moving on."
|
||||
else
|
||||
doClearStore
|
||||
fi
|
||||
}
|
||||
|
||||
clearStore() {
|
||||
if isTestOnNixOS; then
|
||||
die "clearStore: not supported when testing on NixOS. If not essential, call clearStoreIfPossible. If really needed, add conditionals; e.g. if ! isTestOnNixOS; then ..."
|
||||
fi
|
||||
doClearStore
|
||||
}
|
||||
|
||||
doClearStore() {
|
||||
echo "clearing store..."
|
||||
chmod -R +w "$NIX_STORE_DIR"
|
||||
rm -rf "$NIX_STORE_DIR"
|
||||
|
@ -84,6 +113,10 @@ clearCacheCache() {
|
|||
}
|
||||
|
||||
startDaemon() {
|
||||
if isTestOnNixOS; then
|
||||
die "startDaemon: not supported when testing on NixOS. Is it really needed? If so add conditionals; e.g. if ! isTestOnNixOS; then ..."
|
||||
fi
|
||||
|
||||
# Don’t start the daemon twice, as this would just make it loop indefinitely
|
||||
if [[ "${_NIX_TEST_DAEMON_PID-}" != '' ]]; then
|
||||
return
|
||||
|
@ -110,6 +143,10 @@ startDaemon() {
|
|||
}
|
||||
|
||||
killDaemon() {
|
||||
if isTestOnNixOS; then
|
||||
die "killDaemon: not supported when testing on NixOS. Is it really needed? If so add conditionals; e.g. if ! isTestOnNixOS; then ..."
|
||||
fi
|
||||
|
||||
# Don’t fail trying to stop a non-existant daemon twice
|
||||
if [[ "${_NIX_TEST_DAEMON_PID-}" == '' ]]; then
|
||||
return
|
||||
|
@ -130,6 +167,10 @@ killDaemon() {
|
|||
}
|
||||
|
||||
restartDaemon() {
|
||||
if isTestOnNixOS; then
|
||||
die "restartDaemon: not supported when testing on NixOS. Is it really needed? If so add conditionals; e.g. if ! isTestOnNixOS; then ..."
|
||||
fi
|
||||
|
||||
[[ -z "${_NIX_TEST_DAEMON_PID:-}" ]] && return 0
|
||||
|
||||
killDaemon
|
||||
|
@ -152,6 +193,12 @@ skipTest () {
|
|||
exit 99
|
||||
}
|
||||
|
||||
TODO_NixOS() {
|
||||
if isTestOnNixOS; then
|
||||
skipTest "This test has not been adapted for NixOS yet"
|
||||
fi
|
||||
}
|
||||
|
||||
requireDaemonNewerThan () {
|
||||
isDaemonNewer "$1" || skipTest "Daemon is too old"
|
||||
}
|
||||
|
@ -169,7 +216,7 @@ requireGit() {
|
|||
}
|
||||
|
||||
fail() {
|
||||
echo "$1" >&2
|
||||
echo "test failed: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -234,7 +281,7 @@ buggyNeedLocalStore() {
|
|||
|
||||
enableFeatures() {
|
||||
local features="$1"
|
||||
sed -i 's/experimental-features .*/& '"$features"'/' "$NIX_CONF_DIR"/nix.conf
|
||||
sed -i 's/experimental-features .*/& '"$features"'/' "$test_nix_conf_dir"/nix.conf
|
||||
}
|
||||
|
||||
set -x
|
||||
|
|
|
@ -2,23 +2,23 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
clearCache
|
||||
|
||||
outPath=$(nix-build dependencies.nix --no-out-link)
|
||||
|
||||
cacheURI="file://$cacheDir?compression=xz&compression-level=0"
|
||||
|
||||
nix copy --to $cacheURI $outPath
|
||||
nix copy --to "$cacheURI" "$outPath"
|
||||
|
||||
FILESIZES=$(cat ${cacheDir}/*.narinfo | awk '/FileSize: /{sum+=$2}END{print sum}')
|
||||
FILESIZES=$(cat "${cacheDir}"/*.narinfo | awk '/FileSize: /{sum+=$2}END{print sum}')
|
||||
|
||||
clearCache
|
||||
|
||||
cacheURI="file://$cacheDir?compression=xz&compression-level=5"
|
||||
|
||||
nix copy --to $cacheURI $outPath
|
||||
nix copy --to "$cacheURI" "$outPath"
|
||||
|
||||
FILESIZES2=$(cat ${cacheDir}/*.narinfo | awk '/FileSize: /{sum+=$2}END{print sum}')
|
||||
FILESIZES2=$(cat "${cacheDir}"/*.narinfo | awk '/FileSize: /{sum+=$2}END{print sum}')
|
||||
|
||||
[[ $FILESIZES -gt $FILESIZES2 ]]
|
||||
|
|
|
@ -28,6 +28,8 @@ nix registry remove userhome-with-xdg
|
|||
# Assert the .config folder hasn't been created.
|
||||
[ ! -e "$HOME/.config" ]
|
||||
|
||||
TODO_NixOS # Very specific test setup not compatible with the NixOS test environment?
|
||||
|
||||
# Test that files are loaded from XDG by default
|
||||
export XDG_CONFIG_HOME=$TEST_ROOT/confighome
|
||||
export XDG_CONFIG_DIRS=$TEST_ROOT/dir1:$TEST_ROOT/dir2
|
||||
|
|
|
@ -10,6 +10,8 @@ if [[ -z "${NIX_DAEMON_PACKAGE-}" ]]; then
|
|||
skipTest "not using the Nix daemon"
|
||||
fi
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
killDaemon
|
||||
|
||||
# Fill the db using the older Nix
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
# regression #9932
|
||||
echo ":env" | expect 1 nix eval --debugger --expr '(_: throw "oh snap") 42'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
drvPath=$(nix-instantiate dependencies.nix)
|
||||
|
||||
|
@ -33,7 +33,7 @@ nix-store -q --tree "$outPath" | grep '───.*dependencies-input-2'
|
|||
|
||||
echo "output path is $outPath"
|
||||
|
||||
text=$(cat "$outPath"/foobar)
|
||||
text=$(cat "$outPath/foobar")
|
||||
if test "$text" != "FOOBAR"; then exit 1; fi
|
||||
|
||||
deps=$(nix-store -quR "$drvPath")
|
||||
|
@ -65,6 +65,8 @@ drvPath2=$(nix-instantiate dependencies.nix --argstr hashInvalidator yay)
|
|||
# now --valid-derivers returns both
|
||||
test "$(nix-store -q --valid-derivers "$outPath" | sort)" = "$(sort <<< "$drvPath"$'\n'"$drvPath2")"
|
||||
|
||||
TODO_NixOS # The following --delete fails, because it seems to be still alive. This might be caused by a different test using the same path. We should try make the derivations unique, e.g. naming after tests, and adding a timestamp that's constant for that test script run.
|
||||
|
||||
# check that nix-store --valid-derivers only returns existing drv
|
||||
nix-store --delete "$drvPath"
|
||||
test "$(nix-store -q --valid-derivers "$outPath")" = "$drvPath2"
|
||||
|
|
23
tests/functional/derivation-advanced-attributes.sh
Executable file
23
tests/functional/derivation-advanced-attributes.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source common/test-root.sh
|
||||
source common/paths.sh
|
||||
|
||||
set -o pipefail
|
||||
|
||||
source characterisation/framework.sh
|
||||
|
||||
badDiff=0
|
||||
badExitCode=0
|
||||
|
||||
store="$TEST_ROOT/store"
|
||||
|
||||
for nixFile in derivation/*.nix; do
|
||||
drvPath=$(nix-instantiate --store "$store" --pure-eval --expr "$(< "$nixFile")")
|
||||
testName=$(basename "$nixFile" .nix)
|
||||
got="${store}${drvPath}"
|
||||
expected="derivation/$testName.drv"
|
||||
diffAndAcceptInner "$testName" "$got" "$expected"
|
||||
done
|
||||
|
||||
characterisationTestExit
|
|
@ -4,11 +4,11 @@ source common.sh
|
|||
|
||||
drvPath=$(nix-instantiate simple.nix)
|
||||
|
||||
nix derivation show $drvPath | jq .[] > $TEST_HOME/simple.json
|
||||
nix derivation show "$drvPath" | jq .[] > "$TEST_HOME"/simple.json
|
||||
|
||||
drvPath2=$(nix derivation add < $TEST_HOME/simple.json)
|
||||
drvPath2=$(nix derivation add < "$TEST_HOME"/simple.json)
|
||||
|
||||
[[ "$drvPath" = "$drvPath2" ]]
|
||||
|
||||
# Input addressed derivations cannot be renamed.
|
||||
jq '.name = "foo"' < $TEST_HOME/simple.json | expectStderr 1 nix derivation add | grepQuiet "has incorrect output"
|
||||
jq '.name = "foo"' < "$TEST_HOME"/simple.json | expectStderr 1 nix derivation add | grepQuiet "has incorrect output"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Derive([("out","/nix/store/1qsc7svv43m4dw2prh6mvyf7cai5czji-advanced-attributes-defaults","","")],[],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("builder","/bin/bash"),("name","advanced-attributes-defaults"),("out","/nix/store/1qsc7svv43m4dw2prh6mvyf7cai5czji-advanced-attributes-defaults"),("system","my-system")])
|
|
@ -0,0 +1,6 @@
|
|||
derivation {
|
||||
name = "advanced-attributes-defaults";
|
||||
system = "my-system";
|
||||
builder = "/bin/bash";
|
||||
args = [ "-c" "echo hello > $out" ];
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Derive([("dev","/nix/store/8bazivnbipbyi569623skw5zm91z6kc2-advanced-attributes-structured-attrs-defaults-dev","",""),("out","/nix/store/f8f8nvnx32bxvyxyx2ff7akbvwhwd9dw-advanced-attributes-structured-attrs-defaults","","")],[],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__json","{\"builder\":\"/bin/bash\",\"name\":\"advanced-attributes-structured-attrs-defaults\",\"outputs\":[\"out\",\"dev\"],\"system\":\"my-system\"}"),("dev","/nix/store/8bazivnbipbyi569623skw5zm91z6kc2-advanced-attributes-structured-attrs-defaults-dev"),("out","/nix/store/f8f8nvnx32bxvyxyx2ff7akbvwhwd9dw-advanced-attributes-structured-attrs-defaults")])
|
|
@ -0,0 +1,8 @@
|
|||
derivation {
|
||||
name = "advanced-attributes-structured-attrs-defaults";
|
||||
system = "my-system";
|
||||
builder = "/bin/bash";
|
||||
args = [ "-c" "echo hello > $out" ];
|
||||
outputs = [ "out" "dev" ];
|
||||
__structuredAttrs = true;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Derive([("bin","/nix/store/pbzb48v0ycf80jgligcp4n8z0rblna4n-advanced-attributes-structured-attrs-bin","",""),("dev","/nix/store/7xapi8jv7flcz1qq8jhw55ar8ag8hldh-advanced-attributes-structured-attrs-dev","",""),("out","/nix/store/mpq3l1l1qc2yr50q520g08kprprwv79f-advanced-attributes-structured-attrs","","")],[("/nix/store/4xm4wccqsvagz9gjksn24s7rip2fdy7v-foo.drv",["out"]),("/nix/store/plsq5jbr5nhgqwcgb2qxw7jchc09dnl8-bar.drv",["out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__json","{\"__darwinAllowLocalNetworking\":true,\"__impureHostDeps\":[\"/usr/bin/ditto\"],\"__noChroot\":true,\"__sandboxProfile\":\"sandcastle\",\"allowSubstitutes\":false,\"builder\":\"/bin/bash\",\"impureEnvVars\":[\"UNICORN\"],\"name\":\"advanced-attributes-structured-attrs\",\"outputChecks\":{\"bin\":{\"disallowedReferences\":[\"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar\"],\"disallowedRequisites\":[\"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo\"],\"allowedRequisites\":[\"/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo\"]}},\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}"),("bin","/nix/store/pbzb48v0ycf80jgligcp4n8z0rblna4n-advanced-attributes-structured-attrs-bin"),("dev","/nix/store/7xapi8jv7flcz1qq8jhw55ar8ag8hldh-advanced-attributes-structured-attrs-dev"),("out","/nix/store/mpq3l1l1qc2yr50q520g08kprprwv79f-advanced-attributes-structured-attrs")])
|
|
@ -0,0 +1,45 @@
|
|||
let
|
||||
system = "my-system";
|
||||
foo = derivation {
|
||||
inherit system;
|
||||
name = "foo";
|
||||
builder = "/bin/bash";
|
||||
args = ["-c" "echo foo > $out"];
|
||||
};
|
||||
bar = derivation {
|
||||
inherit system;
|
||||
name = "bar";
|
||||
builder = "/bin/bash";
|
||||
args = ["-c" "echo bar > $out"];
|
||||
};
|
||||
in
|
||||
derivation {
|
||||
inherit system;
|
||||
name = "advanced-attributes-structured-attrs";
|
||||
builder = "/bin/bash";
|
||||
args = [ "-c" "echo hello > $out" ];
|
||||
__sandboxProfile = "sandcastle";
|
||||
__noChroot = true;
|
||||
__impureHostDeps = ["/usr/bin/ditto"];
|
||||
impureEnvVars = ["UNICORN"];
|
||||
__darwinAllowLocalNetworking = true;
|
||||
outputs = [ "out" "bin" "dev" ];
|
||||
__structuredAttrs = true;
|
||||
outputChecks = {
|
||||
out = {
|
||||
allowedReferences = [foo];
|
||||
allowedRequisites = [foo];
|
||||
};
|
||||
bin = {
|
||||
disallowedReferences = [bar];
|
||||
disallowedRequisites = [bar];
|
||||
};
|
||||
dev = {
|
||||
maxSize = 789;
|
||||
maxClosureSize = 5909;
|
||||
};
|
||||
};
|
||||
requiredSystemFeatures = ["rainbow" "uid-range"];
|
||||
preferLocalBuild = true;
|
||||
allowSubstitutes = false;
|
||||
}
|
1
tests/functional/derivation/advanced-attributes.drv
Normal file
1
tests/functional/derivation/advanced-attributes.drv
Normal file
|
@ -0,0 +1 @@
|
|||
Derive([("out","/nix/store/33a6fdmn8q9ih9d7npbnrxn2q56a4l8q-advanced-attributes","","")],[("/nix/store/4xm4wccqsvagz9gjksn24s7rip2fdy7v-foo.drv",["out"]),("/nix/store/plsq5jbr5nhgqwcgb2qxw7jchc09dnl8-bar.drv",["out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__darwinAllowLocalNetworking","1"),("__impureHostDeps","/usr/bin/ditto"),("__noChroot","1"),("__sandboxProfile","sandcastle"),("allowSubstitutes",""),("allowedReferences","/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo"),("allowedRequisites","/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo"),("builder","/bin/bash"),("disallowedReferences","/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"),("disallowedRequisites","/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"),("impureEnvVars","UNICORN"),("name","advanced-attributes"),("out","/nix/store/33a6fdmn8q9ih9d7npbnrxn2q56a4l8q-advanced-attributes"),("preferLocalBuild","1"),("requiredSystemFeatures","rainbow uid-range"),("system","my-system")])
|
33
tests/functional/derivation/advanced-attributes.nix
Normal file
33
tests/functional/derivation/advanced-attributes.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
let
|
||||
system = "my-system";
|
||||
foo = derivation {
|
||||
inherit system;
|
||||
name = "foo";
|
||||
builder = "/bin/bash";
|
||||
args = ["-c" "echo foo > $out"];
|
||||
};
|
||||
bar = derivation {
|
||||
inherit system;
|
||||
name = "bar";
|
||||
builder = "/bin/bash";
|
||||
args = ["-c" "echo bar > $out"];
|
||||
};
|
||||
in
|
||||
derivation {
|
||||
inherit system;
|
||||
name = "advanced-attributes";
|
||||
builder = "/bin/bash";
|
||||
args = [ "-c" "echo hello > $out" ];
|
||||
__sandboxProfile = "sandcastle";
|
||||
__noChroot = true;
|
||||
__impureHostDeps = ["/usr/bin/ditto"];
|
||||
impureEnvVars = ["UNICORN"];
|
||||
__darwinAllowLocalNetworking = true;
|
||||
allowedReferences = [foo];
|
||||
allowedRequisites = [foo];
|
||||
disallowedReferences = [bar];
|
||||
disallowedRequisites = [bar];
|
||||
requiredSystemFeatures = ["rainbow" "uid-range"];
|
||||
preferLocalBuild = true;
|
||||
allowSubstitutes = false;
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
needLocalStore "--dump-db requires a local store"
|
||||
|
||||
clearStore
|
||||
|
|
|
@ -5,4 +5,6 @@ requireDaemonNewerThan "2.16.0pre20230419"
|
|||
|
||||
enableFeatures "ca-derivations dynamic-derivations"
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
restartDaemon
|
||||
|
|
|
@ -20,7 +20,7 @@ nix show-derivation "$drvProducingDrv"
|
|||
|
||||
out1=$(nix-build ./text-hashed-output.nix -A producingDrv --no-out-link)
|
||||
|
||||
nix path-info $drv --derivation --json | jq
|
||||
nix path-info $out1 --derivation --json | jq
|
||||
nix path-info "$drv" --derivation --json | jq
|
||||
nix path-info "$out1" --derivation --json | jq
|
||||
|
||||
test $out1 == $drv
|
||||
test "$out1" == "$drv"
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
# Using `--eval-store` with the daemon will eventually copy everything
|
||||
# to the build store, invalidating most of the tests here
|
||||
needLocalStore "“--eval-store” doesn't achieve much with the daemon"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
testStdinHeredoc=$(nix eval -f - <<EOF
|
||||
{
|
||||
|
|
|
@ -33,35 +33,35 @@ source common.sh
|
|||
NIX_CONFIG='
|
||||
experimental-features = nix-command
|
||||
accept-flake-config = true
|
||||
' expect 1 nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
|
||||
[[ $(cat $TEST_ROOT/stdout) = '' ]]
|
||||
grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" $TEST_ROOT/stderr
|
||||
grepQuiet "error: could not find setting 'accept-flake-config'" $TEST_ROOT/stderr
|
||||
' expect 1 nix config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
||||
[[ $(cat "$TEST_ROOT/stdout") = '' ]]
|
||||
grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" "$TEST_ROOT/stderr"
|
||||
grepQuiet "error: could not find setting 'accept-flake-config'" "$TEST_ROOT/stderr"
|
||||
|
||||
# 'flakes' experimental-feature is disabled after, ignore and warn
|
||||
NIX_CONFIG='
|
||||
accept-flake-config = true
|
||||
experimental-features = nix-command
|
||||
' expect 1 nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
|
||||
[[ $(cat $TEST_ROOT/stdout) = '' ]]
|
||||
grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" $TEST_ROOT/stderr
|
||||
grepQuiet "error: could not find setting 'accept-flake-config'" $TEST_ROOT/stderr
|
||||
' expect 1 nix config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
||||
[[ $(cat "$TEST_ROOT/stdout") = '' ]]
|
||||
grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" "$TEST_ROOT/stderr"
|
||||
grepQuiet "error: could not find setting 'accept-flake-config'" "$TEST_ROOT/stderr"
|
||||
|
||||
# 'flakes' experimental-feature is enabled before, process
|
||||
NIX_CONFIG='
|
||||
experimental-features = nix-command flakes
|
||||
accept-flake-config = true
|
||||
' nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
|
||||
grepQuiet "true" $TEST_ROOT/stdout
|
||||
grepQuietInverse "Ignoring setting 'accept-flake-config'" $TEST_ROOT/stderr
|
||||
' nix config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
||||
grepQuiet "true" "$TEST_ROOT/stdout"
|
||||
grepQuietInverse "Ignoring setting 'accept-flake-config'" "$TEST_ROOT/stderr"
|
||||
|
||||
# 'flakes' experimental-feature is enabled after, process
|
||||
NIX_CONFIG='
|
||||
accept-flake-config = true
|
||||
experimental-features = nix-command flakes
|
||||
' nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
|
||||
grepQuiet "true" $TEST_ROOT/stdout
|
||||
grepQuietInverse "Ignoring setting 'accept-flake-config'" $TEST_ROOT/stderr
|
||||
' nix config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
|
||||
grepQuiet "true" "$TEST_ROOT/stdout"
|
||||
grepQuietInverse "Ignoring setting 'accept-flake-config'" "$TEST_ROOT/stderr"
|
||||
|
||||
function exit_code_both_ways {
|
||||
expect 1 nix --experimental-features 'nix-command' "$@" 1>/dev/null
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
clearProfiles
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
outPath=$(nix-build dependencies.nix --no-out-link)
|
||||
|
|
|
@ -4,6 +4,8 @@ source common.sh
|
|||
|
||||
enableFeatures "fetch-closure"
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ source common.sh
|
|||
|
||||
requireGit
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
# Intentionally not in a canonical form
|
||||
# See https://github.com/NixOS/nix/issues/6195
|
||||
|
|
|
@ -4,7 +4,7 @@ source common.sh
|
|||
|
||||
requireGit
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
repo="$TEST_ROOT/git"
|
||||
|
||||
|
@ -14,7 +14,7 @@ git init "$repo"
|
|||
git -C "$repo" config user.email "foobar@example.com"
|
||||
git -C "$repo" config user.name "Foobar"
|
||||
|
||||
echo utrecht > "$repo"/hello
|
||||
echo utrecht > "$repo/hello"
|
||||
git -C "$repo" add hello
|
||||
git -C "$repo" commit -m 'Bla1'
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ set -u
|
|||
|
||||
requireGit
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
rootRepo=$TEST_ROOT/gitSubmodulesRoot
|
||||
subRepo=$TEST_ROOT/gitSubmodulesSub
|
||||
|
|
|
@ -7,7 +7,7 @@ requireGit
|
|||
|
||||
enableFeatures "verified-fetches"
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
repo="$TEST_ROOT/git"
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ source common.sh
|
|||
|
||||
[[ $(type -p hg) ]] || skipTest "Mercurial not installed"
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
# Intentionally not in a canonical form
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
touch $TEST_ROOT/foo -t 202211111111
|
||||
touch "$TEST_ROOT/foo" -t 202211111111
|
||||
# We only check whether 2022-11-1* **:**:** is the last modified date since
|
||||
# `lastModified` is transformed into UTC in `builtins.fetchTarball`.
|
||||
[[ "$(nix eval --impure --raw --expr "(builtins.fetchTree \"path://$TEST_ROOT/foo\").lastModifiedDate")" =~ 2022111.* ]]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
cd "$TEST_ROOT"
|
||||
|
@ -90,7 +92,7 @@ EOF
|
|||
EOF
|
||||
|
||||
# Test tarball URLs on the command line.
|
||||
[[ $(nix flake metadata --json file://$PWD/test_input_no_ext | jq -r .resolved.type) = tarball ]]
|
||||
[[ $(nix flake metadata --json "file://$PWD/test_input_no_ext" | jq -r .resolved.type) = tarball ]]
|
||||
|
||||
popd
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
# Test fetching a flat file.
|
||||
|
|
|
@ -2,26 +2,26 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
rm -rf $TEST_ROOT/filterin
|
||||
mkdir $TEST_ROOT/filterin
|
||||
mkdir $TEST_ROOT/filterin/foo
|
||||
touch $TEST_ROOT/filterin/foo/bar
|
||||
touch $TEST_ROOT/filterin/xyzzy
|
||||
touch $TEST_ROOT/filterin/b
|
||||
touch $TEST_ROOT/filterin/bak
|
||||
touch $TEST_ROOT/filterin/bla.c.bak
|
||||
ln -s xyzzy $TEST_ROOT/filterin/link
|
||||
rm -rf "$TEST_ROOT/filterin"
|
||||
mkdir "$TEST_ROOT/filterin"
|
||||
mkdir "$TEST_ROOT/filterin/foo"
|
||||
touch "$TEST_ROOT/filterin/foo/bar"
|
||||
touch "$TEST_ROOT/filterin/xyzzy"
|
||||
touch "$TEST_ROOT/filterin/b"
|
||||
touch "$TEST_ROOT/filterin/bak"
|
||||
touch "$TEST_ROOT"/filterin/bla.c.bak
|
||||
ln -s xyzzy "$TEST_ROOT/filterin/link"
|
||||
|
||||
checkFilter() {
|
||||
test ! -e $1/foo/bar
|
||||
test -e $1/xyzzy
|
||||
test -e $1/bak
|
||||
test ! -e $1/bla.c.bak
|
||||
test ! -L $1/link
|
||||
test ! -e "$1/foo/bar"
|
||||
test -e "$1/xyzzy"
|
||||
test -e "$1/bak"
|
||||
test ! -e "$1"/bla.c.bak
|
||||
test ! -L "$1/link"
|
||||
}
|
||||
|
||||
nix-build ./filter-source.nix -o $TEST_ROOT/filterout1
|
||||
checkFilter $TEST_ROOT/filterout1
|
||||
nix-build ./filter-source.nix -o "$TEST_ROOT/filterout1"
|
||||
checkFilter "$TEST_ROOT/filterout1"
|
||||
|
||||
nix-build ./path.nix -o $TEST_ROOT/filterout2
|
||||
checkFilter $TEST_ROOT/filterout2
|
||||
nix-build ./path.nix -o "$TEST_ROOT/filterout2"
|
||||
checkFilter "$TEST_ROOT/filterout2"
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
path=$(nix-store -q $(nix-instantiate fixed.nix -A good.0))
|
||||
|
|
|
@ -4,8 +4,8 @@ source ./common.sh
|
|||
|
||||
flake1Dir=$TEST_ROOT/flake1
|
||||
|
||||
mkdir -p $flake1Dir
|
||||
cat > $flake1Dir/flake.nix <<EOF
|
||||
mkdir -p "$flake1Dir"
|
||||
cat > "$flake1Dir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
x = 1;
|
||||
|
@ -14,6 +14,6 @@ cat > $flake1Dir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
[ "$(nix eval --impure --json $flake1Dir#.x)" -eq 1 ]
|
||||
[ "$(nix eval --impure --json $flake1Dir#x)" -eq 2 ]
|
||||
[ "$(nix eval --impure --json $flake1Dir#.packages.$system.x)" -eq 2 ]
|
||||
[ "$(nix eval --impure --json "$flake1Dir"#.x)" -eq 1 ]
|
||||
[ "$(nix eval --impure --json "$flake1Dir#x")" -eq 2 ]
|
||||
[ "$(nix eval --impure --json "$flake1Dir"#.packages."$system".x)" -eq 2 ]
|
||||
|
|
|
@ -5,15 +5,15 @@ source ./common.sh
|
|||
flake1Dir=$TEST_ROOT/flake1
|
||||
flake2Dir=$TEST_ROOT/flake2
|
||||
|
||||
mkdir -p $flake1Dir $flake2Dir
|
||||
mkdir -p "$flake1Dir" "$flake2Dir"
|
||||
|
||||
writeSimpleFlake $flake2Dir
|
||||
tar cfz $TEST_ROOT/flake.tar.gz -C $TEST_ROOT flake2
|
||||
hash=$(nix hash path $flake2Dir)
|
||||
writeSimpleFlake "$flake2Dir"
|
||||
tar cfz "$TEST_ROOT"/flake.tar.gz -C "$TEST_ROOT" flake2
|
||||
hash=$(nix hash path "$flake2Dir")
|
||||
|
||||
dep=$(nix store add-path ./common.sh)
|
||||
|
||||
cat > $flake1Dir/flake.nix <<EOF
|
||||
cat > "$flake1Dir"/flake.nix <<EOF
|
||||
{
|
||||
inputs.flake2.url = "file://$TEST_ROOT/flake.tar.gz";
|
||||
|
||||
|
@ -79,43 +79,43 @@ cat > $flake1Dir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
cp ../simple.nix ../simple.builder.sh ../config.nix $flake1Dir/
|
||||
cp ../simple.nix ../simple.builder.sh ../config.nix "$flake1Dir/"
|
||||
|
||||
echo bar > $flake1Dir/foo
|
||||
echo bar > "$flake1Dir/foo"
|
||||
|
||||
nix build --json --out-link $TEST_ROOT/result $flake1Dir#a1
|
||||
nix build --json --out-link "$TEST_ROOT/result" "$flake1Dir#a1"
|
||||
[[ -e $TEST_ROOT/result/simple.nix ]]
|
||||
|
||||
nix build --json --out-link $TEST_ROOT/result $flake1Dir#a2
|
||||
[[ $(cat $TEST_ROOT/result) = bar ]]
|
||||
nix build --json --out-link "$TEST_ROOT/result" "$flake1Dir#a2"
|
||||
[[ $(cat "$TEST_ROOT/result") = bar ]]
|
||||
|
||||
nix build --json --out-link $TEST_ROOT/result $flake1Dir#a3
|
||||
nix build --json --out-link "$TEST_ROOT/result" "$flake1Dir#a3"
|
||||
|
||||
nix build --json --out-link $TEST_ROOT/result $flake1Dir#a4
|
||||
nix build --json --out-link "$TEST_ROOT/result" "$flake1Dir#a4"
|
||||
|
||||
nix build --json --out-link $TEST_ROOT/result $flake1Dir#a6
|
||||
nix build --json --out-link "$TEST_ROOT/result" "$flake1Dir#a6"
|
||||
[[ -e $TEST_ROOT/result/simple.nix ]]
|
||||
|
||||
nix build --impure --json --out-link $TEST_ROOT/result $flake1Dir#a8
|
||||
diff common.sh $TEST_ROOT/result
|
||||
nix build --impure --json --out-link "$TEST_ROOT/result" "$flake1Dir#a8"
|
||||
diff common.sh "$TEST_ROOT/result"
|
||||
|
||||
expectStderr 1 nix build --impure --json --out-link $TEST_ROOT/result $flake1Dir#a9 \
|
||||
expectStderr 1 nix build --impure --json --out-link "$TEST_ROOT/result" "$flake1Dir#a9" \
|
||||
| grepQuiet "has 0 entries in its context. It should only have exactly one entry"
|
||||
|
||||
nix build --json --out-link $TEST_ROOT/result $flake1Dir#a10
|
||||
[[ $(readlink -e $TEST_ROOT/result) = *simple.drv ]]
|
||||
nix build --json --out-link "$TEST_ROOT/result" "$flake1Dir"#a10
|
||||
[[ $(readlink -e "$TEST_ROOT/result") = *simple.drv ]]
|
||||
|
||||
expectStderr 1 nix build --json --out-link $TEST_ROOT/result $flake1Dir#a11 \
|
||||
expectStderr 1 nix build --json --out-link "$TEST_ROOT/result" "$flake1Dir#a11" \
|
||||
| grepQuiet "has a context which refers to a complete source and binary closure"
|
||||
|
||||
nix build --json --out-link $TEST_ROOT/result $flake1Dir#a12
|
||||
nix build --json --out-link "$TEST_ROOT/result" "$flake1Dir#a12"
|
||||
[[ -e $TEST_ROOT/result/hello ]]
|
||||
|
||||
expectStderr 1 nix build --impure --json --out-link $TEST_ROOT/result $flake1Dir#a13 \
|
||||
expectStderr 1 nix build --impure --json --out-link "$TEST_ROOT/result" "$flake1Dir#a13" \
|
||||
| grepQuiet "has 2 entries in its context. It should only have exactly one entry"
|
||||
|
||||
# Test accessing output in installables with `.` (foobarbaz.<output>)
|
||||
nix build --json --no-link $flake1Dir#a14.foo | jq --exit-status '
|
||||
nix build --json --no-link "$flake1Dir"#a14.foo | jq --exit-status '
|
||||
(.[0] |
|
||||
(.drvPath | match(".*dot-installable.drv")) and
|
||||
(.outputs | keys == ["foo"]))
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
cp ../simple.nix ../simple.builder.sh ../config.nix $TEST_HOME
|
||||
cp ../simple.nix ../simple.builder.sh ../config.nix "$TEST_HOME"
|
||||
|
||||
cd $TEST_HOME
|
||||
cd "$TEST_HOME"
|
||||
|
||||
cat <<EOF > flake.nix
|
||||
{
|
||||
|
@ -27,8 +27,8 @@ EOF
|
|||
|
||||
nix build .#
|
||||
nix bundle --bundler .# .#
|
||||
nix bundle --bundler .#bundlers.$system.default .#packages.$system.default
|
||||
nix bundle --bundler .#bundlers.$system.simple .#packages.$system.default
|
||||
nix bundle --bundler .#bundlers."$system".default .#packages."$system".default
|
||||
nix bundle --bundler .#bundlers."$system".simple .#packages."$system".default
|
||||
|
||||
nix bundle --bundler .#bundlers.$system.default .#apps.$system.default
|
||||
nix bundle --bundler .#bundlers.$system.simple .#apps.$system.default
|
||||
nix bundle --bundler .#bundlers."$system".default .#apps."$system".default
|
||||
nix bundle --bundler .#bundlers."$system".simple .#apps."$system".default
|
||||
|
|
|
@ -8,10 +8,10 @@ requireGit
|
|||
flakeA=$TEST_ROOT/flakeA
|
||||
flakeB=$TEST_ROOT/flakeB
|
||||
|
||||
createGitRepo $flakeA
|
||||
createGitRepo $flakeB
|
||||
createGitRepo "$flakeA"
|
||||
createGitRepo "$flakeB"
|
||||
|
||||
cat > $flakeA/flake.nix <<EOF
|
||||
cat > "$flakeA"/flake.nix <<EOF
|
||||
{
|
||||
inputs.b.url = git+file://$flakeB;
|
||||
inputs.b.inputs.a.follows = "/";
|
||||
|
@ -23,9 +23,9 @@ cat > $flakeA/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
git -C $flakeA add flake.nix
|
||||
git -C "$flakeA" add flake.nix
|
||||
|
||||
cat > $flakeB/flake.nix <<EOF
|
||||
cat > "$flakeB"/flake.nix <<EOF
|
||||
{
|
||||
inputs.a.url = git+file://$flakeA;
|
||||
|
||||
|
@ -35,18 +35,18 @@ cat > $flakeB/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
git -C $flakeB add flake.nix
|
||||
git -C $flakeB commit -a -m 'Foo'
|
||||
git -C "$flakeB" add flake.nix
|
||||
git -C "$flakeB" commit -a -m 'Foo'
|
||||
|
||||
[[ $(nix eval $flakeA#foo) = 1579 ]]
|
||||
[[ $(nix eval $flakeA#foo) = 1579 ]]
|
||||
[[ $(nix eval "$flakeA#foo") = 1579 ]]
|
||||
[[ $(nix eval "$flakeA#foo") = 1579 ]]
|
||||
|
||||
sed -i $flakeB/flake.nix -e 's/456/789/'
|
||||
git -C $flakeB commit -a -m 'Foo'
|
||||
sed -i "$flakeB"/flake.nix -e 's/456/789/'
|
||||
git -C "$flakeB" commit -a -m 'Foo'
|
||||
|
||||
nix flake update b --flake $flakeA
|
||||
[[ $(nix eval $flakeA#foo) = 1912 ]]
|
||||
nix flake update b --flake "$flakeA"
|
||||
[[ $(nix eval "$flakeA#foo") = 1912 ]]
|
||||
|
||||
# Test list-inputs with circular dependencies
|
||||
nix flake metadata $flakeA
|
||||
nix flake metadata "$flakeA"
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ EOF
|
|||
# Without --accept-flake-config, the post hook should not run.
|
||||
nix build < /dev/null
|
||||
(! [[ -f post-hook-ran ]])
|
||||
TODO_NixOS
|
||||
clearStore
|
||||
|
||||
nix build --accept-flake-config
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source ../common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local
|
||||
|
||||
|
|
|
@ -7,12 +7,22 @@ requireGit
|
|||
flake1Dir="$TEST_ROOT/eval-cache-flake"
|
||||
|
||||
createGitRepo "$flake1Dir" ""
|
||||
cp ../simple.nix ../simple.builder.sh ../config.nix "$flake1Dir/"
|
||||
git -C "$flake1Dir" add simple.nix simple.builder.sh config.nix
|
||||
git -C "$flake1Dir" commit -m "config.nix"
|
||||
|
||||
cat >"$flake1Dir/flake.nix" <<EOF
|
||||
{
|
||||
description = "Fnord";
|
||||
outputs = { self }: {
|
||||
outputs = { self }: let inherit (import ./config.nix) mkDerivation; in {
|
||||
foo.bar = throw "breaks";
|
||||
drv = mkDerivation {
|
||||
name = "build";
|
||||
buildCommand = ''
|
||||
echo true > \$out
|
||||
'';
|
||||
};
|
||||
ifd = assert (import self.drv); self.drv;
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
@ -22,3 +32,8 @@ git -C "$flake1Dir" commit -m "Init"
|
|||
|
||||
expect 1 nix build "$flake1Dir#foo.bar" 2>&1 | grepQuiet 'error: breaks'
|
||||
expect 1 nix build "$flake1Dir#foo.bar" 2>&1 | grepQuiet 'error: breaks'
|
||||
|
||||
# Conditional error should not be cached
|
||||
expect 1 nix build "$flake1Dir#ifd" --option allow-import-from-derivation false 2>&1 \
|
||||
| grepQuiet 'error: cannot build .* during evaluation because the option '\''allow-import-from-derivation'\'' is disabled'
|
||||
nix build --no-link "$flake1Dir#ifd"
|
||||
|
|
|
@ -15,6 +15,8 @@ source common.sh
|
|||
|
||||
requireGit
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
# Submodules can't be fetched locally by default.
|
||||
|
@ -27,8 +29,8 @@ rootRepo=$TEST_ROOT/rootRepo
|
|||
subRepo=$TEST_ROOT/submodule
|
||||
|
||||
|
||||
createGitRepo $subRepo
|
||||
cat > $subRepo/flake.nix <<EOF
|
||||
createGitRepo "$subRepo"
|
||||
cat > "$subRepo"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
sub = import ./sub.nix;
|
||||
|
@ -36,28 +38,28 @@ cat > $subRepo/flake.nix <<EOF
|
|||
};
|
||||
}
|
||||
EOF
|
||||
echo '"expression in submodule"' > $subRepo/sub.nix
|
||||
git -C $subRepo add flake.nix sub.nix
|
||||
git -C $subRepo commit -m Initial
|
||||
echo '"expression in submodule"' > "$subRepo"/sub.nix
|
||||
git -C "$subRepo" add flake.nix sub.nix
|
||||
git -C "$subRepo" commit -m Initial
|
||||
|
||||
createGitRepo $rootRepo
|
||||
createGitRepo "$rootRepo"
|
||||
|
||||
git -C $rootRepo submodule init
|
||||
git -C $rootRepo submodule add $subRepo submodule
|
||||
echo '"expression in root repo"' > $rootRepo/root.nix
|
||||
git -C $rootRepo add root.nix
|
||||
git -C $rootRepo commit -m "Add root.nix"
|
||||
git -C "$rootRepo" submodule init
|
||||
git -C "$rootRepo" submodule add "$subRepo" submodule
|
||||
echo '"expression in root repo"' > "$rootRepo"/root.nix
|
||||
git -C "$rootRepo" add root.nix
|
||||
git -C "$rootRepo" commit -m "Add root.nix"
|
||||
|
||||
flakeref=git+file://$rootRepo\?submodules=1\&dir=submodule
|
||||
|
||||
# Flake can live inside a submodule and can be accessed via ?dir=submodule
|
||||
[[ $(nix eval --json $flakeref#sub ) = '"expression in submodule"' ]]
|
||||
[[ $(nix eval --json "$flakeref#sub" ) = '"expression in submodule"' ]]
|
||||
|
||||
# The flake can access content outside of the submodule
|
||||
[[ $(nix eval --json $flakeref#root ) = '"expression in root repo"' ]]
|
||||
[[ $(nix eval --json "$flakeref#root" ) = '"expression in root repo"' ]]
|
||||
|
||||
# Check that dirtying a submodule makes the entire thing dirty.
|
||||
[[ $(nix flake metadata --json $flakeref | jq -r .locked.rev) != null ]]
|
||||
echo '"foo"' > $rootRepo/submodule/sub.nix
|
||||
[[ $(nix eval --json $flakeref#sub ) = '"foo"' ]]
|
||||
[[ $(nix flake metadata --json $flakeref | jq -r .locked.rev) = null ]]
|
||||
[[ $(nix flake metadata --json "$flakeref" | jq -r .locked.rev) != null ]]
|
||||
echo '"foo"' > "$rootRepo"/submodule/sub.nix
|
||||
[[ $(nix eval --json "$flakeref#sub" ) = '"foo"' ]]
|
||||
[[ $(nix flake metadata --json "$flakeref" | jq -r .locked.rev) = null ]]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source ./common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
requireGit
|
||||
|
||||
clearStore
|
||||
|
@ -17,13 +19,17 @@ flake7Dir=$TEST_ROOT/flake7
|
|||
nonFlakeDir=$TEST_ROOT/nonFlake
|
||||
badFlakeDir=$TEST_ROOT/badFlake
|
||||
flakeGitBare=$TEST_ROOT/flakeGitBare
|
||||
lockfileSummaryFlake=$TEST_ROOT/lockfileSummaryFlake
|
||||
|
||||
for repo in "$flake1Dir" "$flake2Dir" "$flake3Dir" "$flake7Dir" "$nonFlakeDir"; do
|
||||
for repo in "$flake1Dir" "$flake2Dir" "$flake3Dir" "$flake7Dir" "$nonFlakeDir" "$lockfileSummaryFlake"; do
|
||||
# Give one repo a non-main initial branch.
|
||||
extraArgs=
|
||||
if [[ "$repo" == "$flake2Dir" ]]; then
|
||||
extraArgs="--initial-branch=main"
|
||||
fi
|
||||
if [[ "$repo" == "$lockfileSummaryFlake" ]]; then
|
||||
extraArgs="--initial-branch=main"
|
||||
fi
|
||||
|
||||
createGitRepo "$repo" "$extraArgs"
|
||||
done
|
||||
|
@ -189,6 +195,7 @@ json=$(nix flake metadata flake1 --json | jq .)
|
|||
[[ -d $(echo "$json" | jq -r .path) ]]
|
||||
[[ $(echo "$json" | jq -r .lastModified) = $(git -C "$flake1Dir" log -n1 --format=%ct) ]]
|
||||
hash1=$(echo "$json" | jq -r .revision)
|
||||
[[ -n $(echo "$json" | jq -r .fingerprint) ]]
|
||||
|
||||
echo foo > "$flake1Dir/foo"
|
||||
git -C "$flake1Dir" add $flake1Dir/foo
|
||||
|
@ -642,3 +649,37 @@ expectStderr 1 nix flake metadata "$flake2Dir" --no-allow-dirty --reference-lock
|
|||
[[ $($nonFlakeDir/shebang-inline-expr.sh baz) = "foo"$'\n'"baz" ]]
|
||||
[[ $($nonFlakeDir/shebang-file.sh baz) = "foo"$'\n'"baz" ]]
|
||||
expect 1 $nonFlakeDir/shebang-reject.sh 2>&1 | grepQuiet -F 'error: unsupported unquoted character in nix shebang: *. Use double backticks to escape?'
|
||||
|
||||
# Test that the --commit-lock-file-summary flag and its alias work
|
||||
cat > "$lockfileSummaryFlake/flake.nix" <<EOF
|
||||
{
|
||||
inputs = {
|
||||
flake1.url = "git+file://$flake1Dir";
|
||||
};
|
||||
|
||||
description = "lockfileSummaryFlake";
|
||||
|
||||
outputs = inputs: rec {
|
||||
packages.$system.default = inputs.flake1.packages.$system.foo;
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
git -C "$lockfileSummaryFlake" add flake.nix
|
||||
git -C "$lockfileSummaryFlake" commit -m 'Add lockfileSummaryFlake'
|
||||
|
||||
testSummary="test summary 1"
|
||||
nix flake lock "$lockfileSummaryFlake" --commit-lock-file --commit-lock-file-summary "$testSummary"
|
||||
[[ -e "$lockfileSummaryFlake/flake.lock" ]]
|
||||
[[ -z $(git -C "$lockfileSummaryFlake" diff main || echo failed) ]]
|
||||
[[ "$(git -C "$lockfileSummaryFlake" log --format=%s -n 1)" = "$testSummary" ]]
|
||||
|
||||
git -C "$lockfileSummaryFlake" rm :/:flake.lock
|
||||
git -C "$lockfileSummaryFlake" commit -m "remove flake.lock"
|
||||
testSummary="test summary 2"
|
||||
# NOTE(cole-h): We use `--option` here because Nix settings do not currently support flag-ifying the
|
||||
# alias of a setting: https://github.com/NixOS/nix/issues/10989
|
||||
nix flake lock "$lockfileSummaryFlake" --commit-lock-file --option commit-lockfile-summary "$testSummary"
|
||||
[[ -e "$lockfileSummaryFlake/flake.lock" ]]
|
||||
[[ -z $(git -C "$lockfileSummaryFlake" diff main || echo failed) ]]
|
||||
[[ "$(git -C "$lockfileSummaryFlake" log --format=%s -n 1)" = "$testSummary" ]]
|
||||
|
|
|
@ -8,16 +8,16 @@ templatesDir=$TEST_ROOT/templates
|
|||
flakeDir=$TEST_ROOT/flake
|
||||
nixpkgsDir=$TEST_ROOT/nixpkgs
|
||||
|
||||
nix registry add --registry $registry templates git+file://$templatesDir
|
||||
nix registry add --registry $registry nixpkgs git+file://$nixpkgsDir
|
||||
nix registry add --registry "$registry" templates "git+file://$templatesDir"
|
||||
nix registry add --registry "$registry" nixpkgs "git+file://$nixpkgsDir"
|
||||
|
||||
createGitRepo $nixpkgsDir
|
||||
createSimpleGitFlake $nixpkgsDir
|
||||
createGitRepo "$nixpkgsDir"
|
||||
createSimpleGitFlake "$nixpkgsDir"
|
||||
|
||||
# Test 'nix flake init'.
|
||||
createGitRepo $templatesDir
|
||||
createGitRepo "$templatesDir"
|
||||
|
||||
cat > $templatesDir/flake.nix <<EOF
|
||||
cat > "$templatesDir"/flake.nix <<EOF
|
||||
{
|
||||
description = "Some templates";
|
||||
|
||||
|
@ -36,9 +36,9 @@ cat > $templatesDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
mkdir $templatesDir/trivial
|
||||
mkdir "$templatesDir/trivial"
|
||||
|
||||
cat > $templatesDir/trivial/flake.nix <<EOF
|
||||
cat > "$templatesDir"/trivial/flake.nix <<EOF
|
||||
{
|
||||
description = "A flake for building Hello World";
|
||||
|
||||
|
@ -50,40 +50,40 @@ cat > $templatesDir/trivial/flake.nix <<EOF
|
|||
};
|
||||
}
|
||||
EOF
|
||||
echo a > $templatesDir/trivial/a
|
||||
echo b > $templatesDir/trivial/b
|
||||
echo a > "$templatesDir/trivial/a"
|
||||
echo b > "$templatesDir/trivial/b"
|
||||
|
||||
git -C $templatesDir add flake.nix trivial/
|
||||
git -C $templatesDir commit -m 'Initial'
|
||||
git -C "$templatesDir" add flake.nix trivial/
|
||||
git -C "$templatesDir" commit -m 'Initial'
|
||||
|
||||
nix flake check templates
|
||||
nix flake show templates
|
||||
nix flake show templates --json | jq
|
||||
|
||||
createGitRepo $flakeDir
|
||||
(cd $flakeDir && nix flake init)
|
||||
(cd $flakeDir && nix flake init) # check idempotence
|
||||
git -C $flakeDir add flake.nix
|
||||
nix flake check $flakeDir
|
||||
nix flake show $flakeDir
|
||||
nix flake show $flakeDir --json | jq
|
||||
git -C $flakeDir commit -a -m 'Initial'
|
||||
createGitRepo "$flakeDir"
|
||||
(cd "$flakeDir" && nix flake init)
|
||||
(cd "$flakeDir" && nix flake init) # check idempotence
|
||||
git -C "$flakeDir" add flake.nix
|
||||
nix flake check "$flakeDir"
|
||||
nix flake show "$flakeDir"
|
||||
nix flake show "$flakeDir" --json | jq
|
||||
git -C "$flakeDir" commit -a -m 'Initial'
|
||||
|
||||
# Test 'nix flake init' with benign conflicts
|
||||
createGitRepo "$flakeDir"
|
||||
echo a > $flakeDir/a
|
||||
(cd $flakeDir && nix flake init) # check idempotence
|
||||
echo a > "$flakeDir/a"
|
||||
(cd "$flakeDir" && nix flake init) # check idempotence
|
||||
|
||||
# Test 'nix flake init' with conflicts
|
||||
createGitRepo "$flakeDir"
|
||||
echo b > $flakeDir/a
|
||||
pushd $flakeDir
|
||||
echo b > "$flakeDir/a"
|
||||
pushd "$flakeDir"
|
||||
(! nix flake init) |& grep "refusing to overwrite existing file '$flakeDir/a'"
|
||||
popd
|
||||
git -C $flakeDir commit -a -m 'Changed'
|
||||
git -C "$flakeDir" commit -a -m 'Changed'
|
||||
|
||||
# Test 'nix flake new'.
|
||||
rm -rf $flakeDir
|
||||
nix flake new -t templates#trivial $flakeDir
|
||||
nix flake new -t templates#trivial $flakeDir # check idempotence
|
||||
nix flake check $flakeDir
|
||||
rm -rf "$flakeDir"
|
||||
nix flake new -t templates#trivial "$flakeDir"
|
||||
nix flake new -t templates#trivial "$flakeDir" # check idempotence
|
||||
nix flake check "$flakeDir"
|
||||
|
|
|
@ -8,12 +8,12 @@ requireGit
|
|||
test_subdir_self_path() {
|
||||
baseDir=$TEST_ROOT/$RANDOM
|
||||
flakeDir=$baseDir/b-low
|
||||
mkdir -p $flakeDir
|
||||
writeSimpleFlake $baseDir
|
||||
writeSimpleFlake $flakeDir
|
||||
mkdir -p "$flakeDir"
|
||||
writeSimpleFlake "$baseDir"
|
||||
writeSimpleFlake "$flakeDir"
|
||||
|
||||
echo all good > $flakeDir/message
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
echo all good > "$flakeDir/message"
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = inputs: rec {
|
||||
packages.$system = rec {
|
||||
|
@ -26,7 +26,7 @@ test_subdir_self_path() {
|
|||
}
|
||||
EOF
|
||||
(
|
||||
nix build $baseDir?dir=b-low --no-link
|
||||
nix build "$baseDir"?dir=b-low --no-link
|
||||
)
|
||||
}
|
||||
test_subdir_self_path
|
||||
|
@ -34,14 +34,14 @@ test_subdir_self_path
|
|||
|
||||
test_git_subdir_self_path() {
|
||||
repoDir=$TEST_ROOT/repo-$RANDOM
|
||||
createGitRepo $repoDir
|
||||
createGitRepo "$repoDir"
|
||||
flakeDir=$repoDir/b-low
|
||||
mkdir -p $flakeDir
|
||||
writeSimpleFlake $repoDir
|
||||
writeSimpleFlake $flakeDir
|
||||
mkdir -p "$flakeDir"
|
||||
writeSimpleFlake "$repoDir"
|
||||
writeSimpleFlake "$flakeDir"
|
||||
|
||||
echo all good > $flakeDir/message
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
echo all good > "$flakeDir/message"
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = inputs: rec {
|
||||
packages.$system = rec {
|
||||
|
@ -55,15 +55,15 @@ test_git_subdir_self_path() {
|
|||
}
|
||||
EOF
|
||||
(
|
||||
cd $flakeDir
|
||||
cd "$flakeDir"
|
||||
git add .
|
||||
git commit -m init
|
||||
# nix build
|
||||
)
|
||||
|
||||
clientDir=$TEST_ROOT/client-$RANDOM
|
||||
mkdir -p $clientDir
|
||||
cat > $clientDir/flake.nix <<EOF
|
||||
mkdir -p "$clientDir"
|
||||
cat > "$clientDir"/flake.nix <<EOF
|
||||
{
|
||||
inputs.inp = {
|
||||
type = "git";
|
||||
|
@ -76,7 +76,7 @@ EOF
|
|||
};
|
||||
}
|
||||
EOF
|
||||
nix build $clientDir --no-link
|
||||
nix build "$clientDir" --no-link
|
||||
|
||||
}
|
||||
test_git_subdir_self_path
|
||||
|
|
|
@ -5,41 +5,41 @@ source ./common.sh
|
|||
[[ $(type -p hg) ]] || skipTest "Mercurial not installed"
|
||||
|
||||
flake1Dir=$TEST_ROOT/flake-hg1
|
||||
mkdir -p $flake1Dir
|
||||
writeSimpleFlake $flake1Dir
|
||||
hg init $flake1Dir
|
||||
mkdir -p "$flake1Dir"
|
||||
writeSimpleFlake "$flake1Dir"
|
||||
hg init "$flake1Dir"
|
||||
|
||||
nix registry add --registry $registry flake1 hg+file://$flake1Dir
|
||||
nix registry add --registry "$registry" flake1 "hg+file://$flake1Dir"
|
||||
|
||||
flake2Dir=$TEST_ROOT/flake-hg2
|
||||
mkdir -p $flake2Dir
|
||||
writeDependentFlake $flake2Dir
|
||||
hg init $flake2Dir
|
||||
mkdir -p "$flake2Dir"
|
||||
writeDependentFlake "$flake2Dir"
|
||||
hg init "$flake2Dir"
|
||||
|
||||
hg add $flake1Dir/*
|
||||
hg commit --config ui.username=foobar@example.org $flake1Dir -m 'Initial commit'
|
||||
hg add "$flake1Dir"/*
|
||||
hg commit --config ui.username=foobar@example.org "$flake1Dir" -m 'Initial commit'
|
||||
|
||||
hg add $flake2Dir/flake.nix
|
||||
hg commit --config ui.username=foobar@example.org $flake2Dir -m 'Initial commit'
|
||||
hg add "$flake2Dir"/flake.nix
|
||||
hg commit --config ui.username=foobar@example.org "$flake2Dir" -m 'Initial commit'
|
||||
|
||||
nix build -o $TEST_ROOT/result hg+file://$flake2Dir
|
||||
nix build -o "$TEST_ROOT/result" "hg+file://$flake2Dir"
|
||||
[[ -e $TEST_ROOT/result/hello ]]
|
||||
|
||||
(! nix flake metadata --json hg+file://$flake2Dir | jq -e -r .revision)
|
||||
(! nix flake metadata --json "hg+file://$flake2Dir" | jq -e -r .revision)
|
||||
|
||||
nix eval hg+file://$flake2Dir#expr
|
||||
nix eval "hg+file://$flake2Dir"#expr
|
||||
|
||||
nix eval hg+file://$flake2Dir#expr
|
||||
nix eval "hg+file://$flake2Dir"#expr
|
||||
|
||||
(! nix eval hg+file://$flake2Dir#expr --no-allow-dirty)
|
||||
(! nix eval "hg+file://$flake2Dir"#expr --no-allow-dirty)
|
||||
|
||||
(! nix flake metadata --json hg+file://$flake2Dir | jq -e -r .revision)
|
||||
(! nix flake metadata --json "hg+file://$flake2Dir" | jq -e -r .revision)
|
||||
|
||||
hg commit --config ui.username=foobar@example.org $flake2Dir -m 'Add lock file'
|
||||
hg commit --config ui.username=foobar@example.org "$flake2Dir" -m 'Add lock file'
|
||||
|
||||
nix flake metadata --json hg+file://$flake2Dir --refresh | jq -e -r .revision
|
||||
nix flake metadata --json hg+file://$flake2Dir
|
||||
[[ $(nix flake metadata --json hg+file://$flake2Dir | jq -e -r .revCount) = 1 ]]
|
||||
nix flake metadata --json "hg+file://$flake2Dir" --refresh | jq -e -r .revision
|
||||
nix flake metadata --json "hg+file://$flake2Dir"
|
||||
[[ $(nix flake metadata --json "hg+file://$flake2Dir" | jq -e -r .revCount) = 1 ]]
|
||||
|
||||
nix build -o $TEST_ROOT/result hg+file://$flake2Dir --no-registries --no-allow-dirty
|
||||
nix build -o $TEST_ROOT/result hg+file://$flake2Dir --no-use-registries --no-allow-dirty
|
||||
nix build -o "$TEST_ROOT/result" "hg+file://$flake2Dir" --no-registries --no-allow-dirty
|
||||
nix build -o "$TEST_ROOT/result" "hg+file://$flake2Dir" --no-use-registries --no-allow-dirty
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source ../common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local
|
||||
cp ../shell-hello.nix ../config.nix $TEST_HOME
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
writeSimpleFlake $TEST_HOME
|
||||
cd $TEST_HOME
|
||||
writeSimpleFlake "$TEST_HOME"
|
||||
cd "$TEST_HOME"
|
||||
mkdir -p foo/subdir
|
||||
|
||||
echo '{ outputs = _: {}; }' > foo/flake.nix
|
||||
|
@ -27,11 +27,11 @@ success=("" . .# .#test ../subdir ../subdir#test "$PWD")
|
|||
failure=("path:$PWD" "../simple.nix")
|
||||
|
||||
for i in "${success[@]}"; do
|
||||
nix build $i || fail "flake should be found by searching up directories"
|
||||
nix build "$i" || fail "flake should be found by searching up directories"
|
||||
done
|
||||
|
||||
for i in "${failure[@]}"; do
|
||||
! nix build $i || fail "flake should not search up directories when using 'path:'"
|
||||
! nix build "$i" || fail "flake should not search up directories when using 'path:'"
|
||||
done
|
||||
|
||||
popd
|
||||
|
@ -45,7 +45,7 @@ if [[ -n $(type -p git) ]]; then
|
|||
pushd subdir
|
||||
git init
|
||||
for i in "${success[@]}" "${failure[@]}"; do
|
||||
! nix build $i || fail "flake should not search past a git repository"
|
||||
! nix build "$i" || fail "flake should not search past a git repository"
|
||||
done
|
||||
rm -rf .git
|
||||
popd
|
||||
|
|
|
@ -7,26 +7,26 @@ requireGit
|
|||
flake1Dir=$TEST_ROOT/flake1
|
||||
flake2Dir=$TEST_ROOT/flake2
|
||||
|
||||
createGitRepo $flake1Dir
|
||||
cat > $flake1Dir/flake.nix <<EOF
|
||||
createGitRepo "$flake1Dir"
|
||||
cat > "$flake1Dir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: { x = import ./x.nix; };
|
||||
}
|
||||
EOF
|
||||
echo 123 > $flake1Dir/x.nix
|
||||
git -C $flake1Dir add flake.nix x.nix
|
||||
git -C $flake1Dir commit -m Initial
|
||||
echo 123 > "$flake1Dir"/x.nix
|
||||
git -C "$flake1Dir" add flake.nix x.nix
|
||||
git -C "$flake1Dir" commit -m Initial
|
||||
|
||||
createGitRepo $flake2Dir
|
||||
cat > $flake2Dir/flake.nix <<EOF
|
||||
createGitRepo "$flake2Dir"
|
||||
cat > "$flake2Dir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self, flake1 }: { x = flake1.x; };
|
||||
}
|
||||
EOF
|
||||
git -C $flake2Dir add flake.nix
|
||||
git -C "$flake2Dir" add flake.nix
|
||||
|
||||
[[ $(nix eval --json $flake2Dir#x --override-input flake1 $TEST_ROOT/flake1) = 123 ]]
|
||||
[[ $(nix eval --json "$flake2Dir#x" --override-input flake1 "$TEST_ROOT/flake1") = 123 ]]
|
||||
|
||||
echo 456 > $flake1Dir/x.nix
|
||||
echo 456 > "$flake1Dir"/x.nix
|
||||
|
||||
[[ $(nix eval --json $flake2Dir#x --override-input flake1 $TEST_ROOT/flake1) = 456 ]]
|
||||
[[ $(nix eval --json "$flake2Dir#x" --override-input flake1 "$TEST_ROOT/flake1") = 456 ]]
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
TODO_NixOS # Provide a `shell` variable. Try not to `export` it, perhaps.
|
||||
|
||||
clearStoreIfPossible
|
||||
rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local
|
||||
|
||||
cp ./simple.nix ./simple.builder.sh ./fmt.simple.sh ./config.nix $TEST_HOME
|
||||
|
@ -31,5 +33,3 @@ EOF
|
|||
nix fmt ./file ./folder | grep 'Formatting: ./file ./folder'
|
||||
nix flake check
|
||||
nix flake show | grep -P "package 'formatter'"
|
||||
|
||||
clearStore
|
||||
|
|
|
@ -21,12 +21,12 @@ expect_trace() {
|
|||
<(echo "$expect") \
|
||||
<(echo "$actual")
|
||||
) && result=0 || result=$?
|
||||
if [ $result -eq 0 ]; then
|
||||
if [ "$result" -eq 0 ]; then
|
||||
echo " ok."
|
||||
else
|
||||
echo " failed. difference:"
|
||||
echo "$msg"
|
||||
return $result
|
||||
return "$result"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ source common.sh
|
|||
|
||||
needLocalStore "“min-free” and “max-free” are daemon options"
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
garbage1=$(nix store add-path --name garbage1 ./nar-access.sh)
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
lockFifo1=$TEST_ROOT/test1.fifo
|
||||
|
@ -20,8 +22,8 @@ outPath3=$(nix-store -r $drvPath3)
|
|||
touch $outPath3.lock
|
||||
|
||||
rm -f "$NIX_STATE_DIR"/gcroots/foo*
|
||||
ln -s $drvPath2 "$NIX_STATE_DIR"/gcroots/foo
|
||||
ln -s $outPath3 "$NIX_STATE_DIR"/gcroots/foo2
|
||||
ln -s $drvPath2 "$NIX_STATE_DIR/gcroots/foo"
|
||||
ln -s $outPath3 "$NIX_STATE_DIR/gcroots/foo2"
|
||||
|
||||
# Start build #1 in the background. It starts immediately.
|
||||
nix-store -rvv "$drvPath1" &
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
# parallel with it.
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
needLocalStore "the GC test needs a synchronisation point"
|
||||
|
||||
clearStore
|
||||
|
|
|
@ -11,28 +11,30 @@ esac
|
|||
|
||||
set -m # enable job control, needed for kill
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
profiles="$NIX_STATE_DIR"/profiles
|
||||
rm -rf $profiles
|
||||
rm -rf "$profiles"
|
||||
|
||||
nix-env -p $profiles/test -f ./gc-runtime.nix -i gc-runtime
|
||||
nix-env -p "$profiles/test" -f ./gc-runtime.nix -i gc-runtime
|
||||
|
||||
outPath=$(nix-env -p $profiles/test -q --no-name --out-path gc-runtime)
|
||||
echo $outPath
|
||||
outPath=$(nix-env -p "$profiles/test" -q --no-name --out-path gc-runtime)
|
||||
echo "$outPath"
|
||||
|
||||
echo "backgrounding program..."
|
||||
$profiles/test/program &
|
||||
"$profiles"/test/program &
|
||||
sleep 2 # hack - wait for the program to get started
|
||||
child=$!
|
||||
echo PID=$child
|
||||
|
||||
nix-env -p $profiles/test -e gc-runtime
|
||||
nix-env -p $profiles/test --delete-generations old
|
||||
nix-env -p "$profiles/test" -e gc-runtime
|
||||
nix-env -p "$profiles/test" --delete-generations old
|
||||
|
||||
nix-store --gc
|
||||
|
||||
kill -- -$child
|
||||
|
||||
if ! test -e $outPath; then
|
||||
if ! test -e "$outPath"; then
|
||||
echo "running program was garbage collected!"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -2,14 +2,16 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStore
|
||||
|
||||
drvPath=$(nix-instantiate dependencies.nix)
|
||||
outPath=$(nix-store -rvv "$drvPath")
|
||||
|
||||
# Set a GC root.
|
||||
rm -f "$NIX_STATE_DIR"/gcroots/foo
|
||||
ln -sf $outPath "$NIX_STATE_DIR"/gcroots/foo
|
||||
rm -f "$NIX_STATE_DIR/gcroots/foo"
|
||||
ln -sf $outPath "$NIX_STATE_DIR/gcroots/foo"
|
||||
|
||||
[ "$(nix-store -q --roots $outPath)" = "$NIX_STATE_DIR/gcroots/foo -> $outPath" ]
|
||||
|
||||
|
@ -42,7 +44,7 @@ cat $outPath/reference-to-input-2/bar
|
|||
# Check that the derivation has been GC'd.
|
||||
if test -e $drvPath; then false; fi
|
||||
|
||||
rm "$NIX_STATE_DIR"/gcroots/foo
|
||||
rm "$NIX_STATE_DIR/gcroots/foo"
|
||||
|
||||
nix-collect-garbage
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
source ../common.sh
|
||||
|
||||
TODO_NixOS # Need to enable git hashing feature and make sure test is ok for store we don't clear
|
||||
|
||||
clearStore
|
||||
clearCache
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
source common.sh
|
||||
|
||||
try () {
|
||||
printf "%s" "$2" > $TEST_ROOT/vector
|
||||
printf "%s" "$2" > "$TEST_ROOT/vector"
|
||||
hash="$(nix-hash --flat ${FORMAT+--$FORMAT} --type "$1" "$TEST_ROOT/vector")"
|
||||
if ! (( "${NO_TEST_CLASSIC-}" )) && test "$hash" != "$3"; then
|
||||
echo "try nix-hash: hash $1, expected $3, got $hash"
|
||||
|
@ -61,7 +61,7 @@ NO_TEST_NIX_COMMAND=1 try sha512 "abc" "ddaf35a193617abacc417349ae20413112e6fa4e
|
|||
NO_TEST_CLASSIC=1 try sha512 "abc" "sha512-3a81oZNherrMQXNJriBBMRLm+k6JqX6iCp7u5ktV05ohkpkqJ0/BqDa6PCOj/uu9RU1EI2Q86A4qmslPpUyknw=="
|
||||
|
||||
try2 () {
|
||||
hash=$(nix-hash --type "$1" $TEST_ROOT/hash-path)
|
||||
hash=$(nix-hash --type "$1" "$TEST_ROOT/hash-path")
|
||||
if test "$hash" != "$2"; then
|
||||
echo "try nix-hash; hash $1, expected $2, got $hash"
|
||||
exit 1
|
||||
|
@ -73,22 +73,22 @@ try2 () {
|
|||
fi
|
||||
}
|
||||
|
||||
rm -rf $TEST_ROOT/hash-path
|
||||
mkdir $TEST_ROOT/hash-path
|
||||
echo "Hello World" > $TEST_ROOT/hash-path/hello
|
||||
rm -rf "$TEST_ROOT/hash-path"
|
||||
mkdir "$TEST_ROOT/hash-path"
|
||||
echo "Hello World" > "$TEST_ROOT/hash-path/hello"
|
||||
|
||||
try2 md5 "ea9b55537dd4c7e104515b2ccfaf4100"
|
||||
|
||||
# Execute bit matters.
|
||||
chmod +x $TEST_ROOT/hash-path/hello
|
||||
chmod +x "$TEST_ROOT/hash-path/hello"
|
||||
try2 md5 "20f3ffe011d4cfa7d72bfabef7882836"
|
||||
|
||||
# Mtime and other bits don't.
|
||||
touch -r . $TEST_ROOT/hash-path/hello
|
||||
chmod 744 $TEST_ROOT/hash-path/hello
|
||||
touch -r . "$TEST_ROOT/hash-path/hello"
|
||||
chmod 744 "$TEST_ROOT/hash-path/hello"
|
||||
try2 md5 "20f3ffe011d4cfa7d72bfabef7882836"
|
||||
|
||||
# File type (e.g., symlink) does.
|
||||
rm $TEST_ROOT/hash-path/hello
|
||||
ln -s x $TEST_ROOT/hash-path/hello
|
||||
rm "$TEST_ROOT/hash-path/hello"
|
||||
ln -s x "$TEST_ROOT/hash-path/hello"
|
||||
try2 md5 "f78b733a68f5edbdf9413899339eaa4a"
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
# test help output
|
||||
|
||||
nix-build --help
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
if nix-instantiate --readonly-mode ./import-derivation.nix; then
|
||||
echo "read-only evaluation of an imported derivation unexpectedly failed"
|
||||
|
@ -11,4 +11,4 @@ fi
|
|||
|
||||
outPath=$(nix-build ./import-derivation.nix --no-out-link)
|
||||
|
||||
[ "$(cat $outPath)" = FOO579 ]
|
||||
[ "$(cat "$outPath")" = FOO579 ]
|
||||
|
|
|
@ -4,10 +4,12 @@ source common.sh
|
|||
|
||||
requireDaemonNewerThan "2.8pre20220311"
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
enableFeatures "ca-derivations impure-derivations"
|
||||
restartDaemon
|
||||
|
||||
clearStore
|
||||
clearStoreIfPossible
|
||||
|
||||
# Basic test of impure derivations: building one a second time should not use the previous result.
|
||||
printf 0 > $TEST_ROOT/counter
|
||||
|
|
|
@ -5,6 +5,8 @@ source common.sh
|
|||
# Needs the config option 'impure-env' to work
|
||||
requireDaemonNewerThan "2.19.0"
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
enableFeatures "configurable-impure-env"
|
||||
restartDaemon
|
||||
|
||||
|
@ -20,13 +22,13 @@ startDaemon
|
|||
|
||||
varTest env_name value --impure-env env_name=value
|
||||
|
||||
echo 'impure-env = set_in_config=config_value' >> "$NIX_CONF_DIR/nix.conf"
|
||||
echo 'impure-env = set_in_config=config_value' >> "$test_nix_conf"
|
||||
set_in_config=daemon_value restartDaemon
|
||||
|
||||
varTest set_in_config config_value
|
||||
varTest set_in_config client_value --impure-env set_in_config=client_value
|
||||
|
||||
sed -i -e '/^trusted-users =/d' "$NIX_CONF_DIR/nix.conf"
|
||||
sed -i -e '/^trusted-users =/d' "$test_nix_conf"
|
||||
|
||||
env_name=daemon_value restartDaemon
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ source common.sh
|
|||
|
||||
set -o pipefail
|
||||
|
||||
source lang/framework.sh
|
||||
source characterisation/framework.sh
|
||||
|
||||
# specialize function a bit
|
||||
function diffAndAccept() {
|
||||
|
@ -138,32 +138,4 @@ for i in lang/eval-okay-*.nix; do
|
|||
fi
|
||||
done
|
||||
|
||||
if test -n "${_NIX_TEST_ACCEPT-}"; then
|
||||
if (( "$badDiff" )); then
|
||||
echo 'Output did mot match, but accepted output as the persisted expected output.'
|
||||
echo 'That means the next time the tests are run, they should pass.'
|
||||
else
|
||||
echo 'NOTE: Environment variable _NIX_TEST_ACCEPT is defined,'
|
||||
echo 'indicating the unexpected output should be accepted as the expected output going forward,'
|
||||
echo 'but no tests had unexpected output so there was no expected output to update.'
|
||||
fi
|
||||
if (( "$badExitCode" )); then
|
||||
exit "$badExitCode"
|
||||
else
|
||||
skipTest "regenerating golden masters"
|
||||
fi
|
||||
else
|
||||
if (( "$badDiff" )); then
|
||||
echo ''
|
||||
echo 'You can rerun this test with:'
|
||||
echo ''
|
||||
echo ' _NIX_TEST_ACCEPT=1 make tests/functional/lang.sh.test'
|
||||
echo ''
|
||||
echo 'to regenerate the files containing the expected output,'
|
||||
echo 'and then view the git diff to decide whether a change is'
|
||||
echo 'good/intentional or bad/unintentional.'
|
||||
echo 'If the diff contains arbitrary or impure information,'
|
||||
echo 'please improve the normalization that the test applies to the output.'
|
||||
fi
|
||||
exit $(( "$badExitCode" + "$badDiff" ))
|
||||
fi
|
||||
characterisationTestExit
|
||||
|
|
|
@ -6,4 +6,4 @@ error:
|
|||
| ^
|
||||
10|
|
||||
|
||||
error: cannot coerce a set to a string: { a = { a = { a = { a = "ha"; b = "ha"; c = "ha"; d = "ha"; e = "ha"; f = "ha"; g = "ha"; h = "ha"; j = "ha"; }; «4294967295 attributes elided» }; «4294967294 attributes elided» }; «4294967293 attributes elided» }
|
||||
error: cannot coerce a set to a string: { a = { a = { a = { a = "ha"; b = "ha"; c = "ha"; d = "ha"; e = "ha"; f = "ha"; g = "ha"; h = "ha"; j = "ha"; }; «8 attributes elided» }; «8 attributes elided» }; «8 attributes elided» }
|
||||
|
|
26
tests/functional/lang/eval-fail-derivation-name.err.exp
Normal file
26
tests/functional/lang/eval-fail-derivation-name.err.exp
Normal file
|
@ -0,0 +1,26 @@
|
|||
error:
|
||||
… while evaluating the attribute 'outPath'
|
||||
at <nix/derivation-internal.nix>:19:9:
|
||||
18| value = commonAttrs // {
|
||||
19| outPath = builtins.getAttr outputName strict;
|
||||
| ^
|
||||
20| drvPath = strict.drvPath;
|
||||
|
||||
… while calling the 'getAttr' builtin
|
||||
at <nix/derivation-internal.nix>:19:19:
|
||||
18| value = commonAttrs // {
|
||||
19| outPath = builtins.getAttr outputName strict;
|
||||
| ^
|
||||
20| drvPath = strict.drvPath;
|
||||
|
||||
… while calling the 'derivationStrict' builtin
|
||||
at <nix/derivation-internal.nix>:9:12:
|
||||
8|
|
||||
9| strict = derivationStrict drvAttrs;
|
||||
| ^
|
||||
10|
|
||||
|
||||
… while evaluating derivation '~jiggle~'
|
||||
whose name attribute is located at /pwd/lang/eval-fail-derivation-name.nix:2:3
|
||||
|
||||
error: invalid derivation name: name '~jiggle~' contains illegal character '~'. Please pass a different 'name'.
|
5
tests/functional/lang/eval-fail-derivation-name.nix
Normal file
5
tests/functional/lang/eval-fail-derivation-name.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
derivation {
|
||||
name = "~jiggle~";
|
||||
system = "some-system";
|
||||
builder = "/dontcare";
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue