From 608b0265e104b4a97f51e5745b1a32078770f3cf Mon Sep 17 00:00:00 2001 From: Dan Peebles Date: Sat, 16 Apr 2016 19:58:26 -0400 Subject: [PATCH] Print out all bad references/requisites at once Also updates tests to check for new information. Fixes #799 --- src/libstore/build.cc | 15 +++++++++++++-- tests/check-reqs.sh | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index ba3f3a371..4b1c177fe 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -2775,14 +2775,25 @@ void DerivationGoal::registerOutputs() } else used = references; + PathSet badPaths; + for (auto & i : used) if (allowed) { if (spec.find(i) == spec.end()) - throw BuildError(format("output ‘%1%’ is not allowed to refer to path ‘%2%’") % actualPath % i); + badPaths.insert(i); } else { if (spec.find(i) != spec.end()) - throw BuildError(format("output ‘%1%’ is not allowed to refer to path ‘%2%’") % actualPath % i); + badPaths.insert(i); } + + if (!badPaths.empty()) { + string badPathsStr; + for (auto & i : badPaths) { + badPathsStr += "\n\t"; + badPathsStr += i; + } + throw BuildError(format("output ‘%1%’ is not allowed to refer to the following paths:%2%") % actualPath % badPathsStr); + } }; checkRefs("allowedReferences", true, false); diff --git a/tests/check-reqs.sh b/tests/check-reqs.sh index 8b2454915..77689215d 100644 --- a/tests/check-reqs.sh +++ b/tests/check-reqs.sh @@ -6,7 +6,8 @@ nix-build -o $RESULT check-reqs.nix -A test1 (! nix-build -o $RESULT check-reqs.nix -A test2) (! nix-build -o $RESULT check-reqs.nix -A test3) -(! nix-build -o $RESULT check-reqs.nix -A test4) +(! nix-build -o $RESULT check-reqs.nix -A test4) 2>&1 | grep -q 'check-reqs-dep1' +(! nix-build -o $RESULT check-reqs.nix -A test4) 2>&1 | grep -q 'check-reqs-dep2' (! nix-build -o $RESULT check-reqs.nix -A test5) (! nix-build -o $RESULT check-reqs.nix -A test6)