Tue Mar 9 20:43:20 2021 UTC ()
tests/indent: demonstrate strange alignment for global variables
(rillig)
diff -r1.1029 -r1.1030 src/distrib/sets/lists/tests/mi
diff -r1.6 -r1.7 src/tests/usr.bin/indent/Makefile
diff -r0 -r1.1 src/tests/usr.bin/indent/indent_variables.0
diff -r0 -r1.1 src/tests/usr.bin/indent/indent_variables.0.pro
diff -r0 -r1.1 src/tests/usr.bin/indent/indent_variables.0.stdout
--- src/distrib/sets/lists/tests/mi 2021/03/08 22:13:05 1.1029
+++ src/distrib/sets/lists/tests/mi 2021/03/09 20:43:19 1.1030
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1029 2021/03/08 22:13:05 rillig Exp $
+# $NetBSD: mi,v 1.1030 2021/03/09 20:43:19 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4727,6 +4727,9 @@
./usr/tests/usr.bin/indent/f_decls.0.stdout tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/float.0 tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/float.0.stdout tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/indent_variables.0 tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/indent_variables.0.pro tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/indent_variables.0.stdout tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/label.0 tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/label.0.pro tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/label.0.stdout tests-usr.bin-tests compattestfile,atf
--- src/tests/usr.bin/indent/Makefile 2021/03/08 22:13:05 1.6
+++ src/tests/usr.bin/indent/Makefile 2021/03/09 20:43:20 1.7
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.6 2021/03/08 22:13:05 rillig Exp $
+# $NetBSD: Makefile,v 1.7 2021/03/09 20:43:20 rillig Exp $
.include <bsd.own.mk>
@@ -24,6 +24,9 @@
FILES+= f_decls.0.stdout
FILES+= float.0
FILES+= float.0.stdout
+FILES+= indent_variables.0
+FILES+= indent_variables.0.pro
+FILES+= indent_variables.0.stdout
FILES+= label.0
FILES+= label.0.stdout
FILES+= label.0.pro
@@ -268,5 +271,64 @@
FILES+= types_from_file.0.pro
FILES+= wchar.0
FILES+= wchar.0.stdout
+
+add-test: .PHONY
+ @set -eu; \
+ test=${NAME:Q}; \
+ [ "$$test" ] || { \
+ echo "usage: ${MAKE} add-test NAME=<name>"; \
+ exit; \
+ }; \
+ \
+ if [ -f "$$test" ]; then \
+ echo "error: test $$test already exists." 1>&2; \
+ exit 1; \
+ fi; \
+ \
+ echo "=> Adding test $$test"; \
+ printf '%s\n' \
+ '/* $$''NetBSD$$ */' \
+ '/* $$''FreeBSD$$ */' \
+ '' \
+ '/*' \
+ ' * TODO: Explain the purpose of the test.' \
+ '*/' \
+ '' \
+ '// TODO: Add some code that passes.' \
+ > "$$test"; \
+ printf '%s\n' \
+ '/* $$''NetBSD$$ */' \
+ '/* $$''FreeBSD$$ */' \
+ '' \
+ '/*' \
+ ' * TODO: Explain the command line options of the test.' \
+ ' */' \
+ '' \
+ '/* TODO: Add some command line options */' \
+ > "$$test.pro"; \
+ cat < "$$test" > "$$test.stdout"; \
+ cvs add "$$test" "$$test.pro" "$$test.stdout"; \
+ printf '%s\n' \
+ '/^FILES+=/i' \
+ "FILES+= $$test" \
+ "FILES+= $$test.pro" \
+ "FILES+= $$test.stdout" \
+ '.' 'w' 'q' \
+ | ed Makefile; \
+ ${MAKE} sync-mi
+
+# Note: only works for adding tests.
+# To remove a test, the $$mi file must be edited manually.
+sync-mi: .PHONY
+ @set -eu; \
+ cd "${MAKEFILE:tA:H}/../../.."; \
+ mi="distrib/sets/lists/tests/mi"; \
+ cvs update "$$mi"; \
+ fmt="./usr/tests/usr.bin/indent/%s\ttests-usr.bin-tests\tcompattestfile,atf\n"; \
+ cat "$$mi" > "$$mi.tmp"; \
+ printf "$$fmt" ${FILES:M${NAME}*} >> "$$mi.tmp"; \
+ distrib/sets/fmt-list "$$mi.tmp"; \
+ mv "$$mi.tmp" "$$mi"; \
+ cvs diff "$$mi" || true
.include <bsd.test.mk>
/* $NetBSD: indent_variables.0,v 1.1 2021/03/09 20:43:20 rillig Exp $ */
/* $FreeBSD$ */
/*-
* Demonstrate how variable declarations are broken into several lines when
* the line length limit is set quite low.
*/
struct s0 a,b;
struct s01 a,b;
struct s012 a,b;
struct s0123 a,b;
struct s01234 a,b;
struct s012345 a,b;
struct s0123456 a,b;
struct s01234567 a,b;
struct s012345678 a,b;
struct s0123456789 a,b;
struct s01234567890 a,b;
struct s012345678901 a,b;
struct s0123456789012 a,b;
struct s01234567890123 a,b;
/* $NetBSD: indent_variables.0.pro,v 1.1 2021/03/09 20:43:20 rillig Exp $ */
/* $FreeBSD$ */
-l20
-di0
/* $NetBSD: indent_variables.0.stdout,v 1.1 2021/03/09 20:43:20 rillig Exp $ */
/* $FreeBSD$ */
/*-
* Demonstrate how variable declarations are broken into several lines when
* the line length limit is set quite low.
*/
struct s0 a,
b;
struct s01 a,
b;
struct s012 a,
b;
struct s0123 a,
b;
struct s01234 a,
b;
struct s012345 a,
b;
struct s0123456 a,
b;
struct s01234567 a,
b;
struct s012345678 a,
b;
struct s0123456789 a,
b;
struct s01234567890 a,
b;
struct s012345678901 a,
b;
struct s0123456789012 a,
b;
struct s01234567890123 a,
b;