gbranden pushed a commit to branch branden-2023-07-05 in repository groff. commit d47f7b46c4a395f52da09d27360ce444530c623a Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Sun Apr 30 06:03:08 2023 -0500
[eqn]: Improve tests of line number accuracy. * src/preproc/eqn/tests/diagnostics-report-correct-line-numbers.sh: Add cases to check behavior of valid input, not just error cases. Also add some unexecuted test cases for future use. --- ChangeLog | 9 ++++ .../diagnostics-report-correct-line-numbers.sh | 58 ++++++++++++++++++++-- 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75f8e8bd3..cf05c1004 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2023-04-30 G. Branden Robinson <g.branden.robin...@gmail.com> + + [eqn]: Improve tests of line number accuracy. + + * src/preproc/eqn/tests/\ + diagnostics-report-correct-line-numbers.sh: Add cases to check + behavior of valid input, not just error cases. Also add some + unexecuted test cases for future use. + 2023-04-29 G. Branden Robinson <g.branden.robin...@gmail.com> * src/include/lf.h (interpret_lf_args): diff --git a/src/preproc/eqn/tests/diagnostics-report-correct-line-numbers.sh b/src/preproc/eqn/tests/diagnostics-report-correct-line-numbers.sh index feb78c117..b9deb60a3 100755 --- a/src/preproc/eqn/tests/diagnostics-report-correct-line-numbers.sh +++ b/src/preproc/eqn/tests/diagnostics-report-correct-line-numbers.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2022 Free Software Foundation, Inc. +# Copyright (C) 2022-2023 Free Software Foundation, Inc. # # This file is part of groff. # @@ -19,6 +19,7 @@ # eqn="${abs_top_builddir:-.}/eqn" +groff="${abs_top_builddir:-.}/test-groff" fail= wail () { @@ -29,27 +30,74 @@ wail () { # Verify that correct input file line numbers are reported. +echo "checking for correct line number when no EQ/EN input" >&2 +error=$(printf '.\n.tm FNORD:\\n(.c\n' \ + | "$eqn" -Tascii | "$groff" -Tascii -z 2>&1 > /dev/null) +echo "$error" | grep -qx FNORD:2 || wail + +echo "checking for correct line number when EQ/EN input empty" >&2 +error=$(printf '.\n.EQ\n.EN\n.tm FNORD:\\n(.c\n' \ + | "$eqn" -Tascii | "$groff" -Tascii -z 2>&1 > /dev/null) +echo "$error" | grep -qx FNORD:4 || wail + +echo "checking for correct line number when EQ/EN input simple" >&2 +error=$(printf '.\n.EQ\nx\n.EN\n.tm FNORD:\\n(.c\n' \ + | "$eqn" -Tascii | "$groff" -Tascii -z 2>&1 > /dev/null) +echo "$error" | grep -qx FNORD:5 || wail + echo "checking for absent line number in early EOF diagnostic" >&2 input='.EQ' -error=$(printf "%s\n" "$input" | "$eqn" 2>&1 > /dev/null) +error=$(printf '%s\n' "$input" | "$eqn" 2>&1 > /dev/null) echo "$error" | grep -Eq '^[^:]+:[^:]+: fatal' || wail echo "checking for correct line number in nested 'EQ' diagnostic" >&2 input='.EQ .EQ' -error=$(printf "%s\n" "$input" | "$eqn" 2>&1 > /dev/null) +error=$(printf '%s\n' "$input" | "$eqn" 2>&1 > /dev/null) echo "$error" | grep -Eq '^[^:]+:[^:]+:2: fatal' || wail echo "checking for correct line number in invalid input character" \ "diagnostic" >&2 -error=$(printf ".EQ\nx\n.EN\n\200\n" | "$eqn" 2>&1 > /dev/null) +error=$(printf '.EQ\nx\n.EN\n\200\n' | "$eqn" 2>&1 > /dev/null) echo "$error" | grep -Eq '^[^:]+:[^:]+:4: error' || wail echo "checking for correct line number in invalid input character" \ "diagnostic when 'lf' request used beforehand" >&2 -error=$(printf ".EQ\nx\n.EN\n.lf 99\n\200\n" | "$eqn" 2>&1 > /dev/null) +error=$(printf '.EQ\nx\n.EN\n.lf 99\n\200\n' | "$eqn" 2>&1 > /dev/null) echo "$error" | grep -Eq '^[^:]+:[^:]+:99: error' || wail +echo "checking for correct line number when invalid 'lf' request used" \ + >&2 +error=$(printf '.lf xyz\n.EQ\n.EQ\n' | "$eqn" 2>&1 > /dev/null) +echo "$error" | grep -Eq '^[^:]+:[^:]+:3: fatal error' || wail + +echo "checking for correct line number when input begins with" \ + "delimited equation and '-N' not used" >&2 +error=$(printf '$ x =\n' | "$eqn" -Tascii -d'$$' 2>&1 > /dev/null) +echo "$error" | grep -Eq '^[^:]+:[^:]+:1: fatal error' || wail + +echo "checking for correct line number when input begins with" \ + "delimited equation and '-N' is used" >&2 +error=$(printf '$ x =\n' | "$eqn" -Tascii -d'$$' -N 2>&1 > /dev/null) +echo "$error" | grep -Eq '^[^:]+:[^:]+:1: error' || wail + +test -z "$fail" +exit + +# tests for future use + +echo "checking for correct line number when later input contains" \ + "delimited equation and '-N' not used" >&2 +error=$(printf '.EQ\ndelim $$\n.EN\n$x =\n' \ + | "$eqn" -Tascii 2>&1 > /dev/null) +echo "$error" | grep -Eq '^[^:]+:[^:]+:4: fatal error' || wail + +echo "checking for correct line number when later input contains" \ + "delimited equation and '-N' is used" >&2 +error=$(printf '.EQ\ndelim $$\n.EN\n$x =\n' \ + | "$eqn" -Tascii 2>&1 > /dev/null) +echo "$error" | grep -Eq '^[^:]+:[^:]+:4: error' || wail + test -z "$fail" # vim:set ai et sw=4 ts=4 tw=72: _______________________________________________ Groff-commit mailing list Groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit