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 empty lines in ...
details: https://anonhg.NetBSD.org/src/rev/6cac3754677b
branches: trunk
changeset: 1026363:6cac3754677b
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Nov 20 11:13:18 2021 +0000
description:
tests/indent: normalize empty lines in tests
diffstat:
tests/usr.bin/indent/fmt_decl.c | 3 ++-
tests/usr.bin/indent/indent_off_on.c | 3 ++-
tests/usr.bin/indent/label.c | 4 +++-
tests/usr.bin/indent/opt_bs.c | 3 ++-
tests/usr.bin/indent/opt_ci.c | 3 ++-
tests/usr.bin/indent/opt_di.c | 3 +--
tests/usr.bin/indent/opt_dj.c | 3 ++-
tests/usr.bin/indent/opt_pcs.c | 3 ++-
tests/usr.bin/indent/opt_psl.c | 4 +++-
tests/usr.bin/indent/opt_sc.c | 3 ++-
tests/usr.bin/indent/opt_v.c | 3 ++-
tests/usr.bin/indent/t_options.awk | 29 ++++++++++++++++++++++++++++-
tests/usr.bin/indent/token_binary_op.c | 3 ++-
tests/usr.bin/indent/token_colon.c | 4 +++-
tests/usr.bin/indent/token_comma.c | 3 ++-
tests/usr.bin/indent/token_comment.c | 21 ++++++++++++++++-----
tests/usr.bin/indent/token_ident.c | 3 ++-
17 files changed, 76 insertions(+), 22 deletions(-)
diffs (truncated from 499 to 300 lines):
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/fmt_decl.c
--- a/tests/usr.bin/indent/fmt_decl.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/fmt_decl.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fmt_decl.c,v 1.20 2021/11/20 09:59:53 rillig Exp $ */
+/* $NetBSD: fmt_decl.c,v 1.21 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
/*
@@ -369,6 +369,7 @@
}
#indent end
+
#indent input
int *
y(void) {
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/indent_off_on.c
--- a/tests/usr.bin/indent/indent_off_on.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/indent_off_on.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent_off_on.c,v 1.4 2021/11/19 22:24:29 rillig Exp $ */
+/* $NetBSD: indent_off_on.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -91,6 +91,7 @@
}
#indent end
+
/*
* The INDENT comments can be written without space between the words, but
* nobody does this.
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/label.c
--- a/tests/usr.bin/indent/label.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/label.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: label.c,v 1.1 2021/10/18 20:18:00 rillig Exp $ */
+/* $NetBSD: label.c,v 1.2 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD: head/usr.bin/indent/tests/label.0 313544 2017-02-10 09:31:39Z pstef $ */
/* See FreeBSD r303489 */
@@ -32,6 +32,7 @@
}
#indent end
+
#indent input
void
label_width(void)
@@ -62,6 +63,7 @@
}
#indent end
+
/*
* The indentation of statement labels is fixed to -2, it is not configurable.
*/
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/opt_bs.c
--- a/tests/usr.bin/indent/opt_bs.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/opt_bs.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bs.c,v 1.6 2021/11/19 22:24:29 rillig Exp $ */
+/* $NetBSD: opt_bs.c,v 1.7 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -61,6 +61,7 @@
}
#indent end
+
/*
* The option '-bs' only affects 'sizeof', not 'offsetof', even though these
* two keywords are syntactically similar.
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/opt_ci.c
--- a/tests/usr.bin/indent/opt_ci.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/opt_ci.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_ci.c,v 1.3 2021/11/01 23:44:08 rillig Exp $ */
+/* $NetBSD: opt_ci.c,v 1.4 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -58,6 +58,7 @@
3));
#indent end
+
/*
* Declarations in functions without parentheses.
*/
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/opt_di.c
--- a/tests/usr.bin/indent/opt_di.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/opt_di.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_di.c,v 1.4 2021/10/24 20:43:28 rillig Exp $ */
+/* $NetBSD: opt_di.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -85,7 +85,6 @@
* Ensure that all whitespace is normalized to be indented by 8 columns,
* which in the default configuration amounts to a single tab.
*/
-
#indent input
int space;
int tab;
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/opt_dj.c
--- a/tests/usr.bin/indent/opt_dj.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/opt_dj.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_dj.c,v 1.3 2021/10/18 07:11:31 rillig Exp $ */
+/* $NetBSD: opt_dj.c,v 1.4 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -30,6 +30,7 @@
#indent run-equals-prev-output -ndj
+
#indent input
void example(void) {
int decl;
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/opt_pcs.c
--- a/tests/usr.bin/indent/opt_pcs.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/opt_pcs.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_pcs.c,v 1.8 2021/10/31 21:43:43 rillig Exp $ */
+/* $NetBSD: opt_pcs.c,v 1.9 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -57,6 +57,7 @@
int var = (function)(arg);
#indent end
+
/*
* The option '-pcs' also applies to 'sizeof' and 'offsetof', even though
* these are not functions.
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/opt_psl.c
--- a/tests/usr.bin/indent/opt_psl.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/opt_psl.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_psl.c,v 1.4 2021/10/18 07:11:31 rillig Exp $ */
+/* $NetBSD: opt_psl.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -22,6 +22,7 @@
#indent run-equals-prev-output -npsl
+
/*
* Multi-line function declarations are affected by these options since indent
* wrongly assumes they were function definitions, not declarations.
@@ -46,6 +47,7 @@
void);
#indent end
+
/*
* In a function definition, in contrast to a declaration, the function name
* is not indented to column 17 since the other function definitions are too
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/opt_sc.c
--- a/tests/usr.bin/indent/opt_sc.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/opt_sc.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_sc.c,v 1.4 2021/10/18 07:11:31 rillig Exp $ */
+/* $NetBSD: opt_sc.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -50,6 +50,7 @@
*/
#indent end
+
/*
* Comments that start with '*' or '-' do not get modified at all.
*/
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/opt_v.c
--- a/tests/usr.bin/indent/opt_v.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/opt_v.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_v.c,v 1.4 2021/11/07 15:44:28 rillig Exp $ */
+/* $NetBSD: opt_v.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -46,6 +46,7 @@
(Lines with comments)/(Lines with code): 0.571
#indent end
+
#indent input
void
example(void)
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/t_options.awk
--- a/tests/usr.bin/indent/t_options.awk Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/t_options.awk Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_options.awk,v 1.4 2021/11/20 10:24:30 rillig Exp $
+# $NetBSD: t_options.awk,v 1.5 2021/11/20 11:13:18 rillig Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -56,6 +56,10 @@
warned = 0
died = 0
+ prev_empty_lines = 0 # the finished "block" of empty lines
+ curr_empty_lines = 0 # the ongoing "block" of empty lines
+ seen_input_section = 0 # the first input section is not checked
+
section = "" # "", "input" or "run"
section_excl_comm = "" # without dollar comments
section_incl_comm = "" # with dollar comments
@@ -106,6 +110,20 @@
close(cmd)
}
+section == "" {
+ if (NF == 0)
+ curr_empty_lines++
+ else {
+ if (curr_empty_lines > 0) {
+ if (prev_empty_lines > 1)
+ warn(NR - curr_empty_lines,
+ "excess empty lines a few lines above")
+ prev_empty_lines = curr_empty_lines
+ }
+ curr_empty_lines = 0
+ }
+}
+
# Hide comments starting with dollar from indent; they are used for marking
# bugs and adding other remarks directly in the input or output sections.
/^[[:space:]]*\/[*][[:space:]]*[$].*[*]\/$/ ||
@@ -120,15 +138,22 @@
print $0 > "expected.out"
if ($2 == "input") {
+ if (prev_empty_lines != 2 && seen_input_section)
+ warn(NR, "input section needs 2 empty lines above, " \
+ "not " prev_empty_lines)
check_unused_input()
section = "input"
section_excl_comm = ""
section_incl_comm = ""
unused_input_lineno = NR
+ seen_input_section = 1
} else if ($2 == "run") {
if (section != "")
warn(NR, "unfinished section " quote(section))
+ if (prev_empty_lines != 1)
+ warn(NR, "run section needs 1 empty line above, " \
+ "not " prev_empty_lines)
section = "run"
output_lineno = NR
section_excl_comm = ""
@@ -173,6 +198,8 @@
die(NR, "invalid line " quote($0))
}
+ prev_empty_lines = 0
+ curr_empty_lines = 0
next
}
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/token_binary_op.c
--- a/tests/usr.bin/indent/token_binary_op.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/token_binary_op.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token_binary_op.c,v 1.7 2021/11/04 17:12:12 rillig Exp $ */
+/* $NetBSD: token_binary_op.c,v 1.8 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -139,6 +139,7 @@
}
#indent end
+
#indent input
void
peculiarities(void)
diff -r a4471975c6dd -r 6cac3754677b tests/usr.bin/indent/token_colon.c
--- a/tests/usr.bin/indent/token_colon.c Sat Nov 20 10:24:30 2021 +0000
+++ b/tests/usr.bin/indent/token_colon.c Sat Nov 20 11:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token_colon.c,v 1.1 2021/10/18 22:30:34 rillig Exp $ */
+/* $NetBSD: token_colon.c,v 1.2 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
Home |
Main Index |
Thread Index |
Old Index