tests/indent: normalize amount of empty lines between test cases
This commit is contained in:
parent
15606711d7
commit
36e939358a
|
@ -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, CachedDir *dir)
|
|||
#indent end
|
||||
|
||||
#indent run-equals-input
|
||||
|
||||
#indent run-equals-input -TCachedDir
|
||||
|
||||
|
||||
|
|
|
@ -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, member);
|
|||
#indent end
|
||||
|
||||
#indent run-equals-input
|
||||
|
||||
#indent run-equals-input -bs
|
||||
|
||||
/*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue