commit ec64220d94408047b2a79f2021f51807fdbd5b07
parent 1e020e46aaaf0f6e6badc9ee32227daafe158dd4
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 10 Jan 2025 21:33:34 +0100
tests/make: Add error/0001-macro.sh
Diffstat:
5 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/tests/Makefile b/tests/Makefile
@@ -9,7 +9,7 @@ DIRS =\
strip/execute\
libc/execute\
cc/execute cc/error\
- make/execute\
+ make/execute make/error\
PROJECTDIR = ..
include $(PROJECTDIR)/scripts/rules.mk
diff --git a/tests/make/error/.gitignore b/tests/make/error/.gitignore
@@ -0,0 +1 @@
+test.log
diff --git a/tests/make/error/0001-macro.sh b/tests/make/error/0001-macro.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+trap 'rm -f $tmp1 $tmp2' EXIT INT TERM HUP
+
+tmp1=tmp1.$$
+tmp2=tmp2.$$
+
+cat > $tmp1 <<EOF
+make: error: <stdin>:5: missing target
+EOF
+
+scc make -f - <<'EOF' > $tmp2 2>&1
+FLAGS=Hello $(EFLAGS)
+all: $(DIRS)
+ @echo Hello World
+
+$(DIRS): FORCE
+ @echo Bye
+
+FORCE:
+EOF
+
+diff $tmp1 $tmp2
diff --git a/tests/make/error/Makefile b/tests/make/error/Makefile
@@ -0,0 +1,18 @@
+.POSIX:
+
+BINDIR = ../../../bin/
+
+all:
+ PATH=$(BINDIR):$$PATH ./chktest.sh
+
+tests:
+ @$(MAKE) |\
+ grep -v TODO |\
+ grep FAIL >/dev/null &&\
+ printf '[FAIL]' || printf '[PASS]'; printf '\tmake/error\n'
+
+hello:
+ @echo Hello World!
+
+clean:
+ rm -f test.log tmp?.* file? file.c file.o core*
diff --git a/tests/make/error/chktest.sh b/tests/make/error/chktest.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+ulimit -c 0
+rm -f test.log
+
+for i in *-*.sh
+do
+ printf "Test: %s\n\n" $i >> test.log
+ (./$i >> test.log 2>&1 && printf '[PASS]\t' || printf '[FAIL]\t'
+ echo "$i") | tee -a test.log
+done