* [gentoo-dev] Add Makefile to run eclass tests
@ 2023-04-23 13:17 Florian Schmaus
2023-04-23 13:17 ` [gentoo-dev] [PATCH] eclass/tests: add " Florian Schmaus
0 siblings, 1 reply; 2+ messages in thread
From: Florian Schmaus @ 2023-04-23 13:17 UTC (permalink / raw
To: gentoo-dev
The eclass tests, found under eclass/tests, are currently not run
automatically. This yields the danger that the tests rot and decay over
time. In fact, I believe this already started to happen.
Ideally the eclass tests are automatically run with the normal QA checks
for ::gentoo. A single entry point to run the eclass testsuite is a
prerequisite for this.
This patch adds, in form of a Makefile, such an entry point. Driving the
tests via Make allows us to exploit Make's built-in features, like
potentially running the tests in parallel.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gentoo-dev] [PATCH] eclass/tests: add Makefile to run eclass tests
2023-04-23 13:17 [gentoo-dev] Add Makefile to run eclass tests Florian Schmaus
@ 2023-04-23 13:17 ` Florian Schmaus
0 siblings, 0 replies; 2+ messages in thread
From: Florian Schmaus @ 2023-04-23 13:17 UTC (permalink / raw
To: gentoo-dev; +Cc: Florian Schmaus
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-23 13:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-23 13:17 [gentoo-dev] Add Makefile to run eclass tests Florian Schmaus
2023-04-23 13:17 ` [gentoo-dev] [PATCH] eclass/tests: add " Florian Schmaus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox