Skip to content

Commit 55016b6

Browse files
committed
Test nix build --json return output paths in floating CA case
Adding a test to ensure there is no regression. The tests that are split out of `tests/build.sh` are ones that don't yet work with CA derivation. I have not yet evaluated whether they should or not. This behavior, reported missing in issue #4661, already got fixed in PR #4818, but didn't get a test case then.
1 parent c184566 commit 55016b6

File tree

6 files changed

+73
-61
lines changed

6 files changed

+73
-61
lines changed

tests/build-delete.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
source common.sh
2+
3+
clearStore
4+
5+
set -o pipefail
6+
7+
# https://github.com/NixOS/nix/issues/6572
8+
issue_6572_independent_outputs() {
9+
nix build -f multiple-outputs.nix --json independent --no-link > $TEST_ROOT/independent.json
10+
11+
# Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
12+
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
13+
nix-store --delete "$p" # Clean up for next test
14+
15+
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
16+
nix-store --delete "$(jq -r <$TEST_ROOT/independent.json .[0].outputs.first)"
17+
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
18+
cmp $p <<EOF
19+
first
20+
second
21+
EOF
22+
nix-store --delete "$p" # Clean up for next test
23+
24+
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
25+
nix-store --delete "$(jq -r <$TEST_ROOT/independent.json .[0].outputs.second)"
26+
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
27+
cmp $p <<EOF
28+
first
29+
second
30+
EOF
31+
nix-store --delete "$p" # Clean up for next test
32+
}
33+
issue_6572_independent_outputs
34+
35+
36+
# https://github.com/NixOS/nix/issues/6572
37+
issue_6572_dependent_outputs() {
38+
39+
nix build -f multiple-outputs.nix --json a --no-link > $TEST_ROOT/a.json
40+
41+
# # Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
42+
p=$(nix build -f multiple-outputs.nix use-a --no-link --print-out-paths)
43+
nix-store --delete "$p" # Clean up for next test
44+
45+
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
46+
nix-store --delete "$(jq -r <$TEST_ROOT/a.json .[0].outputs.second)"
47+
p=$(nix build -f multiple-outputs.nix use-a --no-link --print-out-paths)
48+
cmp $p <<EOF
49+
first
50+
second
51+
EOF
52+
nix-store --delete "$p" # Clean up for next test
53+
}
54+
if isDaemonNewer "2.12pre0"; then
55+
issue_6572_dependent_outputs
56+
fi

tests/build.sh

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -107,62 +107,3 @@ nix build --impure -f multiple-outputs.nix --json e --no-link | jq --exit-status
107107
(.drvPath | match(".*multiple-outputs-e.drv")) and
108108
(.outputs | keys == ["a_a", "b"]))
109109
'
110-
111-
testNormalization () {
112-
clearStore
113-
outPath=$(nix-build ./simple.nix --no-out-link)
114-
test "$(stat -c %Y $outPath)" -eq 1
115-
}
116-
117-
testNormalization
118-
119-
# https://github.com/NixOS/nix/issues/6572
120-
issue_6572_independent_outputs() {
121-
nix build -f multiple-outputs.nix --json independent --no-link > $TEST_ROOT/independent.json
122-
123-
# Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
124-
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
125-
nix-store --delete "$p" # Clean up for next test
126-
127-
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
128-
nix-store --delete "$(jq -r <$TEST_ROOT/independent.json .[0].outputs.first)"
129-
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
130-
cmp $p <<EOF
131-
first
132-
second
133-
EOF
134-
nix-store --delete "$p" # Clean up for next test
135-
136-
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
137-
nix-store --delete "$(jq -r <$TEST_ROOT/independent.json .[0].outputs.second)"
138-
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
139-
cmp $p <<EOF
140-
first
141-
second
142-
EOF
143-
nix-store --delete "$p" # Clean up for next test
144-
}
145-
issue_6572_independent_outputs
146-
147-
148-
# https://github.com/NixOS/nix/issues/6572
149-
issue_6572_dependent_outputs() {
150-
151-
nix build -f multiple-outputs.nix --json a --no-link > $TEST_ROOT/a.json
152-
153-
# # Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
154-
p=$(nix build -f multiple-outputs.nix use-a --no-link --print-out-paths)
155-
nix-store --delete "$p" # Clean up for next test
156-
157-
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
158-
nix-store --delete "$(jq -r <$TEST_ROOT/a.json .[0].outputs.second)"
159-
p=$(nix build -f multiple-outputs.nix use-a --no-link --print-out-paths)
160-
cmp $p <<EOF
161-
first
162-
second
163-
EOF
164-
nix-store --delete "$p" # Clean up for next test
165-
}
166-
if isDaemonNewer "2.12pre0"; then
167-
issue_6572_dependent_outputs
168-
fi

tests/ca/new-build-cmd.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source common.sh
2+
3+
export NIX_TESTS_CA_BY_DEFAULT=1
4+
cd ..
5+
source ./build.sh

tests/ca/recursive.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ requireDaemonNewerThan "2.4pre20210623"
77
export NIX_TESTS_CA_BY_DEFAULT=1
88
cd ..
99
source ./recursive.sh
10-
11-

tests/local.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ nix_tests = \
2121
binary-cache.sh \
2222
multiple-outputs.sh \
2323
ca/build.sh \
24+
ca/new-build-cmd.sh \
2425
nix-build.sh \
2526
gc-concurrent.sh \
2627
repair.sh \
@@ -103,6 +104,8 @@ nix_tests = \
103104
ssh-relay.sh \
104105
plugins.sh \
105106
build.sh \
107+
build-delete.sh \
108+
output-normalization.sh \
106109
ca/nix-run.sh \
107110
selfref-gc.sh ca/selfref-gc.sh \
108111
db-migration.sh \

tests/output-normalization.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source common.sh
2+
3+
testNormalization () {
4+
clearStore
5+
outPath=$(nix-build ./simple.nix --no-out-link)
6+
test "$(stat -c %Y $outPath)" -eq 1
7+
}
8+
9+
testNormalization

0 commit comments

Comments
 (0)