forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run with `nix-build -A tests.problems`
- Loading branch information
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ nixpkgs }: | ||
let | ||
pkgs = import nixpkgs { | ||
system = "x86_64-linux"; | ||
overlays = [ ]; | ||
config = { }; | ||
}; | ||
in | ||
pkgs.stdenvNoCC.mkDerivation { | ||
pname = "a"; | ||
version = "0"; | ||
meta.problems = { | ||
removal.message = "This package has been abandoned upstream and will be removed"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
error: Package ‘a-0’ in /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-default.nix:11 has some problem that must be acknowledged, refusing to evaluate. | ||
|
||
|
||
|
||
Package problems: | ||
|
||
- removal: This package has been abandoned upstream and will be removed | ||
|
||
You can use it anyway by ignoring its problems, using one of the | ||
following methods: | ||
|
||
a) For `nixos-rebuild` you can add "warn" or "ignore" entries to | ||
`nixpkgs.config.problems.handlers` inside configuration.nix, | ||
like this: | ||
|
||
{ | ||
nixpkgs.config.problems.handlers = { | ||
"a"."removal" = "warn"; | ||
}; | ||
} | ||
|
||
b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add | ||
"warn" or "ignore" to `problems.handlers` in | ||
~/.config/nixpkgs/config.nix, like this: | ||
|
||
{ | ||
problems.handlers = { | ||
"a"."removal" = "warn"; | ||
}; | ||
} | ||
|
||
(use '--show-trace' to show detailed location information) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
lib, | ||
nixVersions, | ||
runCommandNoCC, | ||
removeReferencesTo, | ||
path, | ||
}: | ||
let | ||
nixpkgs = lib.cleanSource path; | ||
in | ||
lib.mapAttrs ( | ||
name: _: | ||
let | ||
nixFile = "${./cases + "/${name}/default.nix"}"; | ||
result = runCommandNoCC "test-problems-${name}" { | ||
nativeBuildInputs = [ | ||
removeReferencesTo | ||
]; | ||
} '' | ||
export NIX_STATE_DIR=$(mktemp -d) | ||
mkdir $out | ||
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 nixVersions.minimum}/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[@]}" > >(tee $out/stdout) 2> >(tee $out/stderr) | ||
set +e | ||
echo "$?" > $out/code | ||
echo "Command exited with code $(<$out/code)" | ||
remove-references-to -t ${nixFile} $out/* | ||
''; | ||
checker = runCommandNoCC "test-problems-check-${name}" { } '' | ||
if ! diff ${result}/stderr ${./cases + "/${name}/expected-stderr"}; then | ||
echo "Output of $(< ${result}/command) does not match what was expected (${result}/stderr)" | ||
exit 1 | ||
fi | ||
touch $out | ||
''; | ||
in | ||
lib.nameValuePair name checker | ||
) (builtins.readDir ./cases) |