Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/indent tests/indent: consolidate tests for com...



details:   https://anonhg.NetBSD.org/src/rev/e6370a16e815
branches:  trunk
changeset: 1024321:e6370a16e815
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Oct 18 19:36:29 2021 +0000

description:
tests/indent: consolidate tests for comments

These tests have been the motivation for t_options.sh, which allows to
run indent with various command line options on the same input, without
having to create 3 files per test case.

A test file actually contains several tests, all separated by '#indent'
directives. Isolating each of these tests is simpler than having to pick
up the corresponding sections from 3 separate files. Running indent on
each small test case isolates the test cases from each other, preventing
them to influence later test cases. Exactly this had happened when
support for C99 comments was added in March 2021, which later turned
out to be done wrong.

diffstat:

 distrib/sets/lists/tests/mi                    |   19 +-
 tests/usr.bin/indent/Makefile                  |   11 +-
 tests/usr.bin/indent/comment-line-end.0        |   44 -
 tests/usr.bin/indent/comment-line-end.0.stdout |   48 -
 tests/usr.bin/indent/comments.0                |   55 -
 tests/usr.bin/indent/comments.0.pro            |    3 -
 tests/usr.bin/indent/comments.0.stdout         |   62 -
 tests/usr.bin/indent/t_options.sh              |   53 +-
 tests/usr.bin/indent/token-comment.0           |  233 -------
 tests/usr.bin/indent/token-comment.0.pro       |   14 -
 tests/usr.bin/indent/token-comment.0.stdout    |  272 --------
 tests/usr.bin/indent/token_comment.c           |  779 +++++++++++++++++++++++++
 12 files changed, 824 insertions(+), 769 deletions(-)

diffs (truncated from 1735 to 300 lines):

diff -r 22fe99d8f42d -r e6370a16e815 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Mon Oct 18 18:10:19 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Mon Oct 18 19:36:29 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1142 2021/10/18 18:10:19 rillig Exp $
+# $NetBSD: mi,v 1.1143 2021/10/18 19:36:29 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4734,11 +4734,11 @@
 ./usr/tests/usr.bin/indent/binary.0.stdout                             tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/indent/block.0                                     tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/block.0.stdout                              tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/indent/comment-line-end.0                          tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/indent/comment-line-end.0.stdout                   tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/indent/comments.0                                  tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/indent/comments.0.pro                              tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/indent/comments.0.stdout                           tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/comment-line-end.0                          tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/indent/comment-line-end.0.stdout                   tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/indent/comments.0                                  tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/indent/comments.0.pro                              tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/indent/comments.0.stdout                           tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/indent/cs.0                                                tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/indent/cs.0.pro                                    tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/indent/cs.0.stdout                                 tests-obsolete          obsolete,atf
@@ -5046,9 +5046,9 @@
 ./usr/tests/usr.bin/indent/token-comma.0                               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token-comma.0.pro                           tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token-comma.0.stdout                                tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/indent/token-comment.0                             tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/indent/token-comment.0.pro                         tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/indent/token-comment.0.stdout                      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/token-comment.0                             tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/indent/token-comment.0.pro                         tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/indent/token-comment.0.stdout                      tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/indent/token-decl.0                                        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token-decl.0.pro                            tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token-decl.0.stdout                         tests-usr.bin-tests     compattestfile,atf
@@ -5148,6 +5148,7 @@
 ./usr/tests/usr.bin/indent/token-while_expr.0                          tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token-while_expr.0.pro                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token-while_expr.0.stdout                   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/token_comment.c                             tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token_ident.c                               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/types_from_file.0                           tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/types_from_file.0.list                      tests-usr.bin-tests     compattestfile,atf
diff -r 22fe99d8f42d -r e6370a16e815 tests/usr.bin/indent/Makefile
--- a/tests/usr.bin/indent/Makefile     Mon Oct 18 18:10:19 2021 +0000
+++ b/tests/usr.bin/indent/Makefile     Mon Oct 18 19:36:29 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.17 2021/10/18 18:10:20 rillig Exp $
+#      $NetBSD: Makefile,v 1.18 2021/10/18 19:36:30 rillig Exp $
 
 .include <bsd.own.mk>
 
@@ -11,11 +11,6 @@
 FILESDIR=      ${TESTSDIR}
 FILES=         block.0
 FILES+=                block.0.stdout
-FILES+=                comment-line-end.0
-FILES+=                comment-line-end.0.stdout
-FILES+=                comments.0
-FILES+=                comments.0.pro
-FILES+=                comments.0.stdout
 FILES+=                declarations.0
 FILES+=                declarations.0.stderr
 FILES+=                declarations.0.stdout
@@ -164,9 +159,6 @@
 FILES+=                token-comma.0
 FILES+=                token-comma.0.pro
 FILES+=                token-comma.0.stdout
-FILES+=                token-comment.0
-FILES+=                token-comment.0.pro
-FILES+=                token-comment.0.stdout
 FILES+=                token-decl.0
 FILES+=                token-decl.0.pro
 FILES+=                token-decl.0.stdout
@@ -263,6 +255,7 @@
 FILES+=                token-while_expr.0
 FILES+=                token-while_expr.0.pro
 FILES+=                token-while_expr.0.stdout
+FILES+=                token_comment.c
 FILES+=                token_ident.c
 FILES+=                types_from_file.0
 FILES+=                types_from_file.0.stdout
diff -r 22fe99d8f42d -r e6370a16e815 tests/usr.bin/indent/comment-line-end.0
--- a/tests/usr.bin/indent/comment-line-end.0   Mon Oct 18 18:10:19 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/* $NetBSD: comment-line-end.0,v 1.8 2021/09/30 22:45:34 rillig Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Demonstrates handling of line-end '//' comments.
- *
- * Even though this type of comments had been added in C99, indent didn't
- * support these comments until 2021 and instead messed up the code in
- * unpredictable ways.
- */
-
-int dummy // comment
-= // eq
-1 // one
-+ // plus
-2; // two
-
-/////separator/////
-
-void function(void){}
-
-// Note: removing one of these line-end comments affected the formatting
-// of the main function below, before indent supported '//' comments.
-
-int
-main(void)
-{
-}
-
-void c99_comment(void)
-{
-foo(); // C++ comment
-bar();
-}
-
-void
-comment_at_end_of_function(void)
-{
-    if (cond)
-       statement();
-    // comment
-}
-
-// end-of-line comment at the end of the file
diff -r 22fe99d8f42d -r e6370a16e815 tests/usr.bin/indent/comment-line-end.0.stdout
--- a/tests/usr.bin/indent/comment-line-end.0.stdout    Mon Oct 18 18:10:19 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/* $NetBSD: comment-line-end.0.stdout,v 1.9 2021/10/08 18:29:36 rillig Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Demonstrates handling of line-end '//' comments.
- *
- * Even though this type of comments had been added in C99, indent didn't
- * support these comments until 2021 and instead messed up the code in
- * unpredictable ways.
- */
-
-int            dummy           // comment
-=                              // eq
-1                              // one
-+                              // plus
-2;                             // two
-
-/////separator/////
-
-void
-function(void)
-{
-}
-
-// Note: removing one of these line-end comments affected the formatting
-// of the main function below, before indent supported '//' comments.
-
-int
-main(void)
-{
-}
-
-void
-c99_comment(void)
-{
-       foo();                  // C++ comment
-       bar();
-}
-
-void
-comment_at_end_of_function(void)
-{
-       if (cond)
-               statement();
-       // comment
-}
-
-// end-of-line comment at the end of the file
diff -r 22fe99d8f42d -r e6370a16e815 tests/usr.bin/indent/comments.0
--- a/tests/usr.bin/indent/comments.0   Mon Oct 18 18:10:19 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*     $NetBSD: comments.0,v 1.3 2021/09/24 17:37:55 rillig Exp $      */
-/* $FreeBSD: head/usr.bin/indent/tests/comments.0 321383 2017-07-23 15:07:52Z pstef $ */
-
-typedef enum x {
-       aaaaaaaaaaaaaaaaaaaaaa = 1 << 0,        /* test a */
-       bbbbbbbbbbbbbbbbb = 1 << 1,     /* test b */
-       cccccccccccccc = 1 << 1,        /* test c */
-       dddddddddddddddddddddddddddddd = 1 << 2 /* test d */
-} x;
-
-/* See r303597, r303598, r309219, and r309343 */
-void t(void) {
-       /*
-        * Old indent wrapped the URL near where this sentence ends.
-        *
-        * https://www.freebsd.org/cgi/man.cgi?query=indent&apropos=0&sektion=0&manpath=FreeBSD+12-current&arch=default&format=html
-        */
-
-       /*
-        * The default maximum line length for comments is 78, and the 'kk' at
-        * the end makes the line exactly 78 bytes long.
-        *
-        * aaaaaa bbbbbb cccccc dddddd eeeeee ffffff ggggg hhhhh iiiii jjjj kk
-        */
-
-       /*
-        * Old indent unnecessarily removed the star comment continuation on the next line.
-        *
-        * *test*
-        */
-
-       /* r309219 Go through linked list, freeing from the malloced (t[-1]) address. */
-
-       /* r309343      */
-}
-
-int c(void)
-{
-       if (1) { /*- a christmas tree  *
-                                     ***
-                                    ***** */
-                   /*- another one *
-                                  ***
-                                 ***** */
-           7;
-       }
-
-       if (1) /*- a christmas tree  *
-                                   ***
-                                  ***** */
-                   /*- another one *
-                                  ***
-                                 ***** */
-           1;
-}
diff -r 22fe99d8f42d -r e6370a16e815 tests/usr.bin/indent/comments.0.pro
--- a/tests/usr.bin/indent/comments.0.pro       Mon Oct 18 18:10:19 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-/*     $NetBSD: comments.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $   */
-/* $FreeBSD: head/usr.bin/indent/tests/comments.0.pro 321383 2017-07-23 15:07:52Z pstef $ */
--bbb
diff -r 22fe99d8f42d -r e6370a16e815 tests/usr.bin/indent/comments.0.stdout
--- a/tests/usr.bin/indent/comments.0.stdout    Mon Oct 18 18:10:19 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*     $NetBSD: comments.0.stdout,v 1.3 2021/09/24 17:37:55 rillig Exp $       */
-/* $FreeBSD: head/usr.bin/indent/tests/comments.0.stdout 334563 2018-06-03 15:28:55Z pstef $ */
-
-typedef enum x {
-       aaaaaaaaaaaaaaaaaaaaaa = 1 << 0,        /* test a */
-       bbbbbbbbbbbbbbbbb = 1 << 1,     /* test b */
-       cccccccccccccc = 1 << 1,        /* test c */
-       dddddddddddddddddddddddddddddd = 1 << 2 /* test d */
-} x;
-
-/* See r303597, r303598, r309219, and r309343 */
-void
-t(void)
-{
-       /*
-        * Old indent wrapped the URL near where this sentence ends.
-        *
-        * https://www.freebsd.org/cgi/man.cgi?query=indent&apropos=0&sektion=0&manpath=FreeBSD+12-current&arch=default&format=html
-        */
-
-       /*
-        * The default maximum line length for comments is 78, and the 'kk' at
-        * the end makes the line exactly 78 bytes long.
-        *
-        * aaaaaa bbbbbb cccccc dddddd eeeeee ffffff ggggg hhhhh iiiii jjjj kk
-        */
-
-       /*
-        * Old indent unnecessarily removed the star comment continuation on
-        * the next line.
-        *
-        * *test*
-        */
-
-       /*
-        * r309219 Go through linked list, freeing from the malloced (t[-1])
-        * address.
-        */
-
-       /* r309343      */
-}
-
-int
-c(void)



Home | Main Index | Thread Index | Old Index