mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
Add functional test for no-url-literals experimental feature
Closes: #13533
This commit is contained in:
parent
b062730665
commit
6e8f76482e
2 changed files with 29 additions and 0 deletions
|
|
@ -113,6 +113,7 @@ suites = [
|
||||||
'pure-eval.sh',
|
'pure-eval.sh',
|
||||||
'eval.sh',
|
'eval.sh',
|
||||||
'short-path-literals.sh',
|
'short-path-literals.sh',
|
||||||
|
'no-url-literals.sh',
|
||||||
'repl.sh',
|
'repl.sh',
|
||||||
'binary-cache-build-remote.sh',
|
'binary-cache-build-remote.sh',
|
||||||
'search.sh',
|
'search.sh',
|
||||||
|
|
|
||||||
28
tests/functional/no-url-literals.sh
Normal file
28
tests/functional/no-url-literals.sh
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
clearStoreIfPossible
|
||||||
|
|
||||||
|
# Test 1: By default, unquoted URLs are accepted
|
||||||
|
nix eval --expr 'http://example.com' 2>&1 | grepQuietInverse "error: URL literals are disabled"
|
||||||
|
|
||||||
|
# Test 2: With the experimental feature enabled, unquoted URLs are rejected
|
||||||
|
expect 1 nix eval --extra-experimental-features 'no-url-literals' --expr 'http://example.com' 2>&1 | grepQuiet "error: URL literals are disabled"
|
||||||
|
|
||||||
|
# Test 3: Quoted URLs are always accepted
|
||||||
|
nix eval --extra-experimental-features 'no-url-literals' --expr '"http://example.com"' 2>&1 | grepQuietInverse "error: URL literals are disabled"
|
||||||
|
|
||||||
|
# Test 4: URLs with parameters (which must be quoted) are accepted
|
||||||
|
nix eval --extra-experimental-features 'no-url-literals' --expr '"http://example.com?foo=bar"' 2>&1 | grepQuietInverse "error: URL literals are disabled"
|
||||||
|
|
||||||
|
# Test 5: The feature can be enabled via NIX_CONFIG
|
||||||
|
expect 1 env NIX_CONFIG='extra-experimental-features = no-url-literals' nix eval --expr 'http://example.com' 2>&1 | grepQuiet "error: URL literals are disabled"
|
||||||
|
|
||||||
|
# Test 6: The feature can be enabled via CLI even if not set in config
|
||||||
|
expect 1 env NIX_CONFIG='' nix eval --extra-experimental-features 'no-url-literals' --expr 'http://example.com' 2>&1 | grepQuiet "error: URL literals are disabled"
|
||||||
|
|
||||||
|
# Test 7: Evaluation still works for quoted URLs
|
||||||
|
nix eval --raw --extra-experimental-features no-url-literals --expr '"http://example.com"' | grepQuiet "^http://example.com$"
|
||||||
|
|
||||||
|
echo "no-url-literals test passed!"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue