chiark / gitweb /
tests/filter: New test framework for generate
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 21 Dec 2019 11:40:54 +0000 (11:40 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 28 Dec 2019 22:19:08 +0000 (22:19 +0000)
This test case bypasses autoconf and runs generate directly.
It also gives us somewhere to write examples of each of the
&-expansions without further cluttering test-example.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
tests/filter/.gitignore [new file with mode: 0644]
tests/filter/Subdir.mk.expected [new file with mode: 0644]
tests/filter/Subdir.sd.mk [new file with mode: 0644]
tests/filter/check [new file with mode: 0755]
tests/filter/main.mk.expected [new file with mode: 0644]
tests/filter/update-expected [new file with mode: 0755]

diff --git a/tests/filter/.gitignore b/tests/filter/.gitignore
new file mode 100644 (file)
index 0000000..08c232c
--- /dev/null
@@ -0,0 +1,2 @@
+Makefile
+*.mk.tmp
diff --git a/tests/filter/Subdir.mk.expected b/tests/filter/Subdir.mk.expected
new file mode 100644 (file)
index 0000000..fe0e7aa
--- /dev/null
@@ -0,0 +1,5 @@
+# autogenerated - do not edit
+# test cases for generate script
+
+all:: $(TOP_TARGETS)
+.PHONY: all
diff --git a/tests/filter/Subdir.sd.mk b/tests/filter/Subdir.sd.mk
new file mode 100644 (file)
index 0000000..f942367
--- /dev/null
@@ -0,0 +1 @@
+# test cases for generate script
diff --git a/tests/filter/check b/tests/filter/check
new file mode 100755 (executable)
index 0000000..09b4196
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+set -e
+
+cd tests/filter
+../../generate
+files=$(find -name \*.expected)
+for f in $files; do diff -u $f ${f%.expected}.tmp; done
+
+echo ok.
diff --git a/tests/filter/main.mk.expected b/tests/filter/main.mk.expected
new file mode 100644 (file)
index 0000000..a5b0e9d
--- /dev/null
@@ -0,0 +1,8 @@
+# autogenerated - do not edit
+top_srcdir=@top_srcdir@
+abs_top_srcdir=@abs_top_srcdir@
+SUBDIRMK_MAKEFILES :=
+MAKEFILE_TEMPLATES :=
+SUBDIRMK_MAKEFILES += Subdir.mk
+MAKEFILE_TEMPLATES += ./Subdir.sd.mk
+include $(SUBDIRMK_MAKEFILES)
diff --git a/tests/filter/update-expected b/tests/filter/update-expected
new file mode 100755 (executable)
index 0000000..ff10542
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# Usual approach to updating the expected outputs is
+#   tests/filter/check
+#   tests/filter/update-expected
+#   selectively git-add the things that are right, after inspecting them
+
+set -e
+files=$(find tests/filter -name \*.tmp)
+for f in $files; do cp $f ${f%.tmp}.expected; done