mirror of
https://github.com/NixOS/nix
synced 2025-07-10 04:43:53 +02:00
Merge remote-tracking branch 'upstream/master' into lfs
This commit is contained in:
commit
134530a534
32 changed files with 324 additions and 196 deletions
|
@ -1,5 +1,7 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
badTestNames=()
|
||||
|
||||
# Golden test support
|
||||
#
|
||||
# Test that the output of the given test matches what is expected. If
|
||||
|
@ -18,10 +20,11 @@ function diffAndAcceptInner() {
|
|||
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"
|
||||
if ! diff >&2 --color=always --unified "$expectedOrEmpty" "$got"; then
|
||||
echo >&2 "FAIL: evaluation result of $testName not as expected"
|
||||
# shellcheck disable=SC2034
|
||||
badDiff=1
|
||||
badTestNames+=("$testName")
|
||||
fi
|
||||
|
||||
# Update expected if `_NIX_TEST_ACCEPT` is non-empty.
|
||||
|
@ -42,14 +45,14 @@ function characterisationTestExit() {
|
|||
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.'
|
||||
echo >&2 'Output did mot match, but accepted output as the persisted expected output.'
|
||||
echo >&2 '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.'
|
||||
echo >&2 'NOTE: Environment variable _NIX_TEST_ACCEPT is defined,'
|
||||
echo >&2 'indicating the unexpected output should be accepted as the expected output going forward,'
|
||||
echo >&2 'but no tests had unexpected output so there was no expected output to update.'
|
||||
set -x
|
||||
fi
|
||||
if (( "$badExitCode" )); then
|
||||
|
@ -60,16 +63,21 @@ function characterisationTestExit() {
|
|||
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}.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.'
|
||||
echo >&2 ''
|
||||
echo >&2 'The following tests had unexpected output:'
|
||||
for testName in "${badTestNames[@]}"; do
|
||||
echo >&2 " $testName"
|
||||
done
|
||||
echo >&2 ''
|
||||
echo >&2 'You can rerun this test with:'
|
||||
echo >&2 ''
|
||||
echo >&2 " _NIX_TEST_ACCEPT=1 meson test ${TEST_NAME}"
|
||||
echo >&2 ''
|
||||
echo >&2 'to regenerate the files containing the expected output,'
|
||||
echo >&2 'and then view the git diff to decide whether a change is'
|
||||
echo >&2 'good/intentional or bad/unintentional.'
|
||||
echo >&2 'If the diff contains arbitrary or impure information,'
|
||||
echo >&2 'please improve the normalization that the test applies to the output.'
|
||||
set -x
|
||||
fi
|
||||
exit $(( "$badExitCode" + "$badDiff" ))
|
||||
|
|
|
@ -37,6 +37,7 @@ nix-instantiate --eval -E "builtins.readFile ((builtins.fetchGit file://$TEST_RO
|
|||
|
||||
# Fetch a worktree.
|
||||
unset _NIX_FORCE_HTTP
|
||||
expectStderr 0 nix eval -vvvv --impure --raw --expr "(builtins.fetchGit file://$TEST_ROOT/worktree).outPath" | grepQuiet "copying '$TEST_ROOT/worktree/' to the store"
|
||||
path0=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$TEST_ROOT/worktree).outPath")
|
||||
path0_=$(nix eval --impure --raw --expr "(builtins.fetchTree { type = \"git\"; url = file://$TEST_ROOT/worktree; }).outPath")
|
||||
[[ $path0 = $path0_ ]]
|
||||
|
@ -64,7 +65,7 @@ git -C $repo add differentbranch
|
|||
git -C $repo commit -m 'Test2'
|
||||
git -C $repo checkout master
|
||||
devrev=$(git -C $repo rev-parse devtest)
|
||||
nix eval --impure --raw --expr "builtins.fetchGit { url = file://$repo; rev = \"$devrev\"; }"
|
||||
nix eval --raw --expr "builtins.fetchGit { url = file://$repo; rev = \"$devrev\"; }"
|
||||
|
||||
[[ $(nix eval --raw --expr "builtins.readFile (builtins.fetchGit { url = file://$repo; rev = \"$devrev\"; allRefs = true; } + \"/differentbranch\")") = 'different file' ]]
|
||||
|
||||
|
@ -79,7 +80,7 @@ path2=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"
|
|||
# In pure eval mode, fetchGit with a revision should succeed.
|
||||
[[ $(nix eval --raw --expr "builtins.readFile (fetchGit { url = file://$repo; rev = \"$rev2\"; } + \"/hello\")") = world ]]
|
||||
|
||||
# But without a hash, it fails
|
||||
# But without a hash, it fails.
|
||||
expectStderr 1 nix eval --expr 'builtins.fetchGit "file:///foo"' | grepQuiet "'fetchGit' will not fetch unlocked input"
|
||||
|
||||
# Fetch again. This should be cached.
|
||||
|
@ -141,13 +142,17 @@ path4=$(nix eval --impure --refresh --raw --expr "(builtins.fetchGit file://$rep
|
|||
[[ $(nix eval --impure --expr "builtins.hasAttr \"dirtyRev\" (builtins.fetchGit $repo)") == "false" ]]
|
||||
[[ $(nix eval --impure --expr "builtins.hasAttr \"dirtyShortRev\" (builtins.fetchGit $repo)") == "false" ]]
|
||||
|
||||
status=0
|
||||
nix eval --impure --raw --expr "(builtins.fetchGit { url = $repo; rev = \"$rev2\"; narHash = \"sha256-B5yIPHhEm0eysJKEsO7nqxprh9vcblFxpJG11gXJus1=\"; }).outPath" || status=$?
|
||||
[[ "$status" = "102" ]]
|
||||
expect 102 nix eval --raw --expr "(builtins.fetchGit { url = $repo; rev = \"$rev2\"; narHash = \"sha256-B5yIPHhEm0eysJKEsO7nqxprh9vcblFxpJG11gXJus1=\"; }).outPath"
|
||||
|
||||
path5=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = $repo; rev = \"$rev2\"; narHash = \"sha256-Hr8g6AqANb3xqX28eu1XnjK/3ab8Gv6TJSnkb1LezG9=\"; }).outPath")
|
||||
path5=$(nix eval --raw --expr "(builtins.fetchGit { url = $repo; rev = \"$rev2\"; narHash = \"sha256-Hr8g6AqANb3xqX28eu1XnjK/3ab8Gv6TJSnkb1LezG9=\"; }).outPath")
|
||||
[[ $path = $path5 ]]
|
||||
|
||||
# Ensure that NAR hashes are checked.
|
||||
expectStderr 102 nix eval --raw --expr "(builtins.fetchGit { url = $repo; rev = \"$rev2\"; narHash = \"sha256-Hr8g6AqANb4xqX28eu1XnjK/3ab8Gv6TJSnkb1LezG9=\"; }).outPath" | grepQuiet "error: NAR hash mismatch"
|
||||
|
||||
# It's allowed to use only a narHash, but you should get a warning.
|
||||
expectStderr 0 nix eval --raw --expr "(builtins.fetchGit { url = $repo; ref = \"tag2\"; narHash = \"sha256-Hr8g6AqANb3xqX28eu1XnjK/3ab8Gv6TJSnkb1LezG9=\"; }).outPath" | grepQuiet "warning: Input .* is unlocked"
|
||||
|
||||
# tarball-ttl should be ignored if we specify a rev
|
||||
echo delft > $repo/hello
|
||||
git -C $repo add hello
|
||||
|
@ -255,7 +260,7 @@ echo "/exported-wonky export-ignore=wonk" >> $repo/.gitattributes
|
|||
git -C $repo add not-exported-file exported-wonky .gitattributes
|
||||
git -C $repo commit -m 'Bla6'
|
||||
rev5=$(git -C $repo rev-parse HEAD)
|
||||
path12=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev5\"; }).outPath")
|
||||
path12=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev5\"; }).outPath")
|
||||
[[ ! -e $path12/not-exported-file ]]
|
||||
[[ -e $path12/exported-wonky ]]
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ suites += {
|
|||
'commit-lock-file-summary.sh',
|
||||
'non-flake-inputs.sh',
|
||||
'relative-paths.sh',
|
||||
'symlink-paths.sh'
|
||||
],
|
||||
'workdir': meson.current_source_dir(),
|
||||
}
|
||||
|
|
75
tests/functional/flakes/symlink-paths.sh
Normal file
75
tests/functional/flakes/symlink-paths.sh
Normal file
|
@ -0,0 +1,75 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source ./common.sh
|
||||
|
||||
requireGit
|
||||
|
||||
create_flake() {
|
||||
local flakeDir="$1"
|
||||
createGitRepo $flakeDir
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: { x = 2; };
|
||||
}
|
||||
EOF
|
||||
git -C $flakeDir add flake.nix
|
||||
git -C $flakeDir commit -m Initial
|
||||
}
|
||||
|
||||
test_symlink_points_to_flake() {
|
||||
create_flake "$TEST_ROOT/flake1"
|
||||
ln -sn "$TEST_ROOT/flake1" "$TEST_ROOT/flake1_sym"
|
||||
[[ $(nix eval "$TEST_ROOT/flake1_sym#x") = 2 ]]
|
||||
rm -rf "$TEST_ROOT/flake1" "$TEST_ROOT/flake1_sym"
|
||||
}
|
||||
test_symlink_points_to_flake
|
||||
|
||||
test_symlink_points_to_flake_in_subdir() {
|
||||
create_flake "$TEST_ROOT/subdir/flake1"
|
||||
ln -sn "$TEST_ROOT/subdir" "$TEST_ROOT/subdir_sym"
|
||||
[[ $(nix eval "$TEST_ROOT/subdir_sym/flake1#x") = 2 ]]
|
||||
rm -rf "$TEST_ROOT/subdir" "$TEST_ROOT/subdir_sym"
|
||||
}
|
||||
test_symlink_points_to_flake_in_subdir
|
||||
|
||||
test_symlink_points_to_dir_in_repo() {
|
||||
local repoDir="$TEST_ROOT/flake1"
|
||||
createGitRepo $repoDir
|
||||
mkdir -p "$repoDir/subdir"
|
||||
cat > $repoDir/subdir/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: { x = 2; };
|
||||
}
|
||||
EOF
|
||||
git -C $repoDir add subdir/flake.nix
|
||||
git -C $repoDir commit -m Initial
|
||||
ln -sn "$TEST_ROOT/flake1/subdir" "$TEST_ROOT/flake1_sym"
|
||||
[[ $(nix eval "$TEST_ROOT/flake1_sym#x") = 2 ]]
|
||||
rm -rf "$TEST_ROOT/flake1" "$TEST_ROOT/flake1_sym"
|
||||
}
|
||||
test_symlink_points_to_dir_in_repo
|
||||
|
||||
test_symlink_from_repo_to_another() {
|
||||
local repoDir="$TEST_ROOT/repo1"
|
||||
createGitRepo $repoDir
|
||||
echo "Hello" > $repoDir/file
|
||||
mkdir $repoDir/subdir
|
||||
cat > $repoDir/subdir/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: { x = builtins.readFile ../file; };
|
||||
}
|
||||
EOF
|
||||
git -C $repoDir add subdir/flake.nix file
|
||||
git -C $repoDir commit -m Initial
|
||||
[[ $(nix eval "$TEST_ROOT/repo1/subdir#x") == \"Hello\\n\" ]]
|
||||
|
||||
local repo2Dir="$TEST_ROOT/repo2"
|
||||
createGitRepo $repo2Dir
|
||||
ln -sn "$repoDir/subdir" "$repo2Dir/flake1_sym"
|
||||
echo "World" > $repo2Dir/file
|
||||
git -C "$repo2Dir" add flake1_sym file
|
||||
git -C "$repo2Dir" commit -m Initial
|
||||
[[ $(nix eval "$repo2Dir/flake1_sym#x") == \"Hello\\n\" ]]
|
||||
rm -rf "$TEST_ROOT/repo1" "$TEST_ROOT/repo2"
|
||||
}
|
||||
test_symlink_from_repo_to_another
|
|
@ -37,8 +37,8 @@ expectStderr 1 nix flake lock "$flake2Dir" --override-input flake1 "$TEST_ROOT/f
|
|||
|
||||
nix flake lock "$flake2Dir" --override-input flake1 "$TEST_ROOT/flake1" --allow-dirty-locks
|
||||
|
||||
# Using a lock file with a dirty lock requires --allow-dirty-locks as well.
|
||||
expectStderr 1 nix eval "$flake2Dir#x" |
|
||||
grepQuiet "Lock file contains unlocked input"
|
||||
# Using a lock file with a dirty lock does not require --allow-dirty-locks, but should print a warning.
|
||||
expectStderr 0 nix eval "$flake2Dir#x" |
|
||||
grepQuiet "warning: Lock file entry .* is unlocked"
|
||||
|
||||
[[ $(nix eval "$flake2Dir#x" --allow-dirty-locks) = 456 ]]
|
||||
[[ $(nix eval "$flake2Dir#x") = 456 ]]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source common.sh
|
||||
|
||||
# Store layer needs bugfix
|
||||
|
|
|
@ -25,7 +25,7 @@ done
|
|||
|
||||
# FIXME: we don't know whether we built the manpages, so we can't
|
||||
# reliably test them here.
|
||||
exit 0
|
||||
if false; then
|
||||
|
||||
# test help output
|
||||
|
||||
|
@ -74,3 +74,5 @@ nix-daemon --help
|
|||
nix-hash --help
|
||||
nix-instantiate --help
|
||||
nix-prefetch-url --help
|
||||
|
||||
fi
|
||||
|
|
|
@ -5,4 +5,4 @@ error:
|
|||
| ^
|
||||
2| type = "file";
|
||||
|
||||
error: negative value given for fetchTree attr owner: -1
|
||||
error: negative value given for 'fetchTree' argument 'owner': -1
|
||||
|
|
|
@ -32,7 +32,10 @@ in
|
|||
services.gitea.lfs.enable = true;
|
||||
services.gitea.settings = {
|
||||
service.DISABLE_REGISTRATION = true;
|
||||
server = { DOMAIN = "gitea"; HTTP_PORT = 3000; };
|
||||
server = {
|
||||
DOMAIN = "gitea";
|
||||
HTTP_PORT = 3000;
|
||||
};
|
||||
log.LEVEL = "Info";
|
||||
database.LOG_SQL = false;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue