mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-26 18:24:53 +00:00
This drops matching on the truncated stack trace marker as that only
appears if the stack trace is actually long enough. In some cases the
stack trace is simply too short so Nix prints it out entirely. Then
the tests fail and I'm unhappy.
This was caused by a90d993610 which to the best of my understanding
forces the error message very early in the eval and thus doesn't have
a very long stack trace.
76 lines
2.3 KiB
Nix
76 lines
2.3 KiB
Nix
{
|
|
lib,
|
|
nix,
|
|
runCommand,
|
|
removeReferencesTo,
|
|
path,
|
|
gitMinimal,
|
|
}:
|
|
let
|
|
nixpkgs = lib.cleanSource path;
|
|
unitResult = import ./unit.nix { inherit lib; };
|
|
in
|
|
assert lib.assertMsg (unitResult == [ ])
|
|
"problems/unit.nix failing: ${lib.generators.toPretty { } unitResult}";
|
|
lib.mapAttrs (
|
|
name: _:
|
|
let
|
|
nixFile = "${./cases + "/${name}/default.nix"}";
|
|
result = runCommand "test-problems-${name}" { nativeBuildInputs = [ removeReferencesTo ]; } ''
|
|
export NIX_STATE_DIR=$(mktemp -d)
|
|
mkdir $out
|
|
|
|
|
|
command=()
|
|
${lib.optionalString (builtins.pathExists (./cases + "/${name}/env.nix")) ''
|
|
command+=(
|
|
env
|
|
${lib.concatMapAttrsStringSep "\n" (name: value: "${name}=${toString value}") (
|
|
import (./cases + "/${name}/env.nix")
|
|
)}
|
|
)
|
|
''}
|
|
command+=(
|
|
# FIXME: Using this version because it doesn't print a trace by default
|
|
# Probably should have some regex-style error matching instead
|
|
"${lib.getBin nix}/bin/nix-instantiate"
|
|
${nixFile}
|
|
# Readonly mode because we don't need to write anything to the store
|
|
"--readonly-mode"
|
|
"--arg"
|
|
"nixpkgs"
|
|
"${nixpkgs}"
|
|
)
|
|
|
|
echo "''${command[*]@Q}" > $out/command
|
|
echo "Running ''${command[*]@Q}"
|
|
set +e
|
|
"''${command[@]}" >$out/stdout 2>$out/stderr
|
|
set +e
|
|
echo "$?" > $out/code
|
|
echo "Command exited with code $(<$out/code)"
|
|
remove-references-to -t ${nixFile} $out/stderr
|
|
|
|
sed -i 's/^ //' $out/stderr
|
|
|
|
# extract only from the error message to the end, sometimes the stack
|
|
# traces are too short for nix to truncate them and then we've false
|
|
# negative CI results due to unrelated changes in nixpkgs.
|
|
if grep -q '^error: .' $out/stderr; then
|
|
sed -i -n '/^error: ./,$ p' $out/stderr
|
|
fi
|
|
'';
|
|
checker = runCommand "test-problems-check-${name}" { } ''
|
|
if ! PAGER=cat ${lib.getExe gitMinimal} diff --no-index ${
|
|
./cases + "/${name}/expected-stderr"
|
|
} ${result}/stderr ; then
|
|
echo "Output of $(< ${result}/command) does not match what was expected. To adapt:"
|
|
echo "cp ${result}/stderr ${lib.path.removePrefix path ./cases + "/${name}/expected-stderr"}"
|
|
exit 1
|
|
fi
|
|
touch $out
|
|
'';
|
|
in
|
|
checker
|
|
) (builtins.readDir ./cases)
|