[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-dev
Subject:    [gentoo-dev] [PATCH] eclass/tests: add Makefile to run eclass tests
From:       Florian Schmaus <flow () gentoo ! org>
Date:       2023-04-23 13:17:11
Message-ID: 20230423131711.647266-2-flow () gentoo ! org
[Download RAW message or body]

Signed-off-by: Florian Schmaus <flow@gentoo.org>
---
 eclass/tests/.gitignore |  2 ++
 eclass/tests/Makefile   | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 eclass/tests/.gitignore
 create mode 100644 eclass/tests/Makefile

diff --git a/eclass/tests/.gitignore b/eclass/tests/.gitignore
new file mode 100644
index 000000000000..4df21cab8f5f
--- /dev/null
+++ b/eclass/tests/.gitignore
@@ -0,0 +1,2 @@
+/*.sh.ok
+/.eclasssum
diff --git a/eclass/tests/Makefile b/eclass/tests/Makefile
new file mode 100644
index 000000000000..f53f74cfc1af
--- /dev/null
+++ b/eclass/tests/Makefile
@@ -0,0 +1,27 @@
+SH_FILES := $(wildcard *.sh)
+TEST_FILES := $(filter-out tests-common.sh, $(SH_FILES))
+TEST_OK_FILES := $(patsubst %.sh, .%.sh.ok,$ $(TEST_FILES))
+
+# We cache a successful test result if the testfile itself did not
+# change (%.sh) and the contents of the eclass/ directory did not
+# change (.eclasssum).
+.%.sh.ok: %.sh .eclasssum
+	./$<
+	touch $@
+
+.PHONY: test
+test: $(TEST_OK_FILES)
+
+.PHONY: force
+.ONESHELL:
+.eclasssum: SHELL = /bin/bash
+.eclasssum: force
+	set -euo pipefail
+	find .. -maxdepth 1 -type f -name "*.eclass" |\
+		xargs stat --format="%n %y" |\
+		sort |\
+		xxhsum - > $@.cur
+	trap "rm -f $@.cur" EXIT
+	if ! cmp --silent $@.cur $@; then
+		mv $@.cur $@
+	fi
-- 
2.39.2


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic