about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix')
-rw-r--r--nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix30
1 files changed, 30 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix b/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix
new file mode 100644
index 000000000000..1757bdbbe250
--- /dev/null
+++ b/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix
@@ -0,0 +1,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
+  '';
+}