aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests')
-rw-r--r--nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix30
-rw-r--r--nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/sample-project/Makefile30
2 files changed, 60 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 00000000000..1757bdbbe25
--- /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
+ '';
+}
diff --git a/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/sample-project/Makefile b/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/sample-project/Makefile
new file mode 100644
index 00000000000..5d234db11a0
--- /dev/null
+++ b/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/sample-project/Makefile
@@ -0,0 +1,30 @@
+PREFIX = $(out)
+BINDIR = $(PREFIX)/bin
+LIBEXECDIR = $(PREFIX)/libexec
+LIBDIR = $(PREFIX)/lib
+TYPELIBDIR = $(LIBDIR)/girepository-1.0
+
+all:
+ echo "Compiling…"
+install:
+ echo "Installing…"
+
+bin:
+ mkdir -p $(BINDIR)
+# Adds `bin-${foo}` targets, that install `${foo}` executable to `$(BINDIR)`.
+bin-%: bin
+ touch $(BINDIR)/$(@:bin-%=%)
+ chmod +x $(BINDIR)/$(@:bin-%=%)
+
+libexec:
+ mkdir -p $(LIBEXECDIR)
+# Adds `libexec-${foo}` targets, that install `${foo}` executable to `$(LIBEXECDIR)`.
+libexec-%: libexec
+ touch $(LIBEXECDIR)/$(@:libexec-%=%)
+ chmod +x $(LIBEXECDIR)/$(@:libexec-%=%)
+
+typelib:
+ mkdir -p $(TYPELIBDIR)
+# Adds `typelib-${foo}` targets, that install `${foo}-1.0.typelib` file to `$(TYPELIBDIR)`.
+typelib-%: typelib
+ touch $(TYPELIBDIR)/$(@:typelib-%=%)-1.0.typelib