usr.bin/indent could use a little love, but first it needs some regression tests. The diff below is my initial attempt at this but before I progress too much further I'd like some feedback on the general direction I'm going, especially that Makefile. Is there a way to generalize all of the dependency rules (i.e. tX: tX.in tX.out tX.expected) so we don't have to manually write one for each REGRESS_TARGET?
Also, I apologize in advance if this diff doesn't apply cleanly. I know tech@ strips attachments so I cvs add'ed the /usr/src/regress/usr.bin/indent/ directory and each file inside it. Index: regress/usr.bin/Makefile =================================================================== RCS file: /work/cvsroot/src/regress/usr.bin/Makefile,v retrieving revision 1.27 diff -p -u -r1.27 Makefile --- regress/usr.bin/Makefile 1 Aug 2013 21:26:30 -0000 1.27 +++ regress/usr.bin/Makefile 24 Dec 2013 19:04:06 -0000 @@ -2,7 +2,7 @@ # $NetBSD: Makefile,v 1.1 1997/12/30 23:27:11 cgd Exp $ SUBDIR+= basename bc dc diff diff3 dirname file grep gzip gzsig -SUBDIR+= m4 mandoc sdiff sed sort tsort +SUBDIR+= indent m4 mandoc sdiff sed sort tsort SUBDIR+= xargs .if defined(REGRESS_FULL) Index: regress/usr.bin/indent/Makefile =================================================================== RCS file: regress/usr.bin/indent/Makefile diff -N regress/usr.bin/indent/Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/indent/Makefile 24 Dec 2013 19:01:24 -0000 @@ -0,0 +1,39 @@ +# $OpenBSD$ + +REGRESS_TARGETS = t1 t2 t3 t4 + +# .in: input file +# .out: test output +# .expected: expected output + +# t1: blank after declarations (-bad) +# t2: no blank after declarations (-nbad) +# t3: blank after procedures (-bap) +# t4: no blank after procedures (-nbap) + +all: clean regress + +t1.out: t1.in + indent -bad $(*).in $(@) + +t2.out: t2.in + indent -nbad $(*).in $(@) + +t3.out: t3.in + indent -bap $(*).in $(@) + +t4.out: t4.in + indent -nbap $(*).in $(@) + +t1: t1.in t1.out t1.expected +t2: t2.in t2.out t2.expected +t3: t3.in t3.out t3.expected +t4: t4.in t4.out t4.expected +$(REGRESS_TARGETS): + cmp -s $(.CURDIR)/$(@).expected $(.CURDIR)/$(@).out || \ + (echo "XXX $(*) failed" && false) + +clean: + rm -f *.out + +.include <bsd.regress.mk> Index: regress/usr.bin/indent/t1.expected =================================================================== RCS file: regress/usr.bin/indent/t1.expected diff -N regress/usr.bin/indent/t1.expected --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/indent/t1.expected 24 Dec 2013 18:54:10 -0000 @@ -0,0 +1,10 @@ +/* $OpenBSD$ */ + +int +main(int argc, char *argv) +{ + int x; + + x = 0; + return x; +} Index: regress/usr.bin/indent/t1.in =================================================================== RCS file: regress/usr.bin/indent/t1.in diff -N regress/usr.bin/indent/t1.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/indent/t1.in 24 Dec 2013 18:53:46 -0000 @@ -0,0 +1,3 @@ +/* $OpenBSD$ */ + +int main(int argc,char *argv) {int x;x=0;return x;} Index: regress/usr.bin/indent/t2.expected =================================================================== RCS file: regress/usr.bin/indent/t2.expected diff -N regress/usr.bin/indent/t2.expected --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/indent/t2.expected 24 Dec 2013 18:54:37 -0000 @@ -0,0 +1,9 @@ +/* $OpenBSD$ */ + +int +main(int argc, char *argv) +{ + int x; + x = 0; + return x; +} Index: regress/usr.bin/indent/t2.in =================================================================== RCS file: regress/usr.bin/indent/t2.in diff -N regress/usr.bin/indent/t2.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/indent/t2.in 24 Dec 2013 18:53:34 -0000 @@ -0,0 +1,3 @@ +/* $OpenBSD$ */ + +int main(int argc,char *argv) {int x;x=0;return x;} Index: regress/usr.bin/indent/t3.expected =================================================================== RCS file: regress/usr.bin/indent/t3.expected diff -N regress/usr.bin/indent/t3.expected --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/indent/t3.expected 24 Dec 2013 18:58:14 -0000 @@ -0,0 +1,11 @@ +/* $OpenBSD$ */ + +int +do_nothing(void) +{ +} +int +main(int argc, char *argv) +{ + return 0; +} Index: regress/usr.bin/indent/t3.in =================================================================== RCS file: regress/usr.bin/indent/t3.in diff -N regress/usr.bin/indent/t3.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/indent/t3.in 24 Dec 2013 18:57:53 -0000 @@ -0,0 +1,4 @@ +/* $OpenBSD$ */ + +int do_nothing(void) {} +int main(int argc,char *argv) {return 0;} Index: regress/usr.bin/indent/t4.expected =================================================================== RCS file: regress/usr.bin/indent/t4.expected diff -N regress/usr.bin/indent/t4.expected --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/indent/t4.expected 24 Dec 2013 18:59:57 -0000 @@ -0,0 +1,11 @@ +/* $OpenBSD$ */ + +int +do_nothing(void) +{ +} +int +main(int argc, char *argv) +{ + return 0; +} Index: regress/usr.bin/indent/t4.in =================================================================== RCS file: regress/usr.bin/indent/t4.in diff -N regress/usr.bin/indent/t4.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/indent/t4.in 24 Dec 2013 18:59:49 -0000 @@ -0,0 +1,4 @@ +/* $OpenBSD$ */ + +int do_nothing(void) {} +int main(int argc,char *argv) {return 0;}