forked from LnL7/nix
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NixOS#7954 from obsidiansystems/lang-test-improvem…
…ents Language test improvements
- Loading branch information
Showing
74 changed files
with
762 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Test the function for lang.sh | ||
source common.sh | ||
|
||
source lang/framework.sh | ||
|
||
# We are testing this, so don't want outside world to affect us. | ||
unset _NIX_TEST_ACCEPT | ||
|
||
# We'll only modify this in subshells so we don't need to reset it. | ||
badDiff=0 | ||
|
||
# matches non-empty | ||
echo Hi! > "$TEST_ROOT/got" | ||
cp "$TEST_ROOT/got" "$TEST_ROOT/expected" | ||
( | ||
diffAndAcceptInner test "$TEST_ROOT/got" "$TEST_ROOT/expected" | ||
(( "$badDiff" == 0 )) | ||
) | ||
|
||
# matches empty, non-existant file is the same as empty file | ||
echo -n > "$TEST_ROOT/got" | ||
( | ||
diffAndAcceptInner test "$TEST_ROOT/got" "$TEST_ROOT/does-not-exist" | ||
(( "$badDiff" == 0 )) | ||
) | ||
|
||
# doesn't matches non-empty, non-existant file is the same as empty file | ||
echo Hi! > "$TEST_ROOT/got" | ||
( | ||
diffAndAcceptInner test "$TEST_ROOT/got" "$TEST_ROOT/does-not-exist" | ||
(( "$badDiff" == 1 )) | ||
) | ||
|
||
# doesn't match, `badDiff` set, file unchanged | ||
echo Hi! > "$TEST_ROOT/got" | ||
echo Bye! > "$TEST_ROOT/expected" | ||
( | ||
diffAndAcceptInner test "$TEST_ROOT/got" "$TEST_ROOT/expected" | ||
(( "$badDiff" == 1 )) | ||
) | ||
[[ "$(echo Bye! )" == $(< "$TEST_ROOT/expected") ]] | ||
|
||
# _NIX_TEST_ACCEPT=1 matches non-empty | ||
echo Hi! > "$TEST_ROOT/got" | ||
cp "$TEST_ROOT/got" "$TEST_ROOT/expected" | ||
( | ||
_NIX_TEST_ACCEPT=1 diffAndAcceptInner test "$TEST_ROOT/got" "$TEST_ROOT/expected" | ||
(( "$badDiff" == 0 )) | ||
) | ||
|
||
# _NIX_TEST_ACCEPT doesn't match, `badDiff=1` set, file changed (was previously non-empty) | ||
echo Hi! > "$TEST_ROOT/got" | ||
echo Bye! > "$TEST_ROOT/expected" | ||
( | ||
_NIX_TEST_ACCEPT=1 diffAndAcceptInner test "$TEST_ROOT/got" "$TEST_ROOT/expected" | ||
(( "$badDiff" == 1 )) | ||
) | ||
[[ "$(echo Hi! )" == $(< "$TEST_ROOT/expected") ]] | ||
# second time succeeds | ||
( | ||
diffAndAcceptInner test "$TEST_ROOT/got" "$TEST_ROOT/expected" | ||
(( "$badDiff" == 0 )) | ||
) | ||
|
||
# _NIX_TEST_ACCEPT matches empty, non-existant file not created | ||
echo -n > "$TEST_ROOT/got" | ||
( | ||
_NIX_TEST_ACCEPT=1 diffAndAcceptInner test "$TEST_ROOT/got" "$TEST_ROOT/does-not-exists" | ||
(( "$badDiff" == 0 )) | ||
) | ||
[[ ! -f "$TEST_ROOT/does-not-exist" ]] | ||
|
||
# _NIX_TEST_ACCEPT doesn't match, output empty, file deleted | ||
echo -n > "$TEST_ROOT/got" | ||
echo Bye! > "$TEST_ROOT/expected" | ||
badDiff=0 | ||
( | ||
_NIX_TEST_ACCEPT=1 diffAndAcceptInner test "$TEST_ROOT/got" "$TEST_ROOT/expected" | ||
(( "$badDiff" == 1 )) | ||
) | ||
[[ ! -f "$TEST_ROOT/expected" ]] | ||
# second time succeeds | ||
( | ||
diffAndAcceptInner test "$TEST_ROOT/got" "$TEST_ROOT/expected" | ||
(( "$badDiff" == 0 )) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
error: | ||
… while calling the 'abort' builtin | ||
|
||
at /pwd/lang/eval-fail-abort.nix:1:14: | ||
|
||
1| if true then abort "this should fail" else 1 | ||
| ^ | ||
2| | ||
|
||
error: evaluation aborted with the following error message: 'this should fail' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
error: getting attributes of path ‘PWD/lang/fnord’: No such file or directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
error: | ||
… while evaluating the attribute 'body' | ||
|
||
at /pwd/lang/eval-fail-assert.nix:4:3: | ||
|
||
3| | ||
4| body = x "x"; | ||
| ^ | ||
5| } | ||
|
||
… from call site | ||
|
||
at /pwd/lang/eval-fail-assert.nix:4:10: | ||
|
||
3| | ||
4| body = x "x"; | ||
| ^ | ||
5| } | ||
|
||
… while calling 'x' | ||
|
||
at /pwd/lang/eval-fail-assert.nix:2:7: | ||
|
||
1| let { | ||
2| x = arg: assert arg == "y"; 123; | ||
| ^ | ||
3| | ||
|
||
error: assertion '(arg == "y")' failed | ||
|
||
at /pwd/lang/eval-fail-assert.nix:2:12: | ||
|
||
1| let { | ||
2| x = arg: assert arg == "y"; 123; | ||
| ^ | ||
3| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
error: | ||
… while evaluating a path segment | ||
|
||
at /pwd/lang/eval-fail-bad-antiquote-1.nix:1:2: | ||
|
||
1| "${x: x}" | ||
| ^ | ||
2| | ||
|
||
error: cannot coerce a function to a string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
error: operation 'addToStoreFromDump' is not supported by store 'dummy' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
error: | ||
… while evaluating a path segment | ||
|
||
at /pwd/lang/eval-fail-bad-antiquote-3.nix:1:3: | ||
|
||
1| ''${x: x}'' | ||
| ^ | ||
2| | ||
|
||
error: cannot coerce a function to a string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
error: | ||
… while evaluating a path segment | ||
|
||
at /pwd/lang/eval-fail-bad-string-interpolation-1.nix:1:2: | ||
|
||
1| "${x: x}" | ||
| ^ | ||
2| | ||
|
||
error: cannot coerce a function to a string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
error: operation 'addToStoreFromDump' is not supported by store 'dummy' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
error: | ||
… while evaluating a path segment | ||
|
||
at /pwd/lang/eval-fail-bad-string-interpolation-3.nix:1:3: | ||
|
||
1| ''${x: x}'' | ||
| ^ | ||
2| | ||
|
||
error: cannot coerce a function to a string |
Oops, something went wrong.