Skip to content

Commit 2b62625

Browse files
committed
Move getFlake tests into a separate file
1 parent 7e68306 commit 2b62625

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

tests/functional/flakes/flakes.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,6 @@ nix build -o "$TEST_ROOT/result" "git+file://$flake1Dir?ref=HEAD#default"
109109
nix build -o "$flake1Dir/result" "git+file://$flake1Dir"
110110
nix path-info "$flake1Dir/result"
111111

112-
# 'getFlake' on an unlocked flakeref should fail in pure mode, but
113-
# succeed in impure mode.
114-
(! nix build -o "$TEST_ROOT/result" --expr "(builtins.getFlake \"$flake1Dir\").packages.$system.default")
115-
nix build -o "$TEST_ROOT/result" --expr "(builtins.getFlake \"$flake1Dir\").packages.$system.default" --impure
116-
117-
# 'getFlake' on a locked flakeref should succeed even in pure mode.
118-
nix build -o "$TEST_ROOT/result" --expr "(builtins.getFlake \"git+file://$flake1Dir?rev=$hash2\").packages.$system.default"
119-
120112
# Regression test for dirOf on the root of the flake.
121113
[[ $(nix eval --json flake1#parent) = \""$NIX_STORE_DIR"\" ]]
122114

@@ -131,12 +123,10 @@ nix build -o "$TEST_ROOT/result" --expr "(builtins.getFlake \"git+file://$flake1
131123
# Building a flake with an unlocked dependency should fail in pure mode.
132124
(! nix build -o "$TEST_ROOT/result" flake2#bar --no-registries)
133125
(! nix build -o "$TEST_ROOT/result" flake2#bar --no-use-registries)
134-
(! nix eval --expr "builtins.getFlake \"$flake2Dir\"")
135126

136127
# But should succeed in impure mode.
137128
(! nix build -o "$TEST_ROOT/result" flake2#bar --impure)
138129
nix build -o "$TEST_ROOT/result" flake2#bar --impure --no-write-lock-file
139-
nix eval --expr "builtins.getFlake \"$flake2Dir\"" --impure
140130

141131
# Building a local flake with an unlocked dependency should fail with --no-update-lock-file.
142132
expect 1 nix build -o "$TEST_ROOT/result" "$flake2Dir#bar" --no-update-lock-file 2>&1 | grep 'requires lock file changes'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
source ./common.sh
4+
5+
TODO_NixOS
6+
7+
createFlake1
8+
createFlake2
9+
10+
# 'getFlake' on an unlocked flakeref should fail in pure mode, but
11+
# succeed in impure mode.
12+
(! nix build -o "$TEST_ROOT/result" --expr "(builtins.getFlake \"$flake1Dir\").packages.$system.default")
13+
nix build -o "$TEST_ROOT/result" --expr "(builtins.getFlake \"$flake1Dir\").packages.$system.default" --impure
14+
15+
# 'getFlake' on a locked flakeref should succeed even in pure mode.
16+
hash=$(nix flake metadata flake1 --json --refresh | jq -r .revision)
17+
nix build -o "$TEST_ROOT/result" --expr "(builtins.getFlake \"git+file://$flake1Dir?rev=$hash\").packages.$system.default"
18+
19+
# Building a flake with an unlocked dependency should fail in pure mode.
20+
(! nix eval --expr "builtins.getFlake \"$flake2Dir\"")
21+
22+
# But should succeed in impure mode.
23+
nix eval --expr "builtins.getFlake \"$flake2Dir\"" --impure

tests/functional/flakes/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ suites += {
2727
'shebang.sh',
2828
'commit-lock-file-summary.sh',
2929
'non-flake-inputs.sh',
30+
'get-flake.sh',
3031
],
3132
'workdir': meson.current_source_dir(),
3233
}

0 commit comments

Comments
 (0)