Module Name: src
Committed By: rillig
Date: Sun Apr 24 08:52:44 UTC 2022
Modified Files:
src/tests/usr.bin/indent: fmt_decl.c lsym_offsetof.c opt_bacc.c
opt_badp.c opt_bs.c opt_ci.c opt_fcb.c opt_l.c t_options.awk
token_comment.c token_string_prefix.c
Log Message:
tests/indent: normalize amount of empty lines between test cases
To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/lsym_offsetof.c \
src/tests/usr.bin/indent/opt_l.c \
src/tests/usr.bin/indent/token_string_prefix.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/opt_bacc.c \
src/tests/usr.bin/indent/opt_bs.c src/tests/usr.bin/indent/t_options.awk
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/opt_badp.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/opt_ci.c \
src/tests/usr.bin/indent/opt_fcb.c
cvs rdiff -u -r1.28 -r1.29 src/tests/usr.bin/indent/token_comment.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/indent/fmt_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.33 src/tests/usr.bin/indent/fmt_decl.c:1.34
--- src/tests/usr.bin/indent/fmt_decl.c:1.33 Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/fmt_decl.c Sun Apr 24 08:52:44 2022
@@ -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 @@ ToToken(bool cond)
#indent end
#indent run-equals-input -TToken
+
/* Since lexi.c 1.153 from 2021-11-25. */
#indent run-equals-input
@@ -647,6 +648,7 @@ static CachedDir *dot = NULL;
#indent end
#indent run-equals-input -TCachedDir
+
/* Since lexi.c 1.153 from 2021-11-25. */
#indent run-equals-input
@@ -713,6 +715,7 @@ CachedDir_Assign(CachedDir **var, Cached
#indent end
#indent run-equals-input
+
#indent run-equals-input -TCachedDir
Index: src/tests/usr.bin/indent/lsym_offsetof.c
diff -u src/tests/usr.bin/indent/lsym_offsetof.c:1.3 src/tests/usr.bin/indent/lsym_offsetof.c:1.4
--- src/tests/usr.bin/indent/lsym_offsetof.c:1.3 Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/lsym_offsetof.c Sun Apr 24 08:52:44 2022
@@ -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 @@ size_t offset = offsetof(struct s, memb
#indent end
#indent run-equals-input
+
#indent run-equals-input -bs
/*
Index: src/tests/usr.bin/indent/opt_l.c
diff -u src/tests/usr.bin/indent/opt_l.c:1.3 src/tests/usr.bin/indent/opt_l.c:1.4
--- src/tests/usr.bin/indent/opt_l.c:1.3 Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/opt_l.c Sun Apr 24 08:52:44 2022
@@ -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
Index: src/tests/usr.bin/indent/token_string_prefix.c
diff -u src/tests/usr.bin/indent/token_string_prefix.c:1.3 src/tests/usr.bin/indent/token_string_prefix.c:1.4
--- src/tests/usr.bin/indent/token_string_prefix.c:1.3 Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/token_string_prefix.c Sun Apr 24 08:52:44 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: token_string_prefix.c,v 1.3 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: token_string_prefix.c,v 1.4 2022/04/24 08:52:44 rillig Exp $ */
/*
* Tests for strings of wide characters, which are prefixed with 'L'.
@@ -15,7 +15,9 @@ wchar_t wide_string[] = L"wide string";
* string literal.
*/
#indent run-equals-input -di0
+
#indent run-equals-input -di0 -l25
+
#indent run-equals-input -di0 -l1
Index: src/tests/usr.bin/indent/opt_bacc.c
diff -u src/tests/usr.bin/indent/opt_bacc.c:1.8 src/tests/usr.bin/indent/opt_bacc.c:1.9
--- src/tests/usr.bin/indent/opt_bacc.c:1.8 Sat Apr 23 06:43:23 2022
+++ src/tests/usr.bin/indent/opt_bacc.c Sun Apr 24 08:52:44 2022
@@ -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 @@ int outer_below;
#indent end
#indent run-equals-input -di0 -bacc
+
#indent run-equals-input -di0 -nbacc
Index: src/tests/usr.bin/indent/opt_bs.c
diff -u src/tests/usr.bin/indent/opt_bs.c:1.8 src/tests/usr.bin/indent/opt_bs.c:1.9
--- src/tests/usr.bin/indent/opt_bs.c:1.8 Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/opt_bs.c Sun Apr 24 08:52:44 2022
@@ -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 @@ int sizeof_newline = sizeof
#indent end
#indent run-equals-input -di0 -bs
+
#indent run-equals-input -di0 -nbs
Index: src/tests/usr.bin/indent/t_options.awk
diff -u src/tests/usr.bin/indent/t_options.awk:1.8 src/tests/usr.bin/indent/t_options.awk:1.9
--- src/tests/usr.bin/indent/t_options.awk:1.8 Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/t_options.awk Sun Apr 24 08:52:44 2022
@@ -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 @@ BEGIN {
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 @@ function quote(s)
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 @@ section == "" {
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 @@ section == "" {
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 @@ section == "" {
} 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 @@ section == "" {
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 @@ section == "" {
input_excl_comm = section_excl_comm
input_incl_comm = section_incl_comm
section = ""
+ max_empty_lines = 0
} else if ($2 == "end" && section == "run") {
if (section_incl_comm == input_incl_comm)
@@ -187,6 +203,7 @@ section == "" {
output_excl_comm = section_excl_comm
output_incl_comm = section_incl_comm
section = ""
+ max_empty_lines = 0
} else if ($2 == "end") {
warn(NR, "misplaced " quote("#indent end"))
Index: src/tests/usr.bin/indent/opt_badp.c
diff -u src/tests/usr.bin/indent/opt_badp.c:1.7 src/tests/usr.bin/indent/opt_badp.c:1.8
--- src/tests/usr.bin/indent/opt_badp.c:1.7 Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/opt_badp.c Sun Apr 24 08:52:44 2022
@@ -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 @@ empty(void)
#indent end
#indent run-equals-input -badp
+
#indent run-equals-input -nbadp
@@ -27,6 +28,7 @@ blank(void)
#indent end
#indent run-equals-input -badp
+
#indent run-equals-input -nbadp
@@ -39,6 +41,7 @@ declaration(void)
#indent end
#indent run-equals-input -badp
+
#indent run-equals-input -nbadp
@@ -58,6 +61,7 @@ statement(void)
stmt();
}
#indent end
+
#indent run-equals-input -nbadp
@@ -79,6 +83,7 @@ declaration_statement(void)
stmt();
}
#indent end
+
#indent run-equals-input -nbadp
@@ -93,6 +98,7 @@ declaration_blank_statement(void)
#indent end
#indent run-equals-input -badp
+
#indent run-equals-input -nbadp
@@ -109,4 +115,5 @@ declaration_blank_blank_statement(void)
#indent end
#indent run-equals-input -badp
+
#indent run-equals-input -nbadp
Index: src/tests/usr.bin/indent/opt_ci.c
diff -u src/tests/usr.bin/indent/opt_ci.c:1.6 src/tests/usr.bin/indent/opt_ci.c:1.7
--- src/tests/usr.bin/indent/opt_ci.c:1.6 Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/opt_ci.c Sun Apr 24 08:52:44 2022
@@ -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 @@ int top_level = (1 +
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 @@ sum(int a, int b)
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
Index: src/tests/usr.bin/indent/opt_fcb.c
diff -u src/tests/usr.bin/indent/opt_fcb.c:1.6 src/tests/usr.bin/indent/opt_fcb.c:1.7
--- src/tests/usr.bin/indent/opt_fcb.c:1.6 Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/opt_fcb.c Sun Apr 24 08:52:44 2022
@@ -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 @@ example(void)
#indent end
#indent run-equals-input -fcb
+
#indent run-equals-input -nfcb
Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.28 src/tests/usr.bin/indent/token_comment.c:1.29
--- src/tests/usr.bin/indent/token_comment.c:1.28 Fri Apr 22 21:21:20 2022
+++ src/tests/usr.bin/indent/token_comment.c Sun Apr 24 08:52:44 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.28 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.29 2022/04/24 08:52:44 rillig Exp $ */
/*
* Tests for formatting comments. C99 defines block comments and end-of-line
@@ -851,6 +851,7 @@ comment_at_end_of_function(void)
int decl;
// end-of-line comment at the end of the file
#indent end
+
#indent run-equals-input
@@ -861,6 +862,7 @@ int decl;
*/
/*-AE*/
#indent end
+
#indent run-equals-input
@@ -975,6 +977,7 @@ f(void)
#indent end
#indent run-equals-input -l5
+
#indent run-equals-input -l32
@@ -1010,6 +1013,7 @@ line 4 */
#indent end
#indent run-equals-input -nfc1
+
#indent run-equals-input -nfc1 -nsc
#indent run -nsc