Merge pull request #169449 from Artturin/movetesting1

testers.testVersion: move from trivial-builders.nix
This commit is contained in:
Artturi 2022-04-23 06:06:16 +03:00 committed by GitHub
commit 62866bc352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
75 changed files with 229 additions and 220 deletions

View File

@ -6,7 +6,7 @@ When using Nix, you will frequently need to download source code and other files
Because fixed output derivations are _identified_ by their hash, a common mistake is to update a fetcher's URL or a version parameter, without updating the hash. **This will cause the old contents to be used.** So remember to always invalidate the hash argument.
For those who develop and maintain fetchers, a similar problem arises with changes to the implementation of a fetcher. These may cause a fixed output derivation to fail, but won't normally be caught by tests because the supposed output is already in the store or cache. For the purpose of testing, you can use a trick that is embodied by the [`invalidateFetcherByDrvHash`](#sec-pkgs-invalidateFetcherByDrvHash) function. It uses the derivation `name` to create a unique output path per fetcher implementation, defeating the caching precisely where it would be harmful.
For those who develop and maintain fetchers, a similar problem arises with changes to the implementation of a fetcher. These may cause a fixed output derivation to fail, but won't normally be caught by tests because the supposed output is already in the store or cache. For the purpose of testing, you can use a trick that is embodied by the [`invalidateFetcherByDrvHash`](#tester-invalidateFetcherByDrvHash) function. It uses the derivation `name` to create a unique output path per fetcher implementation, defeating the caching precisely where it would be harmful.
## `fetchurl` and `fetchzip` {#fetchurl}

View File

@ -7,5 +7,4 @@
</para>
<xi:include href="special/fhs-environments.section.xml" />
<xi:include href="special/mkshell.section.xml" />
<xi:include href="special/invalidateFetcherByDrvHash.section.xml" />
</chapter>

View File

@ -1,31 +0,0 @@
## `invalidateFetcherByDrvHash` {#sec-pkgs-invalidateFetcherByDrvHash}
Use the derivation hash to invalidate the output via name, for testing.
Type: `(a@{ name, ... } -> Derivation) -> a -> Derivation`
Normally, fixed output derivations can and should be cached by their output
hash only, but for testing we want to re-fetch everytime the fetcher changes.
Changes to the fetcher become apparent in the drvPath, which is a hash of
how to fetch, rather than a fixed store path.
By inserting this hash into the name, we can make sure to re-run the fetcher
every time the fetcher changes.
This relies on the assumption that Nix isn't clever enough to reuse its
database of local store contents to optimize fetching.
You might notice that the "salted" name derives from the normal invocation,
not the final derivation. `invalidateFetcherByDrvHash` has to invoke the fetcher
function twice: once to get a derivation hash, and again to produce the final
fixed output derivation.
Example:
tests.fetchgit = invalidateFetcherByDrvHash fetchgit {
name = "nix-source";
url = "https://github.com/NixOS/nix";
rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";
sha256 = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY=";
};

View File

@ -0,0 +1,82 @@
# Testers {#chap-testers}
This chapter describes several testing builders which are available in the <literal>testers</literal> namespace.
## `testVersion` {#tester-testVersion}
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:
```nix
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";
};
```
## `testEqualDerivation` {#tester-testEqualDerivation}
Checks that two packages produce the exact same build instructions.
This can be used to make sure that a certain difference of configuration,
such as the presence of an overlay does not cause a cache miss.
When the derivations are equal, the return value is an empty file.
Otherwise, the build log explains the difference via `nix-diff`.
Example:
```nix
testEqualDerivation
"The hello package must stay the same when enabling checks."
hello
(hello.overrideAttrs(o: { doCheck = true; }))
```
## `invalidateFetcherByDrvHash` {#tester-invalidateFetcherByDrvHash}
Use the derivation hash to invalidate the output via name, for testing.
Type: `(a@{ name, ... } -> Derivation) -> a -> Derivation`
Normally, fixed output derivations can and should be cached by their output
hash only, but for testing we want to re-fetch everytime the fetcher changes.
Changes to the fetcher become apparent in the drvPath, which is a hash of
how to fetch, rather than a fixed store path.
By inserting this hash into the name, we can make sure to re-run the fetcher
every time the fetcher changes.
This relies on the assumption that Nix isn't clever enough to reuse its
database of local store contents to optimize fetching.
You might notice that the "salted" name derives from the normal invocation,
not the final derivation. `invalidateFetcherByDrvHash` has to invoke the fetcher
function twice: once to get a derivation hash, and again to produce the final
fixed output derivation.
Example:
```nix
tests.fetchgit = invalidateFetcherByDrvHash fetchgit {
name = "nix-source";
url = "https://github.com/NixOS/nix";
rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";
sha256 = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY=";
};
```

View File

@ -25,6 +25,7 @@
<title>Builders</title>
<xi:include href="builders/fetchers.chapter.xml" />
<xi:include href="builders/trivial-builders.chapter.xml" />
<xi:include href="builders/testers.chapter.xml" />
<xi:include href="builders/special.xml" />
<xi:include href="builders/images.xml" />
<xi:include href="hooks/index.xml" />

View File

@ -1,7 +1,7 @@
{ stdenv
, lib
, gitUpdater
, testVersion
, testers
, furnace
, fetchFromGitHub
, cmake
@ -83,7 +83,7 @@ stdenv.mkDerivation rec {
inherit pname version;
rev-prefix = "v";
};
tests.version = testVersion {
tests.version = testers.testVersion {
package = furnace;
# The command always exits with code 1
command = "(furnace --version || [ $? -eq 1 ])";

View File

@ -8,7 +8,7 @@
, flac
, sox
, util-linux
, testVersion
, testers
, whipper
}:
@ -74,7 +74,7 @@ in python3.pkgs.buildPythonApplication rec {
runHook postCheck
'';
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = whipper;
command = "HOME=$TMPDIR whipper --version";
};

View File

@ -29,7 +29,7 @@
, curl
, ApplicationServices
, Foundation
, testVersion
, testers
, imagemagick
}:
@ -120,7 +120,7 @@ stdenv.mkDerivation rec {
'';
passthru.tests.version =
testVersion { package = imagemagick; };
testers.testVersion { package = imagemagick; };
meta = with lib; {
homepage = "http://www.imagemagick.org/";

View File

@ -3,7 +3,7 @@
, cairo, dbus, systemd, gdk-pixbuf, glib, libX11, libXScrnSaver
, wayland, wayland-protocols
, libXinerama, libnotify, pango, xorgproto, librsvg
, testVersion, dunst
, testers, dunst
}:
stdenv.mkDerivation rec {
@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
--set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE"
'';
passthru.tests.version = testVersion { package = dunst; };
passthru.tests.version = testers.testVersion { package = dunst; };
meta = with lib; {
description = "Lightweight and customizable notification daemon";

View File

@ -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

View File

@ -7,7 +7,7 @@
, kjobwidgets
, kxmlgui
, lib
, testVersion
, testers
, k4dirstat
}:
@ -26,7 +26,7 @@ mkDerivation rec {
buildInputs = [ kiconthemes kio kjobwidgets kxmlgui ];
passthru.tests.version =
testVersion {
testers.testVersion {
package = k4dirstat;
command = "k4dirstat -platform offscreen --version &>/dev/stdout";
};

View File

@ -1,4 +1,4 @@
{ lib, rustPlatform, fetchCrate, installShellFiles, testVersion, sigi }:
{ lib, rustPlatform, fetchCrate, installShellFiles, testers, sigi }:
rustPlatform.buildRustPackage rec {
pname = "sigi";
@ -19,7 +19,7 @@ rustPlatform.buildRustPackage rec {
installManPage sigi.1
'';
passthru.tests.version = testVersion { package = sigi; };
passthru.tests.version = testers.testVersion { package = sigi; };
meta = with lib; {
description = "Organizing CLI for people who don't love organizing.";

View File

@ -10,7 +10,7 @@
, installShellFiles
, libsass
, zola
, testVersion
, testers
}:
rustPlatform.buildRustPackage rec {
@ -48,7 +48,7 @@ rustPlatform.buildRustPackage rec {
--bash completions/zola.bash
'';
passthru.tests.version = testVersion { package = zola; };
passthru.tests.version = testers.testVersion { package = zola; };
meta = with lib; {
description = "A fast static site generator with everything built-in";

View File

@ -31,7 +31,7 @@
, zip
, zlib
, withGTK3 ? true, gtk3, gtk2
, testVersion
, testers
, palemoon
}:
@ -211,7 +211,7 @@ stdenv.mkDerivation rec {
)"
update-source-version ${pname} "$version"
'';
tests.version = testVersion {
tests.version = testers.testVersion {
package = palemoon;
};
};

View File

@ -1,4 +1,4 @@
{ lib, buildGoModule, fetchFromGitHub, testVersion, ocm }:
{ lib, buildGoModule, fetchFromGitHub, testers, ocm }:
buildGoModule rec {
pname = "ocm";
@ -18,7 +18,7 @@ buildGoModule rec {
ln -s $GOPATH/bin/ocm ocm
'';
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = ocm;
command = "ocm version";
};

View File

@ -1,4 +1,4 @@
{ lib, buildGoModule, fetchFromGitHub, testVersion, odo }:
{ lib, buildGoModule, fetchFromGitHub, testers, odo }:
buildGoModule rec {
pname = "odo";
@ -22,7 +22,7 @@ buildGoModule rec {
cp -a odo $out/bin
'';
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = odo;
command = "odo version";
version = "v${version}";

View File

@ -4,7 +4,7 @@
, libkrb5
, git
, installShellFiles
, testVersion
, testers
, openshift
}:
@ -52,7 +52,7 @@ buildGoModule rec {
installShellCompletion --zsh contrib/completions/zsh/*
'';
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = openshift;
command = "oc version";
version = "v${version}";

View File

@ -6,7 +6,7 @@
, pythonPackages
, emacs
, ruby
, testVersion
, testers
, which, dtach, openssl, bash, gdb, man
, withEmacs ? true
, withRuby ? true
@ -102,7 +102,7 @@ stdenv.mkDerivation rec {
passthru = {
pythonSourceRoot = "notmuch-${version}/bindings/python";
tests.version = testVersion { package = notmuch; };
tests.version = testers.testVersion { package = notmuch; };
inherit version;
};

View File

@ -1,7 +1,7 @@
{ lib
, fetchFromGitHub
, buildGoModule
, testVersion
, testers
, seaweedfs
}:
@ -21,7 +21,7 @@ buildGoModule rec {
subPackages = [ "weed" ];
passthru.tests.version =
testVersion { package = seaweedfs; command = "weed version"; };
testers.testVersion { package = seaweedfs; command = "weed version"; };
meta = with lib; {
description = "Simple and highly scalable distributed file system";

View File

@ -7,7 +7,7 @@
, makeWrapper
, makeDesktopItem
, copyDesktopItems
, testVersion
, testers
, key
}:
@ -98,7 +98,7 @@ in stdenv.mkDerivation rec {
'';
passthru.tests.version =
testVersion {
testers.testVersion {
package = key;
command = "KeY --help";
};
@ -118,4 +118,3 @@ in stdenv.mkDerivation rec {
platforms = platforms.all;
};
}

View File

@ -4,7 +4,7 @@
, installShellFiles
, git
, nix-update-script
, testVersion
, testers
, git-machete
}:

View File

@ -1,4 +1,4 @@
{ lib, buildGoModule, fetchFromGitHub, testVersion, scmpuff }:
{ lib, buildGoModule, fetchFromGitHub, testers, scmpuff }:
buildGoModule rec {
pname = "scmpuff";
@ -15,7 +15,7 @@ buildGoModule rec {
ldflags = [ "-s" "-w" "-X main.VERSION=${version}" ];
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = scmpuff;
command = "scmpuff version";
};

View File

@ -1,4 +1,4 @@
{ lib, buildGoModule, fetchFromGitHub, testVersion, git-sizer }:
{ lib, buildGoModule, fetchFromGitHub, testers, git-sizer }:
buildGoModule rec {
pname = "git-sizer";
@ -17,7 +17,7 @@ buildGoModule rec {
doCheck = false;
passthru.tests.vesion = testVersion {
passthru.tests.vesion = testers.testVersion {
package = git-sizer;
};

View File

@ -9,7 +9,7 @@
, Security
, SystemConfiguration
, libiconv
, testVersion
, testers
, jujutsu
}:
@ -44,7 +44,7 @@ rustPlatform.buildRustPackage rec {
];
passthru.tests = {
version = testVersion {
version = testers.testVersion {
package = jujutsu;
command = "jj --version";
};

View File

@ -11,7 +11,7 @@
, lib
, fetchFromGitHub
# For tests
, testVersion
, testers
, runCommand
, fetchurl
# Main build tools
@ -230,7 +230,7 @@ let self = stdenv.mkDerivation rec {
HandBrakeCLI -i ${testMkv} -o test.mkv -e x264 -q 20 -B 160
test -e test.mkv
'';
version = testVersion { package = self; command = "HandBrakeCLI --version"; };
version = testers.testVersion { package = self; command = "HandBrakeCLI --version"; };
};
meta = with lib; {

View File

@ -6,7 +6,7 @@
, gpgme
, libassuan
, lvm2
, testVersion
, testers
, podman-tui
}:
buildGoModule rec {
@ -33,7 +33,7 @@ buildGoModule rec {
ldflags = [ "-s" "-w" ];
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = podman-tui;
command = "podman-tui version";
version = "v${version}";

View File

@ -1,4 +1,18 @@
{ pkgs, lib, callPackage }:
{ pkgs, lib, callPackage, runCommand }:
# Documentation is in doc/builders/testers.chapter.md
{
testEqualDerivation = callPackage ./test-equal-derivation.nix { };
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
'';
}

View File

@ -1,22 +1,5 @@
{ lib, runCommand, emptyFile, nix-diff }:
/*
Checks that two packages produce the exact same build instructions.
This can be used to make sure that a certain difference of configuration,
such as the presence of an overlay does not cause a cache miss.
When the derivations are equal, the return value is an empty file.
Otherwise, the build log explains the difference via `nix-diff`.
Example:
testEqualDerivation
"The hello package must stay the same when enabling checks."
hello
(hello.overrideAttrs(o: { doCheck = true; }))
*/
assertion: a: b:
let
drvA = builtins.unsafeDiscardOutputDependency a.drvPath or (throw "testEqualDerivation second argument must be a package");

View File

@ -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
'';
}

View File

@ -1,4 +1,4 @@
{ lib, buildGoModule, fetchFromGitHub, testVersion }:
{ lib, buildGoModule, fetchFromGitHub, testers }:
let self = buildGoModule rec {
pname = "go-jsonnet";
@ -17,7 +17,7 @@ let self = buildGoModule rec {
subPackages = [ "cmd/jsonnet*" ];
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = self;
version = "v${version}";
};

View File

@ -2,7 +2,7 @@
, stdenv
, fetchFromGitHub
, fetchpatch
, testVersion
, testers
, uasm
}:
@ -47,7 +47,7 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = uasm;
command = "uasm -h";
version = "v${version}";

View File

@ -7,7 +7,7 @@
, pony
, junit-xml
, pythonOlder
, testVersion
, testers
}:
let self = buildPythonApplication rec {
@ -31,7 +31,7 @@ let self = buildPythonApplication rec {
propagatedBuildInputs = [ click glob2 parso pony junit-xml ];
passthru.tests.version = testVersion { package = self; };
passthru.tests.version = testers.testVersion { package = self; };
meta = with lib; {
description = "mutation testing system for Python, with a strong focus on ease of use";

View File

@ -9,7 +9,7 @@
, pytest-check
, pythonOlder
, markdown
, testVersion
, testers
, tomlkit
, staticjinja
, callPackage
@ -53,7 +53,7 @@ buildPythonPackage rec {
'';
passthru.tests = {
version = testVersion { package = staticjinja; };
version = testers.testVersion { package = staticjinja; };
minimal-template = callPackage ./test-minimal-template {};
};

View File

@ -19,7 +19,7 @@
, zsync
, OVMF
, quickemu
, testVersion
, testers
}:
let
runtimePaths = [
@ -73,7 +73,7 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
passthru.tests = testVersion { package = quickemu; };
passthru.tests = testers.testVersion { package = quickemu; };
meta = with lib; {
description = "Quickly create and run optimised Windows, macOS and Linux desktop virtual machines";

View File

@ -4,7 +4,7 @@
, fetchFromGitHub
, llvmPackages
, rustPlatform
, testVersion
, testers
}:
let
@ -27,7 +27,7 @@ let
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
passthru.tests.version = testVersion { inherit package; };
passthru.tests.version = testers.testVersion { inherit package; };
meta = with lib; {
description = "An interface to send PartiQL statements to Amazon Quantum Ledger Database (QLDB)";

View File

@ -1,4 +1,4 @@
{ lib, buildGoModule, fetchFromGitHub, testVersion, bingo }:
{ lib, buildGoModule, fetchFromGitHub, testers, bingo }:
buildGoModule rec {
pname = "bingo";
@ -26,7 +26,7 @@ buildGoModule rec {
ldflags = [ "-s" "-w" ];
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = bingo;
command = "bingo version";
version = "v${version}";

View File

@ -3,7 +3,7 @@
, fetchFromGitHub
, protobuf
, git
, testVersion
, testers
, buf
, installShellFiles
}:
@ -70,7 +70,7 @@ buildGoModule rec {
runHook postInstall
'';
passthru.tests.version = testVersion { package = buf; };
passthru.tests.version = testers.testVersion { package = buf; };
meta = with lib; {
homepage = "https://buf.build";

View File

@ -2,7 +2,7 @@
, buildGoModule
, fetchFromGitHub
, fq
, testVersion
, testers
}:
buildGoModule rec {
@ -26,7 +26,7 @@ buildGoModule rec {
subPackages = [ "." ];
passthru.tests = testVersion { package = fq; };
passthru.tests = testers.testVersion { package = fq; };
meta = with lib; {
description = "jq for binary formats";

View File

@ -1,4 +1,4 @@
{ lib, buildGoModule, fetchFromGitHub, testVersion, gojq }:
{ lib, buildGoModule, fetchFromGitHub, testers, gojq }:
buildGoModule rec {
pname = "gojq";
@ -15,7 +15,7 @@ buildGoModule rec {
ldflags = [ "-s" "-w" ];
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = gojq;
};

View File

@ -1,4 +1,4 @@
{ lib, buildGoModule, fetchFromGitHub, testVersion, kube-linter }:
{ lib, buildGoModule, fetchFromGitHub, testers, kube-linter }:
buildGoModule rec {
pname = "kube-linter";
@ -17,7 +17,7 @@ buildGoModule rec {
"-s" "-w" "-X golang.stackrox.io/kube-linter/internal/version.version=${version}"
];
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = kube-linter;
command = "kube-linter version";
};

View File

@ -1,4 +1,4 @@
{ cmake, fetchFromGitHub, lib, ninja, stdenv, testVersion, quick-lint-js }:
{ cmake, fetchFromGitHub, lib, ninja, stdenv, testers, quick-lint-js }:
stdenv.mkDerivation rec {
@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
doCheck = true;
passthru.tests = {
version = testVersion { package = quick-lint-js; };
version = testers.testVersion { package = quick-lint-js; };
};
meta = with lib; {

View File

@ -2,7 +2,7 @@
, cairo, fontconfig, freetype, gdk-pixbuf, glib
, glibc, gtk2, libX11, nspr, nss, pango
, libxcb, libXi, libXrender, libXext, dbus
, testVersion, chromedriver
, testers, chromedriver
}:
let
@ -56,7 +56,7 @@ in stdenv.mkDerivation rec {
wrapProgram "$out/bin/chromedriver" --prefix LD_LIBRARY_PATH : "${libs}"
'';
passthru.tests.version = testVersion { package = chromedriver; };
passthru.tests.version = testers.testVersion { package = chromedriver; };
meta = with lib; {
homepage = "https://chromedriver.chromium.org/";

View File

@ -1,4 +1,4 @@
{ lib, buildGoModule, fetchFromGitHub, installShellFiles, testVersion, sq }:
{ lib, buildGoModule, fetchFromGitHub, installShellFiles, testers, sq }:
buildGoModule rec {
pname = "sq";
version = "0.15.4";
@ -29,7 +29,7 @@ buildGoModule rec {
'';
passthru.tests = {
version = testVersion { package = sq; };
version = testers.testVersion { package = sq; };
};
meta = with lib; {

View File

@ -1,4 +1,4 @@
{ lib, stdenv, nodejs, fetchzip, testVersion, yarn }:
{ lib, stdenv, nodejs, fetchzip, testers, yarn }:
stdenv.mkDerivation rec {
pname = "yarn";
@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
ln -s $out/libexec/yarn/bin/yarn.js $out/bin/yarnpkg
'';
passthru.tests = testVersion { package = yarn; };
passthru.tests = testers.testVersion { package = yarn; };
meta = with lib; {
homepage = "https://yarnpkg.com/";

View File

@ -11,7 +11,7 @@
, rhash
, tinyxml-2
, help2man
, testVersion
, testers
, lgogdownloader
}:
@ -43,7 +43,7 @@ stdenv.mkDerivation rec {
];
passthru.tests = {
version = testVersion { package = lgogdownloader; };
version = testers.testVersion { package = lgogdownloader; };
};
meta = with lib; {

View File

@ -4,7 +4,7 @@
, fetchurl
, makeDesktopItem
, copyDesktopItems
, testVersion
, testers
, opensupaplex
, SDL2
, SDL2_mixer
@ -62,7 +62,7 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = opensupaplex;
command = "opensupaplex --help";
version = "v${version}";

View File

@ -26,7 +26,7 @@
, vulkan-loader
, shaderc
, testVersion
, testers
, warzone2100
, withVideos ? false
@ -104,7 +104,7 @@ stdenv.mkDerivation rec {
'';
passthru.tests = {
version = testVersion {
version = testers.testVersion {
package = warzone2100;
# The command always exits with code 1
command = "(warzone2100 --version || [ $? -eq 1 ])";

View File

@ -2,7 +2,7 @@
, buildGoModule
, fetchFromGitHub
, promscale
, testVersion
, testers
}:
buildGoModule rec {
@ -40,7 +40,7 @@ buildGoModule rec {
runHook postCheck
'';
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = promscale;
command = "promscale -version";
};

View File

@ -2,7 +2,7 @@
, fetchFromGitHub
, buildGoModule
, stayrtr
, testVersion
, testers
}:
buildGoModule rec {
@ -23,7 +23,7 @@ buildGoModule rec {
"-X main.version=${version}"
];
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = stayrtr;
};

View File

@ -1,4 +1,4 @@
{ stdenv, lib, rustPlatform, fetchFromGitHub, installShellFiles, colmena, testVersion }:
{ stdenv, lib, rustPlatform, fetchFromGitHub, installShellFiles, colmena, testers }:
rustPlatform.buildRustPackage rec {
pname = "colmena";
@ -29,7 +29,7 @@ rustPlatform.buildRustPackage rec {
# We guarantee CLI and Nix API stability for the same minor version
apiVersion = builtins.concatStringsSep "." (lib.take 2 (lib.splitString "." version));
tests.version = testVersion { package = colmena; };
tests.version = testers.testVersion { package = colmena; };
};
meta = with lib; {

View File

@ -12,7 +12,7 @@
# For tests
, _7zz
, testVersion
, testers
}:
let
@ -79,7 +79,7 @@ stdenv.mkDerivation rec {
passthru = {
updateScript = ./update.sh;
tests.version = testVersion {
tests.version = testers.testVersion {
package = _7zz;
command = "7zz --help";
};

View File

@ -2,7 +2,7 @@
, buildDotnetModule
, fetchFromGitHub
, dotnetCorePackages
, testVersion
, testers
, discordchatexporter-cli
}:
@ -29,7 +29,7 @@ buildDotnetModule rec {
passthru = {
updateScript = ./updater.sh;
tests.version = testVersion {
tests.version = testers.testVersion {
package = discordchatexporter-cli;
version = "v${version}";
};

View File

@ -1,7 +1,7 @@
{ lib
, stdenv
, fetchFromGitHub
, testVersion
, testers
, pxz
, xz
}:
@ -34,7 +34,7 @@ stdenv.mkDerivation rec {
"MANDIR=${placeholder "out"}/share/man"
];
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = pxz;
};

View File

@ -1,4 +1,4 @@
{ lib, rustPlatform, fetchFromGitea, protobuf, testVersion, garage }:
{ lib, rustPlatform, fetchFromGitea, protobuf, testers, garage }:
rustPlatform.buildRustPackage rec {
pname = "garage";
version = "0.7.0";
@ -16,7 +16,7 @@ rustPlatform.buildRustPackage rec {
nativeBuildInputs = [ protobuf ];
passthru = {
tests.version = testVersion { package = garage; };
tests.version = testers.testVersion { package = garage; };
};
meta = {

View File

@ -1,7 +1,7 @@
{ lib
, buildGoModule
, fetchFromGitHub
, testVersion
, testers
, adrgen
}:
@ -18,7 +18,7 @@ buildGoModule rec {
vendorSha256 = "sha256-aDtUD+KKKSE0TpSi4+6HXSBMqF/TROZZhT0ox3a8Idk=";
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = adrgen;
command = "adrgen version";
version = "v${version}";

View File

@ -6,7 +6,6 @@
, coreutils
, gawk
, gnum4
, testVersion
, util-linux
}:

View File

@ -8,7 +8,7 @@
, gdk-pixbuf
, atk
, gtk3
, testVersion
, testers
, czkawka
}:
@ -38,7 +38,7 @@ rustPlatform.buildRustPackage rec {
gtk3
];
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = czkawka;
command = "czkawka_cli --version";
};

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchurl, datefmt, testVersion }:
{ lib, stdenv, fetchurl, datefmt, testers }:
stdenv.mkDerivation rec {
pname = "datefmt";
@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
makeFlags = [ "PREFIX=$(out)" ];
passthru.tests.version = testVersion { package = datefmt; };
passthru.tests.version = testers.testVersion { package = datefmt; };
meta = with lib; {
homepage = "https://jb55.com/datefmt";

View File

@ -5,7 +5,7 @@
, runCommand
, nix-update-script
, dsq
, testVersion
, testers
, diffutils
}:
@ -30,7 +30,7 @@ buildGoModule rec {
updateScript = nix-update-script { attrPath = pname; };
tests = {
version = testVersion { package = dsq; };
version = testers.testVersion { package = dsq; };
pretty-csv = runCommand "${pname}-test" { } ''
mkdir "$out"

View File

@ -1,7 +1,7 @@
{ lib
, stdenv
, fetchFromGitHub
, testVersion
, testers
, gummy
, cmake
, libX11
@ -51,7 +51,7 @@ stdenv.mkDerivation rec {
ln -s $out/libexec/gummyd $out/bin/gummyd
'';
passthru.tests.version = testVersion { package = gummy; };
passthru.tests.version = testers.testVersion { package = gummy; };
meta = with lib; {
homepage = "https://github.com/Fushko/gummy";

View File

@ -2,7 +2,7 @@
, fetchFromGitHub
, rustPlatform
, installShellFiles
, testVersion
, testers
, lsd
}:
@ -27,7 +27,7 @@ rustPlatform.buildRustPackage rec {
# Found argument '--test-threads' which wasn't expected, or isn't valid in this context
doCheck = false;
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = lsd;
};

View File

@ -10,7 +10,7 @@
, Foundation
, mandown
, zellij
, testVersion
, testers
}:
rustPlatform.buildRustPackage rec {
@ -54,7 +54,7 @@ rustPlatform.buildRustPackage rec {
--zsh <($out/bin/zellij setup --generate-completion zsh)
'';
passthru.tests.version = testVersion { package = zellij; };
passthru.tests.version = testers.testVersion { package = zellij; };
meta = with lib; {
description = "A terminal workspace with batteries included";

View File

@ -1,4 +1,4 @@
{ lib, fetchFromGitHub, buildGoModule, testVersion, clash }:
{ lib, fetchFromGitHub, buildGoModule, testers, clash }:
buildGoModule rec {
pname = "clash";
@ -26,7 +26,7 @@ buildGoModule rec {
"-X github.com/Dreamacro/clash/constant.Version=${version}"
];
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = clash;
command = "clash -v";
};

View File

@ -1,4 +1,4 @@
{ buildGoModule, fetchFromGitHub, lib, curlie, testVersion }:
{ buildGoModule, fetchFromGitHub, lib, curlie, testers }:
buildGoModule rec {
pname = "curlie";
@ -15,7 +15,7 @@ buildGoModule rec {
ldflags = [ "-s" "-w" "-X main.version=${version}" ];
passthru.tests.version = testVersion {
passthru.tests.version = testers.testVersion {
package = curlie;
command = "curlie version";
};

View File

@ -8,7 +8,7 @@
, Security
, libiconv
, innernet
, testVersion
, testers
}:
rustPlatform.buildRustPackage rec {
@ -40,8 +40,8 @@ rustPlatform.buildRustPackage rec {
'';
passthru.tests = {
serverVersion = testVersion { package = innernet; command = "innernet-server --version"; };
version = testVersion { package = innernet; command = "innernet --version"; };
serverVersion = testers.testVersion { package = innernet; command = "innernet-server --version"; };
version = testers.testVersion { package = innernet; command = "innernet --version"; };
};
meta = with lib; {

View File

@ -13,7 +13,7 @@
, withPgSQL ? true, postgresql
, withMysql ? true, libmysqlclient, zlib, numactl
, gnutlsSupport ? false, gnutls
, testVersion
, testers
, pmacct
}:
@ -55,7 +55,7 @@ stdenv.mkDerivation rec {
++ lib.optional gnutlsSupport "--enable-gnutls";
passthru.tests = {
version = testVersion { package = pmacct; command = "pmacct -V"; };
version = testers.testVersion { package = pmacct; command = "pmacct -V"; };
};
meta = with lib; {

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, openssl, testVersion, smartdns }:
{ lib, stdenv, fetchFromGitHub, openssl, testers, smartdns }:
stdenv.mkDerivation rec {
pname = "smartdns";
@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
installFlags = [ "SYSCONFDIR=${placeholder "out"}/etc" ];
passthru.tests = {
version = testVersion { package = smartdns; };
version = testers.testVersion { package = smartdns; };
};
meta = with lib; {

View File

@ -1,7 +1,7 @@
{ lib
, rustPlatform
, fetchFromGitHub
, testVersion
, testers
, alejandra
}:
@ -19,7 +19,7 @@ rustPlatform.buildRustPackage rec {
cargoSha256 = "sha256-SsIpggbRQPjpCYgCG4sSJ022MmMV4bJJ8UAHcJR74O8=";
passthru.tests = {
version = testVersion { package = alejandra; };
version = testers.testVersion { package = alejandra; };
};
meta = with lib; {

View File

@ -3,7 +3,7 @@
, python3Packages
, nix-update-script
, s-tui
, testVersion
, testers
}:
python3Packages.buildPythonPackage rec {
@ -22,7 +22,7 @@ python3Packages.buildPythonPackage rec {
passthru = {
updateScript = nix-update-script { attrPath = pname; };
tests = testVersion { package = s-tui; };
tests = testers.testVersion { package = s-tui; };
};
meta = with lib; {

View File

@ -8,7 +8,7 @@
, jre
, makeWrapper
, crowdin-cli
, testVersion
, testers
, unzip
}:
@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
passthru.tests.version = testVersion { package = crowdin-cli; };
passthru.tests.version = testers.testVersion { package = crowdin-cli; };
meta = with lib; {
mainProgram = "crowdin";

View File

@ -1,4 +1,4 @@
{ lib, fetchFromGitHub, rustPlatform, tree-sitter, difftastic, testVersion }:
{ lib, fetchFromGitHub, rustPlatform, tree-sitter, difftastic, testers }:
rustPlatform.buildRustPackage rec {
pname = "difftastic";
@ -13,7 +13,7 @@ rustPlatform.buildRustPackage rec {
cargoSha256 = "sha256-qHG3ve8HoMWBS/x6mRbXMsrpcqNqfVcbAkfYOk7Su/0=";
passthru.tests.version = testVersion { package = difftastic; };
passthru.tests.version = testers.testVersion { package = difftastic; };
meta = with lib; {
description = "A syntax-aware diff";

View File

@ -3,7 +3,7 @@
, fetchFromGitHub
, stdenv
, Security
, testVersion
, testers
, igrep
}:
@ -23,7 +23,7 @@ rustPlatform.buildRustPackage rec {
buildInputs = lib.optionals stdenv.isDarwin [ Security ];
passthru.tests = {
version = testVersion { package = igrep; command = "ig --version"; };
version = testers.testVersion { package = igrep; command = "ig --version"; };
};
meta = with lib; {

View File

@ -1,5 +1,5 @@
{ lib, stdenv, fetchFromGitHub, rustPlatform, pkg-config, openssl, Security
, testVersion, mdbook-linkcheck }:
, testers, mdbook-linkcheck }:
rustPlatform.buildRustPackage rec {
pname = "mdbook-linkcheck";
@ -22,7 +22,7 @@ rustPlatform.buildRustPackage rec {
doCheck = false; # tries to access network to test broken web link functionality
passthru.tests.version = testVersion { package = mdbook-linkcheck; };
passthru.tests.version = testers.testVersion { package = mdbook-linkcheck; };
meta = with lib; {
description = "A backend for `mdbook` which will check your links for you.";

View File

@ -1255,6 +1255,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

View File

@ -725,8 +725,8 @@ with pkgs;
installShellFiles = callPackage ../build-support/install-shell-files {};
# See doc/builders/special/invalidateFetcherByDrvHash.section.md or
# https://nixos.org/manual/nixpkgs/unstable/#sec-pkgs-invalidateFetcherByDrvHash
# See doc/builders/testers.chapter.md or
# https://nixos.org/manual/nixpkgs/unstable/#tester-invalidateFetcherByDrvHash
invalidateFetcherByDrvHash = f: args:
let
drvPath = (f args).drvPath;