testers.testVersion: move from trivial-builders.nix
we will have more testers in the future so they should have their own location putting 'testers' in args will also make it simpler to use multiple testers
This commit is contained in:
parent
daac043257
commit
250ef1ff39
4 changed files with 40 additions and 40 deletions
|
@ -2,7 +2,6 @@
|
|||
, stdenv
|
||||
, fetchurl
|
||||
, nixos
|
||||
, testVersion
|
||||
, testers
|
||||
, hello
|
||||
}:
|
||||
|
@ -19,7 +18,7 @@ stdenv.mkDerivation rec {
|
|||
doCheck = true;
|
||||
|
||||
passthru.tests = {
|
||||
version = testVersion { package = hello; };
|
||||
version = testers.testVersion { package = hello; };
|
||||
|
||||
invariant-under-noXlibs =
|
||||
testers.testEqualDerivation
|
||||
|
|
|
@ -1,4 +1,41 @@
|
|||
{ pkgs, lib, callPackage }:
|
||||
{ pkgs, lib, callPackage, runCommand }:
|
||||
{
|
||||
testEqualDerivation = callPackage ./test-equal-derivation.nix { };
|
||||
|
||||
/* Checks the command output contains the specified version
|
||||
*
|
||||
* Although simplistic, this test assures that the main program
|
||||
* can run. While there's no substitute for a real test case,
|
||||
* it does catch dynamic linking errors and such. It also provides
|
||||
* some protection against accidentally building the wrong version,
|
||||
* for example when using an 'old' hash in a fixed-output derivation.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* passthru.tests.version = testVersion { package = hello; };
|
||||
*
|
||||
* passthru.tests.version = testVersion {
|
||||
* package = seaweedfs;
|
||||
* command = "weed version";
|
||||
* };
|
||||
*
|
||||
* passthru.tests.version = testVersion {
|
||||
* package = key;
|
||||
* command = "KeY --help";
|
||||
* # Wrong '2.5' version in the code. Drop on next version.
|
||||
* version = "2.5";
|
||||
* };
|
||||
*/
|
||||
testVersion =
|
||||
{ package,
|
||||
command ? "${package.meta.mainProgram or package.pname or package.name} --version",
|
||||
version ? package.version,
|
||||
}: runCommand "${package.name}-test-version" { nativeBuildInputs = [ package ]; meta.timeout = 60; } ''
|
||||
if output=$(${command} 2>&1); then
|
||||
grep -Fw "${version}" - <<< "$output"
|
||||
touch $out
|
||||
else
|
||||
echo "$output" >&2 && exit 1
|
||||
fi
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -784,41 +784,4 @@ rec {
|
|||
outputHash = "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5";
|
||||
preferLocalBuild = true;
|
||||
} "mkdir $out";
|
||||
|
||||
/* Checks the command output contains the specified version
|
||||
*
|
||||
* Although simplistic, this test assures that the main program
|
||||
* can run. While there's no substitute for a real test case,
|
||||
* it does catch dynamic linking errors and such. It also provides
|
||||
* some protection against accidentally building the wrong version,
|
||||
* for example when using an 'old' hash in a fixed-output derivation.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* passthru.tests.version = testVersion { package = hello; };
|
||||
*
|
||||
* passthru.tests.version = testVersion {
|
||||
* package = seaweedfs;
|
||||
* command = "weed version";
|
||||
* };
|
||||
*
|
||||
* passthru.tests.version = testVersion {
|
||||
* package = key;
|
||||
* command = "KeY --help";
|
||||
* # Wrong '2.5' version in the code. Drop on next version.
|
||||
* version = "2.5";
|
||||
* };
|
||||
*/
|
||||
testVersion =
|
||||
{ package,
|
||||
command ? "${package.meta.mainProgram or package.pname or package.name} --version",
|
||||
version ? package.version,
|
||||
}: runCommand "${package.name}-test-version" { nativeBuildInputs = [ package ]; meta.timeout = 60; } ''
|
||||
if output=$(${command} 2>&1); then
|
||||
grep -Fw "${version}" - <<< "$output"
|
||||
touch $out
|
||||
else
|
||||
echo "$output" >&2 && exit 1
|
||||
fi
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -1253,6 +1253,7 @@ mapAliases ({
|
|||
terraform_1_0 = throw "terraform_1_0 has been renamed to terraform_1"; # Added 2021-12-08
|
||||
terraform_1_0_0 = throw "terraform_1_0_0 has been renamed to terraform_1"; # Added 2021-06-15
|
||||
tesseract_4 = throw "'tesseract_4' has been renamed to/replaced by 'tesseract4'"; # Converted to throw 2022-02-22
|
||||
testVersion = testers.testVersion; # Added 2022-04-20
|
||||
tex-gyre-bonum-math = throw "'tex-gyre-bonum-math' has been renamed to/replaced by 'tex-gyre-math.bonum'"; # Converted to throw 2022-02-22
|
||||
tex-gyre-pagella-math = throw "'tex-gyre-pagella-math' has been renamed to/replaced by 'tex-gyre-math.pagella'"; # Converted to throw 2022-02-22
|
||||
tex-gyre-schola-math = throw "'tex-gyre-schola-math' has been renamed to/replaced by 'tex-gyre-math.schola'"; # Converted to throw 2022-02-22
|
||||
|
|
Loading…
Reference in a new issue