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: normalize amount of empty...
details: https://anonhg.NetBSD.org/src/rev/044d8a07fb16
branches: trunk
changeset: 365769:044d8a07fb16
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Apr 24 08:52:44 2022 +0000
description:
tests/indent: normalize amount of empty lines between test cases
diffstat:
tests/usr.bin/indent/fmt_decl.c | 5 ++++-
tests/usr.bin/indent/lsym_offsetof.c | 3 ++-
tests/usr.bin/indent/opt_bacc.c | 3 ++-
tests/usr.bin/indent/opt_badp.c | 9 ++++++++-
tests/usr.bin/indent/opt_bs.c | 3 ++-
tests/usr.bin/indent/opt_ci.c | 8 +++++++-
tests/usr.bin/indent/opt_fcb.c | 4 +++-
tests/usr.bin/indent/opt_l.c | 4 +++-
tests/usr.bin/indent/t_options.awk | 19 ++++++++++++++++++-
tests/usr.bin/indent/token_comment.c | 6 +++++-
tests/usr.bin/indent/token_string_prefix.c | 4 +++-
11 files changed, 57 insertions(+), 11 deletions(-)
diffs (truncated from 371 to 300 lines):
diff -r 68e37d89d585 -r 044d8a07fb16 tests/usr.bin/indent/fmt_decl.c
--- a/tests/usr.bin/indent/fmt_decl.c Sun Apr 24 08:48:17 2022 +0000
+++ b/tests/usr.bin/indent/fmt_decl.c Sun Apr 24 08:52:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fmt_decl.c,v 1.33 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: fmt_decl.c,v 1.34 2022/04/24 08:52:44 rillig Exp $ */
/*
* Tests for declarations of global variables, external functions, and local
@@ -613,6 +613,7 @@
#indent end
#indent run-equals-input -TToken
+
/* Since lexi.c 1.153 from 2021-11-25. */
#indent run-equals-input
@@ -647,6 +648,7 @@
#indent end
#indent run-equals-input -TCachedDir
+
/* Since lexi.c 1.153 from 2021-11-25. */
#indent run-equals-input
@@ -713,6 +715,7 @@
#indent end
#indent run-equals-input
+
#indent run-equals-input -TCachedDir
diff -r 68e37d89d585 -r 044d8a07fb16 tests/usr.bin/indent/lsym_offsetof.c
--- a/tests/usr.bin/indent/lsym_offsetof.c Sun Apr 24 08:48:17 2022 +0000
+++ b/tests/usr.bin/indent/lsym_offsetof.c Sun Apr 24 08:52:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_offsetof.c,v 1.3 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: lsym_offsetof.c,v 1.4 2022/04/24 08:52:44 rillig Exp $ */
/*
* Tests for the token lsym_offsetof, which represents the keyword 'offsetof'
@@ -10,6 +10,7 @@
#indent end
#indent run-equals-input
+
#indent run-equals-input -bs
/*
diff -r 68e37d89d585 -r 044d8a07fb16 tests/usr.bin/indent/opt_bacc.c
--- a/tests/usr.bin/indent/opt_bacc.c Sun Apr 24 08:48:17 2022 +0000
+++ b/tests/usr.bin/indent/opt_bacc.c Sun Apr 24 08:52:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bacc.c,v 1.8 2022/04/23 06:43:23 rillig Exp $ */
+/* $NetBSD: opt_bacc.c,v 1.9 2022/04/24 08:52:44 rillig Exp $ */
/*
* Tests for the options '-bacc' and '-nbacc' ("blank line around conditional
@@ -145,4 +145,5 @@
#indent end
#indent run-equals-input -di0 -bacc
+
#indent run-equals-input -di0 -nbacc
diff -r 68e37d89d585 -r 044d8a07fb16 tests/usr.bin/indent/opt_badp.c
--- a/tests/usr.bin/indent/opt_badp.c Sun Apr 24 08:48:17 2022 +0000
+++ b/tests/usr.bin/indent/opt_badp.c Sun Apr 24 08:52:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_badp.c,v 1.7 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: opt_badp.c,v 1.8 2022/04/24 08:52:44 rillig Exp $ */
/*
* Tests for the options '-badp' and '-nbadp'.
@@ -15,6 +15,7 @@
#indent end
#indent run-equals-input -badp
+
#indent run-equals-input -nbadp
@@ -27,6 +28,7 @@
#indent end
#indent run-equals-input -badp
+
#indent run-equals-input -nbadp
@@ -39,6 +41,7 @@
#indent end
#indent run-equals-input -badp
+
#indent run-equals-input -nbadp
@@ -58,6 +61,7 @@
stmt();
}
#indent end
+
#indent run-equals-input -nbadp
@@ -79,6 +83,7 @@
stmt();
}
#indent end
+
#indent run-equals-input -nbadp
@@ -93,6 +98,7 @@
#indent end
#indent run-equals-input -badp
+
#indent run-equals-input -nbadp
@@ -109,4 +115,5 @@
#indent end
#indent run-equals-input -badp
+
#indent run-equals-input -nbadp
diff -r 68e37d89d585 -r 044d8a07fb16 tests/usr.bin/indent/opt_bs.c
--- a/tests/usr.bin/indent/opt_bs.c Sun Apr 24 08:48:17 2022 +0000
+++ b/tests/usr.bin/indent/opt_bs.c Sun Apr 24 08:52:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bs.c,v 1.8 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: opt_bs.c,v 1.9 2022/04/24 08:52:44 rillig Exp $ */
/*
* Tests for the options '-bs' and '-nbs' ("blank after sizeof").
@@ -106,6 +106,7 @@
#indent end
#indent run-equals-input -di0 -bs
+
#indent run-equals-input -di0 -nbs
diff -r 68e37d89d585 -r 044d8a07fb16 tests/usr.bin/indent/opt_ci.c
--- a/tests/usr.bin/indent/opt_ci.c Sun Apr 24 08:48:17 2022 +0000
+++ b/tests/usr.bin/indent/opt_ci.c Sun Apr 24 08:52:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_ci.c,v 1.6 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: opt_ci.c,v 1.7 2022/04/24 08:52:44 rillig Exp $ */
/*
* Tests for the option '-ci', which controls the indentation of continuation
@@ -23,8 +23,11 @@
2 + (
3));
#indent end
+
#indent run-equals-prev-output -ci2
+
#indent run-equals-prev-output -ci4
+
#indent run-equals-prev-output -ci8
#indent run -ci0 -nlp
@@ -143,8 +146,11 @@
third));
}
#indent end
+
#indent run-equals-prev-output -ci2
+
#indent run-equals-prev-output -ci4
+
#indent run-equals-prev-output -ci8
#indent run -ci2 -nlp
diff -r 68e37d89d585 -r 044d8a07fb16 tests/usr.bin/indent/opt_fcb.c
--- a/tests/usr.bin/indent/opt_fcb.c Sun Apr 24 08:48:17 2022 +0000
+++ b/tests/usr.bin/indent/opt_fcb.c Sun Apr 24 08:52:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_fcb.c,v 1.6 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: opt_fcb.c,v 1.7 2022/04/24 08:52:44 rillig Exp $ */
/*
* Tests for the options '-fcb' and '-nfcb'.
@@ -63,6 +63,7 @@
#indent end
#indent run-equals-input -fcb
+
#indent run-equals-input -nfcb
@@ -137,4 +138,5 @@
#indent end
#indent run-equals-input -fcb
+
#indent run-equals-input -nfcb
diff -r 68e37d89d585 -r 044d8a07fb16 tests/usr.bin/indent/opt_l.c
--- a/tests/usr.bin/indent/opt_l.c Sun Apr 24 08:48:17 2022 +0000
+++ b/tests/usr.bin/indent/opt_l.c Sun Apr 24 08:52:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_l.c,v 1.3 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: opt_l.c,v 1.4 2022/04/24 08:52:44 rillig Exp $ */
/*
* Tests for the option '-l', which specifies the maximum length of a line.
@@ -27,9 +27,11 @@
* same output.
*/
#indent end
+
#indent run-equals-prev-output -lc38
#indent run-equals-input -l78
+
#indent run-equals-input -lc78
diff -r 68e37d89d585 -r 044d8a07fb16 tests/usr.bin/indent/t_options.awk
--- a/tests/usr.bin/indent/t_options.awk Sun Apr 24 08:48:17 2022 +0000
+++ b/tests/usr.bin/indent/t_options.awk Sun Apr 24 08:52:44 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_options.awk,v 1.8 2022/04/22 21:21:20 rillig Exp $
+# $NetBSD: t_options.awk,v 1.9 2022/04/24 08:52:44 rillig Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -54,6 +54,7 @@
prev_empty_lines = 0 # the finished "block" of empty lines
curr_empty_lines = 0 # the ongoing "block" of empty lines
+ max_empty_lines = 0 # between sections
seen_input_section = 0 # the first input section is not checked
section = "" # "", "input" or "run"
@@ -89,6 +90,12 @@
return "'" s "'"
}
+function check_empty_lines_block(n)
+{
+ if (max_empty_lines != n && seen_input_section)
+ warn(NR, "expecting " n " empty " (n != 1 ? "lines" : "line") ", got " max_empty_lines)
+}
+
function check_unused_input()
{
if (unused_input_lineno != 0)
@@ -110,6 +117,8 @@
if (NF == 0)
curr_empty_lines++
else {
+ if (curr_empty_lines > max_empty_lines)
+ max_empty_lines = curr_empty_lines
if (curr_empty_lines > 0) {
if (prev_empty_lines > 1)
warn(NR - curr_empty_lines - 1,
@@ -138,6 +147,7 @@
if (prev_empty_lines != 2 && seen_input_section)
warn(NR, "input section needs 2 empty lines above, " \
"not " prev_empty_lines)
+ check_empty_lines_block(2)
check_unused_input()
section = "input"
section_excl_comm = ""
@@ -148,6 +158,7 @@
} else if ($2 == "run") {
if (section != "")
warn(NR, "unfinished section " quote(section))
+ check_empty_lines_block(1)
if (prev_empty_lines != 1)
warn(NR, "run section needs 1 empty line above, " \
"not " prev_empty_lines)
@@ -160,13 +171,17 @@
unused_input_lineno = 0
} else if ($2 == "run-equals-input") {
+ check_empty_lines_block(1)
run_indent(input_excl_comm)
printf("%s", input_excl_comm) > "expected.out"
unused_input_lineno = 0
+ max_empty_lines = 0
} else if ($2 == "run-equals-prev-output") {
+ check_empty_lines_block(1)
run_indent(input_excl_comm)
printf("%s", output_excl_comm) > "expected.out"
+ max_empty_lines = 0
} else if ($2 == "end" && section == "input") {
if (section_incl_comm == input_incl_comm)
@@ -175,6 +190,7 @@
input_excl_comm = section_excl_comm
input_incl_comm = section_incl_comm
section = ""
+ max_empty_lines = 0
Home |
Main Index |
Thread Index |
Old Index