tests: add small testcase for output cycle detection

Change-Id: I186937dfbca4d051e5ad860239720816429a0a8e
This commit is contained in:
Maximilian Bosch
2025-08-23 16:23:35 +02:00
parent f7871fcb57
commit 312e90f4b6
3 changed files with 36 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
with import ./config.nix;
rec {
dep = import ./dependencies.nix {};
cycle = mkDerivation {
name = "cycle";
inherit dep;
outputs = [ "foo" "bar" "baz" ];
builder = builtins.toFile "builder.sh" ''
mkdir -p $foo/bin $bar/lib $baz/share
echo $bar > $foo/bin/alarm
echo $baz > $bar/lib/libfoo
echo $foo > $baz/share/lalala
'';
};
as_dependency = mkDerivation {
name = "depends-on-cycle";
inherit cycle;
builder = builtins.toFile "builder.sh" ''
touch $out
'';
};
}
+1
View File
@@ -173,6 +173,7 @@ functional_tests_scripts = [
'regression-reference-checks.sh',
'redirected-filter-source.sh',
'daemon-trust.sh',
'output-cycles.sh',
]
# Plugin tests require shared libraries support.
+10
View File
@@ -0,0 +1,10 @@
source common.sh
clearStore
(! nix-build check-outputs.nix -A cycle) 2>&1 | grepQuiet "cycle detected in build of '.*' in the references of output 'bar' from output 'foo'"
error="$(! nix-build check-outputs.nix -A as_dependency 2>&1)"
grepQuiet "cycle detected in build of '.*' in the references of output 'bar' from output 'foo'" <<<"$error"
grepQuiet "error: 1 dependencies of derivation" <<<"$error"