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: test in-place formatting ...



details:   https://anonhg.NetBSD.org/src/rev/43b22af1a864
branches:  trunk
changeset: 1026474:43b22af1a864
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Nov 25 21:39:21 2021 +0000

description:
tests/indent: test in-place formatting with parse errors

The file gets formatted until the end, despite the parse error. This may
destroy layout details of the code but usually preserves the overall
structure. Since all source code is supposed to be under version
control, this is not a problem.

diffstat:

 tests/usr.bin/indent/t_misc.sh |  21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diffs (41 lines):

diff -r 46c5063dfc2f -r 43b22af1a864 tests/usr.bin/indent/t_misc.sh
--- a/tests/usr.bin/indent/t_misc.sh    Thu Nov 25 21:01:32 2021 +0000
+++ b/tests/usr.bin/indent/t_misc.sh    Thu Nov 25 21:39:21 2021 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_misc.sh,v 1.17 2021/11/20 09:59:53 rillig Exp $
+# $NetBSD: t_misc.sh,v 1.18 2021/11/25 21:39:21 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -53,6 +53,24 @@
            cat code.c.bak
 }
 
+atf_test_case 'in_place_parse_error'
+in_place_parse_error_body()
+{
+       # On normal parse errors, indent continues until the end of the file.
+       # This means that even in the case of errors, not much is lost.
+
+       cat <<-\EOF > code.c
+               int line1;
+               }
+               int line3;
+       EOF
+
+       atf_check -s 'exit:1' -e 'ignore' \
+          "$indent" code.c
+       atf_check -o 'inline:int\t\tline1;\n}\nint\t\tline3;\n' \
+           cat code.c
+}
+
 atf_test_case 'verbose_profile'
 verbose_profile_body()
 {
@@ -397,4 +415,5 @@
        atf_add_test_case 'default_backup_extension'
        atf_add_test_case 'several_profiles'
        atf_add_test_case 'command_line_vs_profile'
+       atf_add_test_case 'in_place_parse_error'
 }



Home | Main Index | Thread Index | Old Index