lint: automate adding a test for lint1

This commit is contained in:
rillig 2021-01-10 12:05:07 +00:00
parent e107438c00
commit a0c63d1765

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.57 2021/01/09 21:37:44 rillig Exp $
# $NetBSD: Makefile,v 1.58 2021/01/10 12:05:07 rillig Exp $
.include <bsd.own.mk>
@ -43,4 +43,44 @@ oper.o: ops.def
.include "Makefile.err-msgs-h"
${SRCS:Nerr.c}: err-msgs.h
add-test: .PHONY
@set -eu; \
test=${NAME:Q}; \
[ "$$test" ] || { \
echo "usage: ${MAKE} add-test NAME=<name>"; \
exit; \
}; \
\
cd '../../../tests/usr.bin/xlint/lint1'; \
if [ -f "$$test.c" ]; then \
echo "error: test $$test already exists in $$PWD."; \
exit 1; \
fi; \
\
echo "=> Adding test $$test"; \
printf '%s\n' \
'/* $$''NetBSD$$ */' \
"# 3 \"$$test.c\"" \
'' \
'/*' \
' * TODO: Explain the purpose of the test.' \
'*/' \
'' \
'/* lint1-extra-flags: -p */' \
'' \
'// TODO: Add some code that passes.' \
'// TODO: Add some code that fails.' \
> "$$test.c"; \
> "$$test.exp"; \
cvs add "$$test.c" "$$test.exp"; \
printf '%s\n' \
'/^FILES+=/i' \
"FILES+= $$test.c" \
"FILES+= $$test.exp" \
'.' 'w' 'q' \
| ed Makefile; \
${MAKE} sync-mi; \
printf '%s\n' '/^test_case /i' "test_case $$test" '.' 'w' 'q' \
| ed t_integration.sh
.include <bsd.prog.mk>