Skip to content

Commit b767987

Browse files
authored
Merge pull request #11926 from DeterminateSystems/split-flake-tests
Break up tests/functional/flakes/flakes.sh
2 parents 82f6fba + 4a18c78 commit b767987

File tree

9 files changed

+333
-301
lines changed

9 files changed

+333
-301
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,4 @@ jobs:
220220
path: flake-regressions/tests
221221
- uses: DeterminateSystems/nix-installer-action@main
222222
- uses: DeterminateSystems/magic-nix-cache-action@main
223-
- run: nix build --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
223+
- run: nix build -L --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
source ./common.sh
4+
5+
TODO_NixOS
6+
7+
createFlake1
8+
9+
lockfileSummaryFlake=$TEST_ROOT/lockfileSummaryFlake
10+
createGitRepo "$lockfileSummaryFlake" "--initial-branch=main"
11+
12+
# Test that the --commit-lock-file-summary flag and its alias work
13+
cat > "$lockfileSummaryFlake/flake.nix" <<EOF
14+
{
15+
inputs = {
16+
flake1.url = "git+file://$flake1Dir";
17+
};
18+
19+
description = "lockfileSummaryFlake";
20+
21+
outputs = inputs: rec {
22+
packages.$system.default = inputs.flake1.packages.$system.foo;
23+
};
24+
}
25+
EOF
26+
27+
git -C "$lockfileSummaryFlake" add flake.nix
28+
git -C "$lockfileSummaryFlake" commit -m 'Add lockfileSummaryFlake'
29+
30+
testSummary="test summary 1"
31+
nix flake lock "$lockfileSummaryFlake" --commit-lock-file --commit-lock-file-summary "$testSummary"
32+
[[ -e "$lockfileSummaryFlake/flake.lock" ]]
33+
[[ -z $(git -C "$lockfileSummaryFlake" diff main || echo failed) ]]
34+
[[ "$(git -C "$lockfileSummaryFlake" log --format=%s -n 1)" = "$testSummary" ]]
35+
36+
git -C "$lockfileSummaryFlake" rm :/:flake.lock
37+
git -C "$lockfileSummaryFlake" commit -m "remove flake.lock"
38+
testSummary="test summary 2"
39+
# NOTE(cole-h): We use `--option` here because Nix settings do not currently support flag-ifying the
40+
# alias of a setting: https://github.com/NixOS/nix/issues/10989
41+
nix flake lock "$lockfileSummaryFlake" --commit-lock-file --option commit-lockfile-summary "$testSummary"
42+
[[ -e "$lockfileSummaryFlake/flake.lock" ]]
43+
[[ -z $(git -C "$lockfileSummaryFlake" diff main || echo failed) ]]
44+
[[ "$(git -C "$lockfileSummaryFlake" log --format=%s -n 1)" = "$testSummary" ]]

tests/functional/flakes/common.sh

+32
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,44 @@ EOF
3838
}
3939

4040
createSimpleGitFlake() {
41+
requireGit
4142
local flakeDir="$1"
4243
writeSimpleFlake "$flakeDir"
4344
git -C "$flakeDir" add flake.nix simple.nix shell.nix simple.builder.sh config.nix
4445
git -C "$flakeDir" commit -m 'Initial'
4546
}
4647

48+
# Create a simple Git flake and add it to the registry as "flake1".
49+
createFlake1() {
50+
flake1Dir="$TEST_ROOT/flake1"
51+
createGitRepo "$flake1Dir" ""
52+
createSimpleGitFlake "$flake1Dir"
53+
nix registry add --registry "$registry" flake1 "git+file://$flake1Dir"
54+
}
55+
56+
createFlake2() {
57+
flake2Dir="$TEST_ROOT/flake 2"
58+
percentEncodedFlake2Dir="$TEST_ROOT/flake%202"
59+
60+
# Give one repo a non-main initial branch.
61+
createGitRepo "$flake2Dir" "--initial-branch=main"
62+
63+
cat > "$flake2Dir/flake.nix" <<EOF
64+
{
65+
description = "Fnord";
66+
67+
outputs = { self, flake1 }: rec {
68+
packages.$system.bar = flake1.packages.$system.foo;
69+
};
70+
}
71+
EOF
72+
73+
git -C "$flake2Dir" add flake.nix
74+
git -C "$flake2Dir" commit -m 'Initial'
75+
76+
nix registry add --registry "$registry" flake2 "git+file://$percentEncodedFlake2Dir"
77+
}
78+
4779
writeDependentFlake() {
4880
local flakeDir="$1"
4981
cat > "$flakeDir/flake.nix" <<EOF

tests/functional/flakes/dubious-query.sh

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
source ./common.sh
44

5-
requireGit
6-
7-
repoDir="$TEST_ROOT/repo"
8-
createGitRepo "$repoDir"
9-
createSimpleGitFlake "$repoDir"
5+
createFlake1
6+
repoDir="$flake1Dir"
107

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

tests/functional/flakes/edit.sh

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
source ./common.sh
44

5-
requireGit
6-
7-
flake1Dir=$TEST_ROOT/flake1
8-
9-
createGitRepo "$flake1Dir"
10-
createSimpleGitFlake "$flake1Dir"
5+
createFlake1
116

127
export EDITOR=cat
138
nix edit "$flake1Dir#" | grepQuiet simple.builder.sh

0 commit comments

Comments
 (0)