summary refs log tree commit diff
path: root/pkgs/build-support/testers/default.nix
blob: 8b79843b8332f4ebd1d1f3c0de00b9233e5f3fe6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{ 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
    '';
}