summaryrefslogtreecommitdiff
path: root/eclass/tests/Makefile
blob: ee4a454912c319ffcd93ed3043c2754e6416b0ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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