aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix
blob: 1757bdbbe2500b645c493b4d165a6565cdbf9efc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{ runCommand
}:

rec {
  runTest = name: body: runCommand name { } ''
    set -o errexit
    ${body}
    touch $out
  '';

  skip = cond: text:
    if cond then ''
      echo "Skipping test $name" > /dev/stderr
    '' else text;

  fail = text: ''
    echo "FAIL: $name: ${text}" > /dev/stderr
    exit 1
  '';

  expectSomeLineContainingYInFileXToMentionZ = file: filter: expected: ''
    if ! cat "${file}" | grep "${filter}"; then
        ${fail "The file “${file}” should include a line containing “${filter}”."}
    fi

    if ! cat "${file}" | grep "${filter}" | grep ${expected}; then
        ${fail "The file “${file}” should include a line containing “${filter}” that also contains “${expected}”."}
    fi
  '';
}