eclass/tests: add Makefile to run eclass tests

Thanks to robbat2 for providing feedback.

Closes: https://github.com/gentoo/gentoo/pull/30603
Signed-off-by: Florian Schmaus <flow@gentoo.org>
This commit is contained in:
Florian Schmaus 2023-04-15 15:42:59 +02:00
parent 8a8b23d9f4
commit 94694a5c37
No known key found for this signature in database
GPG Key ID: 2239A7E8F5852052
2 changed files with 29 additions and 0 deletions

2
.gitignore vendored
View File

@ -1,6 +1,8 @@
/.ebuild.x
/distfiles/
/eclass/*.5
/eclass/tests/*.sh.ok
/eclass/tests/.eclasssum
/local/
/packages/
/profiles/use.local.desc

27
eclass/tests/Makefile Normal file
View File

@ -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" \
-exec stat --format="%n %y" \{} \+ |\
sort |\
cksum - > $@.cur
trap "rm -f $@.cur" EXIT
if ! cmp --silent $@.cur $@; then
mv $@.cur $@
fi