Skip to content

Commit

Permalink
test(functional/flakes): add dubious-query
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanhonof committed Sep 26, 2024
1 parent 1ce19c2 commit ebc80fa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
23 changes: 23 additions & 0 deletions tests/functional/flakes/dubious-query.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

source ./common.sh

requireGit

nixpkgsDir="$TEST_ROOT/nixpkgs"
createGitRepo "$nixpkgsDir"
createSimpleGitFlake "$nixpkgsDir"

# Check that a flakeref without a query is accepted correctly.
expectStderr 0 nix --offline build --dry-run "git+file://$nixpkgsDir#foo"

# Check that a flakeref with a good query is accepted correctly.
expectStderr 0 nix --offline build --dry-run "git+file://$nixpkgsDir?foo=bar#foo"

# Check that we get the dubious query warning, when passing in a query without an equal sign.
expectStderr 0 nix --offline build --dry-run "git+file://$nixpkgsDir?bar#foo" \
| grepQuiet "warning: dubious URI query 'bar' is missing equal sign '=', ignoring"

# Check that the anchor (#) is taken as a whole, not split, and throws an error.
expectStderr 1 nix --offline build --dry-run "git+file://$nixpkgsDir#foo?bar" \
| grepQuiet "error: flake 'git+file://$nixpkgsDir' does not provide attribute 'packages.$system.foo?bar', 'legacyPackages.$system.foo?bar' or 'foo?bar'"
3 changes: 2 additions & 1 deletion tests/functional/flakes/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ flake-tests := \
$(d)/eval-cache.sh \
$(d)/search-root.sh \
$(d)/config.sh \
$(d)/show.sh
$(d)/show.sh \
$(d)/dubious-query.sh

install-tests-groups += flake
1 change: 1 addition & 0 deletions tests/functional/flakes/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ suites += {
'search-root.sh',
'config.sh',
'show.sh',
'dubious-query.sh',
],
'workdir': meson.current_build_dir(),
}

0 comments on commit ebc80fa

Please sign in to comment.