nixpkgs/pkgs/build-support/testers/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
601 B
Nix
Raw Normal View History

{ pkgs, lib, callPackage, runCommand }:
2022-04-20 18:26:52 +00:00
# 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
'';
}