Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: automate adding a test for lint1



details:   https://anonhg.NetBSD.org/src/rev/7ae729c4fb04
branches:  trunk
changeset: 1017808:7ae729c4fb04
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 10 12:05:07 2021 +0000

description:
lint: automate adding a test for lint1

diffstat:

 usr.bin/xlint/lint1/Makefile |  42 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 41 insertions(+), 1 deletions(-)

diffs (54 lines):

diff -r 971462888a4d -r 7ae729c4fb04 usr.bin/xlint/lint1/Makefile
--- a/usr.bin/xlint/lint1/Makefile      Sun Jan 10 11:24:42 2021 +0000
+++ b/usr.bin/xlint/lint1/Makefile      Sun Jan 10 12:05:07 2021 +0000
@@ -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 @@
 .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>



Home | Main Index | Thread Index | Old Index