Skip to content

Commit 3f0dd78

Browse files
committed
Add a test for nix flake check building checks
1 parent 564593b commit 3f0dd78

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/functional/flakes/check.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,35 @@ EOF
135135

136136
checkRes=$(nix flake check --all-systems $flakeDir 2>&1 && fail "nix flake check --all-systems should have failed" || true)
137137
echo "$checkRes" | grepQuiet "formatter.system-1"
138+
139+
# Test whether `nix flake check` builds checks.
140+
cat > $flakeDir/flake.nix <<EOF
141+
{
142+
outputs = { self }: {
143+
checks.$system.foo = with import ./config.nix; mkDerivation {
144+
name = "simple";
145+
buildCommand = "mkdir \$out";
146+
};
147+
};
148+
}
149+
EOF
150+
151+
cp "${config_nix}" "$flakeDir/"
152+
153+
expectStderr 0 nix flake check "$flakeDir" | grepQuiet 'running 1 flake check'
154+
155+
cat > $flakeDir/flake.nix <<EOF
156+
{
157+
outputs = { self }: {
158+
checks.$system.foo = with import ./config.nix; mkDerivation {
159+
name = "simple";
160+
buildCommand = "false";
161+
};
162+
};
163+
}
164+
EOF
165+
166+
# FIXME: error code 100 doesn't get propagated from the daemon.
167+
if ! isTestOnNixOS; then
168+
expectStderr 100 nix flake check "$flakeDir" | grepQuiet 'builder failed with exit code 1'
169+
fi

0 commit comments

Comments
 (0)