diff options
author | Artturin <Artturin@artturin.com> | 2022-04-20 16:31:36 +0300 |
---|---|---|
committer | Artturin <Artturin@artturin.com> | 2022-04-22 16:22:40 +0300 |
commit | 250ef1ff392b938415726a9331a30012573efaea (patch) | |
tree | ed7eb8b03608f8ca9701f7f413fc378226daf9f1 /pkgs/build-support | |
parent | daac04325706fe506e576b1d6e7405367c386e11 (diff) | |
download | nixpkgs-250ef1ff392b938415726a9331a30012573efaea.tar nixpkgs-250ef1ff392b938415726a9331a30012573efaea.tar.gz nixpkgs-250ef1ff392b938415726a9331a30012573efaea.tar.bz2 nixpkgs-250ef1ff392b938415726a9331a30012573efaea.tar.lz nixpkgs-250ef1ff392b938415726a9331a30012573efaea.tar.xz nixpkgs-250ef1ff392b938415726a9331a30012573efaea.tar.zst nixpkgs-250ef1ff392b938415726a9331a30012573efaea.zip |
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
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/testers/default.nix | 39 | ||||
-rw-r--r-- | pkgs/build-support/trivial-builders.nix | 37 |
2 files changed, 38 insertions, 38 deletions
diff --git a/pkgs/build-support/testers/default.nix b/pkgs/build-support/testers/default.nix index 1d1effa3730..b63ba5742b2 100644 --- a/pkgs/build-support/testers/default.nix +++ b/pkgs/build-support/testers/default.nix @@ -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 + ''; } diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index 1f9543f808e..bd14971fe78 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -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 - ''; } |