groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 35/41: [refer]: Regression-test Savannah #62124.


From: G. Branden Robinson
Subject: [groff] 35/41: [refer]: Regression-test Savannah #62124.
Date: Sat, 5 Mar 2022 16:06:22 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 076374220547a181ca532be0b2997bd904b71c31
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Mar 6 03:43:46 2022 +1100

    [refer]: Regression-test Savannah #62124.
    
    * src/preproc/refer/tests/report-correct-line-numbers.sh: Do it.
    * src/preproc/refer/tests/artifacts/62124.ref: Add new file.
    * src/preproc/refer/refer.am (refer_TESTS): Run test.
      (TESTS): Add test to suite.
      (EXTRA_DIST): Ship test and artifact in distribution archive.
    
    Test fails at this commit.
---
 ChangeLog                                          |   9 ++
 src/preproc/refer/refer.am                         |  11 ++-
 src/preproc/refer/tests/artifacts/62124.ref        |   4 +
 .../refer/tests/report-correct-line-numbers.sh     | 102 +++++++++++++++++++++
 4 files changed, 124 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 40f2bc74..0c00df93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-03-06  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [refer]: Regression-test Savannah #62124.
+
+       * src/preproc/refer/tests/report-correct-line-numbers.sh: Do it.
+       * src/preproc/refer/tests/artifacts/62124.ref: Add new file.
+       * src/preproc/refer/refer.am (refer_TESTS): Run test.
+       (EXTRA_DIST): Ship test artifact in distribution archive.
+
 2022-03-05  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/div.cpp
diff --git a/src/preproc/refer/refer.am b/src/preproc/refer/refer.am
index af16f969..0f14238b 100644
--- a/src/preproc/refer/refer.am
+++ b/src/preproc/refer/refer.am
@@ -7,8 +7,8 @@
 # Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
-# groff is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 # for more details.
 #
@@ -41,6 +41,13 @@ src/preproc/refer/refer-refer.$(OBJEXT): defs.h
 src/preproc/refer/refer-token.$(OBJEXT): defs.h
 src/preproc/refer/refer-label.$(OBJEXT): defs.h
 
+refer_TESTS = \
+  src/preproc/refer/tests/report-correct-line-numbers.sh
+TESTS += $(refer_TESTS)
+EXTRA_DIST += \
+  $(refer_TESTS) \
+  src/preproc/refer/tests/artifacts/62124.ref
+
 
 # Local Variables:
 # fill-column: 72
diff --git a/src/preproc/refer/tests/artifacts/62124.ref 
b/src/preproc/refer/tests/artifacts/62124.ref
new file mode 100644
index 00000000..10938377
--- /dev/null
+++ b/src/preproc/refer/tests/artifacts/62124.ref
@@ -0,0 +1,4 @@
+%A Irritablé, X.
+%T ˆUniversit\*'e de Grenoble. ‰Cours donn\*'es aux Houches.
+%Z ˆMon dieu, Consiel !‰
+%Z NOTE: This file is deliberately not valid UTF-8.  Try Latin-1.
diff --git a/src/preproc/refer/tests/report-correct-line-numbers.sh 
b/src/preproc/refer/tests/report-correct-line-numbers.sh
new file mode 100755
index 00000000..06b02806
--- /dev/null
+++ b/src/preproc/refer/tests/report-correct-line-numbers.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+refer="${abs_top_builddir:-.}/refer"
+
+fail=
+
+wail () {
+    echo FAILED >&2
+    fail=YES
+}
+
+# Regression-test Savannah #62124.  Ensure correct line numbers in
+# diagnostics on bibliography files.
+
+# Locate our test artifacts.
+artifact_dir=
+
+for buildroot in . .. ../..
+do
+    d=$buildroot/src/preproc/refer/tests/artifacts
+    if [ -d "$d" ]
+    then
+        artifact_dir=$d
+        break
+    fi
+done
+
+# If we can't find it, we can't test.
+test -z "$artifact_dir" && exit 77 # skip
+
+input=".
+.R1
+bibliography $artifact_dir/62124.ref
+cattywumpus
+.R2
+.
+.R1
+bibliography $artifact_dir/62124.ref
+cattywumpus
+.R2"
+
+# We want standard error _only_.
+output=$(echo "$input" | "$refer" -e -p "$artifact_dir"/62124.ref \
+    2>&1 >/dev/null)
+
+# We should get every complaint about the bibliography twice because it
+# is dumped twice; the line numbers should not change because they're
+# problems with the bibliography file, not the input file.
+
+# We're pattern-matching diagnostic output here, which is a delicate
+# thing to do.  If a test failure occurs, ensure the diagnostic message
+# text hasn't changed before assuming a deeper logic problem.
+
+echo "checking detection of invalid character on line 1"
+count=$(echo "$output" | grep -c "refer:.*/62124.ref:1:.*code 129")
+test $count -eq 2 || wail
+
+echo "checking detection of first invalid character on line 2"
+count=$(echo "$output" | grep -c "refer:.*/62124.ref:2:.*code 136")
+test $count -eq 2 || wail
+
+echo "checking detection of second invalid character on line 2"
+count=$(echo "$output" | grep -c "refer:.*/62124.ref:2:.*code 137")
+test $count -eq 2 || wail
+
+echo "checking detection of first invalid character on line 3"
+count=$(echo "$output" | grep -c "refer:.*/62124.ref:3:.*code 136")
+test $count -eq 2 || wail
+
+echo "checking detection of second invalid character on line 3"
+count=$(echo "$output" | grep -c "refer:.*/62124.ref:3:.*code 137")
+test $count -eq 2 || wail
+
+# Problems with the input file should also be accurately located.
+
+echo "checking detection of 1st invalid refer(1) command in input file"
+echo "$output" | grep -q "refer:.*:4:.*unknown command" || wail
+
+echo "checking detection of 2nd invalid refer(1) command in input file"
+echo "$output" | grep -q "refer:.*:9:.*unknown command" || wail
+
+test -z "$fail" || exit 1
+
+# vim:set ai et sw=4 ts=4 tw=72:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]