Module Name:    src
Committed By:   rillig
Date:           Sun Jan 10 12:05:07 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: Makefile

Log Message:
lint: automate adding a test for lint1


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/xlint/lint1/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/Makefile
diff -u src/usr.bin/xlint/lint1/Makefile:1.57 src/usr.bin/xlint/lint1/Makefile:1.58
--- src/usr.bin/xlint/lint1/Makefile:1.57	Sat Jan  9 21:37:44 2021
+++ src/usr.bin/xlint/lint1/Makefile	Sun Jan 10 12:05:07 2021
@@ -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>

Reply via email to