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: extend tests for labels, ...



details:   https://anonhg.NetBSD.org/src/rev/07a51b1b1fd4
branches:  trunk
changeset: 989886:07a51b1b1fd4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Oct 18 20:18:00 2021 +0000

description:
tests/indent: extend tests for labels, extract test driver

Having the test driver in a separate file allows to run it on its own,
as 'awk -f t_options.awk label.c'. When the test driver warns, exit 1;
this is only needed for the standalone version, when run from inside ATF
the warnings on stderr already suffice to make the test fail in the end.

diffstat:

 distrib/sets/lists/tests/mi         |   10 +-
 tests/usr.bin/indent/Makefile       |    7 +-
 tests/usr.bin/indent/label.0        |   44 --------
 tests/usr.bin/indent/label.0.pro    |    3 -
 tests/usr.bin/indent/label.0.stdout |   45 --------
 tests/usr.bin/indent/label.c        |  124 +++++++++++++++++++++++
 tests/usr.bin/indent/t_options.awk  |  192 ++++++++++++++++++++++++++++++++++++
 tests/usr.bin/indent/t_options.sh   |  143 +--------------------------
 8 files changed, 327 insertions(+), 241 deletions(-)

diffs (truncated from 648 to 300 lines):

diff -r 1bd095d61871 -r 07a51b1b1fd4 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Mon Oct 18 19:36:29 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Mon Oct 18 20:18:00 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1143 2021/10/18 19:36:29 rillig Exp $
+# $NetBSD: mi,v 1.1144 2021/10/18 20:18:00 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4755,9 +4755,10 @@
 ./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
+./usr/tests/usr.bin/indent/label.0                                     tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/indent/label.0.pro                                 tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/indent/label.0.stdout                              tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/indent/label.c                                     tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/lex.0                                       tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/lex.0.pro                                   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/lex.0.stdout                                        tests-usr.bin-tests     compattestfile,atf
@@ -5034,6 +5035,7 @@
 ./usr/tests/usr.bin/indent/t_indent                                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/t_misc                                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/t_options                                   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/t_options.awk                               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token-binary_op.0                           tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token-binary_op.0.pro                       tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token-binary_op.0.stdout                    tests-usr.bin-tests     compattestfile,atf
diff -r 1bd095d61871 -r 07a51b1b1fd4 tests/usr.bin/indent/Makefile
--- a/tests/usr.bin/indent/Makefile     Mon Oct 18 19:36:29 2021 +0000
+++ b/tests/usr.bin/indent/Makefile     Mon Oct 18 20:18:00 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.18 2021/10/18 19:36:30 rillig Exp $
+#      $NetBSD: Makefile,v 1.19 2021/10/18 20:18:00 rillig Exp $
 
 .include <bsd.own.mk>
 
@@ -22,9 +22,7 @@
 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
+FILES+=                label.c
 FILES+=                lex.0
 FILES+=                lex.0.pro
 FILES+=                lex.0.stdout
@@ -147,6 +145,7 @@
 FILES+=                surplusbad.0
 FILES+=                surplusbad.0.stdout
 FILES+=                surplusbad.0.pro
+FILES+=                t_options.awk
 FILES+=                token-binary_op.0
 FILES+=                token-binary_op.0.pro
 FILES+=                token-binary_op.0.stdout
diff -r 1bd095d61871 -r 07a51b1b1fd4 tests/usr.bin/indent/label.0
--- a/tests/usr.bin/indent/label.0      Mon Oct 18 19:36:29 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*     $NetBSD: label.0,v 1.2 2021/09/27 19:02:44 rillig Exp $ */
-/* $FreeBSD: head/usr.bin/indent/tests/label.0 313544 2017-02-10 09:31:39Z pstef $ */
-/* See r303489 */
-void t(void) {
-       switch (1)
-       {
-               case 1: /* test */
-               case 2:         /* test */
-       }
-CLEANUP:
-       ;
-V: ;
-U: ;
-}
-
-/*
- * The indentation of statement labels is fixed to -2, it is not configurable.
- */
-void
-label_indentation(void)
-{
-       if (level1) {
-       if (level2) {
-       if (level3) {
-       if (level4) {
-       if (level5) {
-       label5:
-       statement();
-       }
-       label4:
-       statement();
-       }
-       label3:
-       statement();
-       }
-       label2:
-       statement();
-       }
-       label1:
-       statement();
-       }
-       label0:
-       statement();
-}
diff -r 1bd095d61871 -r 07a51b1b1fd4 tests/usr.bin/indent/label.0.pro
--- a/tests/usr.bin/indent/label.0.pro  Mon Oct 18 19:36:29 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-/*     $NetBSD: label.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $      */
-/* $FreeBSD: head/usr.bin/indent/tests/label.0.pro 314613 2017-03-03 20:15:22Z ngie $ */
--nut
diff -r 1bd095d61871 -r 07a51b1b1fd4 tests/usr.bin/indent/label.0.stdout
--- a/tests/usr.bin/indent/label.0.stdout       Mon Oct 18 19:36:29 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*     $NetBSD: label.0.stdout,v 1.2 2021/09/27 19:02:44 rillig Exp $  */
-/* $FreeBSD: head/usr.bin/indent/tests/label.0.stdout 321381 2017-07-23 14:04:45Z pstef $ */
-/* See r303489 */
-void
-t(void)
-{
-        switch (1) {
-        case 1:                 /* test */
-        case 2:                 /* test */
-        }
-CLEANUP:
-        ;
-V:      ;
-U:      ;
-}
-
-/*
- * The indentation of statement labels is fixed to -2, it is not configurable.
- */
-void
-label_indentation(void)
-{
-        if (level1) {
-                if (level2) {
-                        if (level3) {
-                                if (level4) {
-                                        if (level5) {
-                                label5:
-                                                statement();
-                                        }
-                        label4:
-                                        statement();
-                                }
-                label3:
-                                statement();
-                        }
-        label2:
-                        statement();
-                }
-label1:
-                statement();
-        }
-label0:
-        statement();
-}
diff -r 1bd095d61871 -r 07a51b1b1fd4 tests/usr.bin/indent/label.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/label.c      Mon Oct 18 20:18:00 2021 +0000
@@ -0,0 +1,124 @@
+/*     $NetBSD: label.c,v 1.1 2021/10/18 20:18:00 rillig Exp $ */
+/* $FreeBSD: head/usr.bin/indent/tests/label.0 313544 2017-02-10 09:31:39Z pstef $ */
+
+/* See FreeBSD r303489 */
+
+#indent input
+void t(void) {
+       switch (1)
+       {
+               case 1: /* test */
+               case 2:         /* test */
+       }
+CLEANUP:
+       ;
+V: ;
+U: ;
+}
+#indent end
+
+#indent run
+void
+t(void)
+{
+       switch (1) {
+       case 1:                 /* test */
+       case 2:                 /* test */
+       }
+CLEANUP:
+       ;
+V:     ;
+U:     ;
+}
+#indent end
+
+#indent input
+void
+label_width(void)
+{
+L:;
+L2:;
+L_3:;
+L__4:;
+L___5:;
+L____6:;
+L_____7:;
+L______8:;
+}
+#indent end
+
+#indent run
+void
+label_width(void)
+{
+L:     ;
+L2:    ;
+L_3:   ;
+L__4:  ;
+L___5: ;
+L____6:        ;
+L_____7:;
+L______8:;
+}
+#indent end
+
+/*
+ * The indentation of statement labels is fixed to -2, it is not configurable.
+ */
+#indent input
+void
+label_indentation(void)
+{
+       if (level1) {
+       if (level2) {
+       if (level3) {
+       if (level4) {
+       if (level5) {
+       label5:
+       statement();
+       }
+       label4:
+       statement();
+       }
+       label3:
+       statement();
+       }
+       label2:
+       statement();
+       }
+       label1:
+       statement();
+       }
+       label0:
+       statement();
+}
+#indent end
+
+#indent run
+void
+label_indentation(void)
+{
+       if (level1) {
+               if (level2) {
+                       if (level3) {
+                               if (level4) {
+                                       if (level5) {
+                               label5:
+                                               statement();
+                                       }
+                       label4:
+                                       statement();
+                               }
+               label3:
+                               statement();
+                       }
+       label2:
+                       statement();
+               }
+label1:
+               statement();
+       }
+label0:
+       statement();
+}
+#indent end
diff -r 1bd095d61871 -r 07a51b1b1fd4 tests/usr.bin/indent/t_options.awk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/t_options.awk        Mon Oct 18 20:18:00 2021 +0000
@@ -0,0 +1,192 @@
+# $NetBSD: t_options.awk,v 1.1 2021/10/18 20:18:00 rillig Exp $
+#
+# Copyright (c) 2021 The NetBSD Foundation, Inc.
+# All rights reserved.
+#



Home | Main Index | Thread Index | Old Index