add flakes.sh test for shebang supported types of comments

This commit is contained in:
Cyclic4179 2024-03-27 14:55:02 +01:00 committed by GitHub
parent a2c3333b97
commit 6227cd06bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,6 +93,23 @@ foo
EOF EOF
chmod +x $nonFlakeDir/shebang-comments.sh chmod +x $nonFlakeDir/shebang-comments.sh
cat > $nonFlakeDir/shebang-different-comments.sh <<EOF
#! $(type -P env) nix
# some comments
// some comments
* some comments
\ some comments
% some comments
@ some comments
-- some comments
(* some comment
#! nix --offline shell
#! nix flake1#fooScript
#! nix --no-write-lock-file --command cat
foo
EOF
chmod +x $nonFlakeDir/shebang-different-comments.sh
cat > $nonFlakeDir/shebang-reject.sh <<EOF cat > $nonFlakeDir/shebang-reject.sh <<EOF
#! $(type -P env) nix #! $(type -P env) nix
# some comments # some comments
@ -607,6 +624,7 @@ expectStderr 1 nix flake metadata "$flake2Dir" --no-allow-dirty --reference-lock
[[ $($nonFlakeDir/shebang.sh) = "foo" ]] [[ $($nonFlakeDir/shebang.sh) = "foo" ]]
[[ $($nonFlakeDir/shebang.sh "bar") = "foo"$'\n'"bar" ]] [[ $($nonFlakeDir/shebang.sh "bar") = "foo"$'\n'"bar" ]]
[[ $($nonFlakeDir/shebang-comments.sh ) = "foo" ]] [[ $($nonFlakeDir/shebang-comments.sh ) = "foo" ]]
[[ "$($nonFlakeDir/shebang-different-comments.sh)" = "$(cat $nonFlakeDir/shebang-different-comments.sh)" ]]
[[ $($nonFlakeDir/shebang-inline-expr.sh baz) = "foo"$'\n'"baz" ]] [[ $($nonFlakeDir/shebang-inline-expr.sh baz) = "foo"$'\n'"baz" ]]
[[ $($nonFlakeDir/shebang-file.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?' expect 1 $nonFlakeDir/shebang-reject.sh 2>&1 | grepQuiet -F 'error: unsupported unquoted character in nix shebang: *. Use double backticks to escape?'