[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 02/03: Repair nroff test case.
From: |
G. Branden Robinson |
Subject: |
[groff] 02/03: Repair nroff test case. |
Date: |
Mon, 13 Apr 2020 08:59:52 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 2a9e09c0331c5ecca5fe0c3ee7f12dc93c547553
Author: G. Branden Robinson <address@hidden>
AuthorDate: Mon Apr 13 22:30:05 2020 +1000
Repair nroff test case.
* src/roff/nroff/nroff.sh: Let test cases tell us to use test-groff as
groff with an environment variable.
* src/roff/nroff/tests/verbose_option_works.sh.in: Refactor. Stop
messing with @GROFF_BIN_PATH_SETUP@; instead, let test-groff handle
that for us. Locate it and export the variable GROFF_TEST_GROFF so
nroff can find it. Because we manipulate $PATH to run the tests, the
$PATH of an installed groff system will _always_ differ from that used
by a build tree; ignore it in the test cases. Dispose of bashisms and
set shebang to /bin/sh.
I have more confidence in the test script now. Does anyone else?
$ cat build/src/roff/nroff/tests/verbose_option_works.sh.log
nroff: 1.22.4.169-e44b5
groff: 1.22.4.169-e44b5
testing 'nroff -V'
test-groff -Tascii -mtty-char
testing 'nroff -V 1'
test-groff -Tascii -mtty-char 1
testing 'nroff -V "1a 1b"'
test-groff -Tascii -mtty-char "1a 1b"
testing 'nroff -V "1a 1b" 2'
test-groff -Tascii -mtty-char "1a 1b" 2
testing 'nroff -V 1a\"1b 2'
test-groff -Tascii -mtty-char 1a"1b 2
PASS src/roff/nroff/tests/verbose_option_works.sh (exit status: 0)
---
ChangeLog | 11 +++++--
src/roff/nroff/nroff.sh | 7 ++--
src/roff/nroff/tests/verbose_option_works.sh.in | 44 +++++++++++++------------
3 files changed, 37 insertions(+), 25 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 60f8da1..0304051 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,12 +5,19 @@
results. Make it easier to see a discrepancy.
* src/roff/nroff/nroff.sh: Call groff with -v or --version when
- we are called that way.
+ we are called that way. Let test cases tell us to use
+ test-groff as groff with an environment variable.
* src/roff/nroff/tests/verbose_option_works.sh.in: Check the
nroff version being tested against the groff version being
wrapped. This exposes a bug; the system groff rather than the
- build tree groff was being invoked.
+ build tree groff was being invoked. Refactor. Stop messing
+ with @GROFF_BIN_PATH_SETUP@; instead, let test-groff handle that
+ for us. Locate it and export the variable GROFF_TEST_GROFF so
+ nroff can find it. Because we manipulate $PATH to run the
+ tests, the $PATH of an installed groff system will _always_
+ differ from that used by a build tree, ignore it in the test
+ cases. Dispose of bashisms and set shebang to /bin/sh.
2020-04-13 G. Branden Robinson <address@hidden>
diff --git a/src/roff/nroff/nroff.sh b/src/roff/nroff/nroff.sh
index ccddddb..86deaf4 100644
--- a/src/roff/nroff/nroff.sh
+++ b/src/roff/nroff/nroff.sh
@@ -138,6 +138,9 @@ opts="-mtty-char$opts"
@GROFF_BIN_PATH_SETUP@
export GROFF_BIN_PATH
+# Let the test cases redirect us.
+groff=${GROFF_TEST_GROFF:-groff}
+
# Note 1: It would be nice to apply the DRY ("Don't Repeat Yourself")
# principle here and store the entire command string to be executed into
# a variable, and then either display it or execute it. For example:
@@ -164,9 +167,9 @@ export GROFF_BIN_PATH
# want 'nroff' to become 'groff ... ""' if $# equals zero.
if [ -n "$dry_run" ]
then
- echo PATH="$GROFF_RUNTIME$PATH" groff $T $opts ${1+"$@"}
+ echo PATH="$GROFF_RUNTIME$PATH" $groff $T $opts ${1+"$@"}
else
- PATH="$GROFF_RUNTIME$PATH" groff $T $opts ${1+"$@"}
+ PATH="$GROFF_RUNTIME$PATH" $groff $T $opts ${1+"$@"}
fi
# eof
diff --git a/src/roff/nroff/tests/verbose_option_works.sh.in
b/src/roff/nroff/tests/verbose_option_works.sh.in
index 4f9086c..3d5237e 100755
--- a/src/roff/nroff/tests/verbose_option_works.sh.in
+++ b/src/roff/nroff/tests/verbose_option_works.sh.in
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
#
# Copyright (C) 2020 Free Software Foundation, Inc.
#
@@ -20,41 +20,43 @@
# Ensure a predictable character encoding.
export LC_ALL=C
-# Ensure a predictable command search path.
-@GROFF_BIN_PATH_SETUP@
set -e
-nroff="${abs_top_builddir:-.}/nroff"
+export GROFF_TEST_GROFF=${abs_top_builddir:-.}/test-groff
-nroff_ver=$("$nroff" -v | awk 'NR == 1 {print $NF}')
-groff_ver=$("$nroff" -v | awk 'NR == 2 {print $NF}')
+# The $PATH used by an installed nroff at runtime does not match what
+# we're trying to test, which should be using the groff and runtime
+# support from the build tree. Therefore the $PATH that nroff -V
+# reports will _always_ be wrong for test purposes. Skip over it.
+#
+# If the build environment has a directory in the $PATH matching
+# "test-groff " (with the trailing space), failure may result if sed
+# doesn't match greedily. POSIX says it should.
+sedexpr='s/^PATH=.*test-groff /test-groff /'
+PATH=${abs_top_builddir:-.}:$PATH
+
+nroff_ver=$(nroff -v | awk 'NR == 1 {print $NF}')
+groff_ver=$(nroff -v | awk 'NR == 2 {print $NF}')
echo nroff: $nroff_ver >&2
echo groff: $groff_ver >&2
test "$nroff_ver" = "$groff_ver"
echo "testing 'nroff -V'" >&2
-expected="PATH=$GROFF_RUNTIME$PATH groff -Tascii -mtty-char"
-actual=$("$nroff" -V)
-diff -u <(echo "$expected") <(echo "$actual")
+nroff -V | sed "$sedexpr" | grep -x "test-groff -Tascii -mtty-char"
echo "testing 'nroff -V 1'" >&2
-expected="PATH=$GROFF_RUNTIME$PATH groff -Tascii -mtty-char 1"
-actual=$("$nroff" -V 1)
-diff -u <(echo "$expected") <(echo "$actual")
+nroff -V 1 | sed "$sedexpr" | grep -x "test-groff -Tascii -mtty-char 1"
echo "testing 'nroff -V \"1a 1b\"'" >&2
-expected="PATH=$GROFF_RUNTIME$PATH groff -Tascii -mtty-char \"1a 1b\""
-actual=$("$nroff" -V \"1a 1b\")
-diff -u <(echo "$expected") <(echo "$actual")
+nroff -V \"1a 1b\" | sed "$sedexpr" \
+ | grep -x "test-groff -Tascii -mtty-char \"1a 1b\""
echo "testing 'nroff -V \"1a 1b\" 2'" >&2
-expected="PATH=$GROFF_RUNTIME$PATH groff -Tascii -mtty-char \"1a 1b\" 2"
-actual=$("$nroff" -V \"1a 1b\" 2)
-diff -u <(echo "$expected") <(echo "$actual")
+nroff -V \"1a 1b\" 2 | sed "$sedexpr" \
+ | grep -x "test-groff -Tascii -mtty-char \"1a 1b\" 2"
echo "testing 'nroff -V 1a\\\"1b 2'" >&2
-expected="PATH=$GROFF_RUNTIME$PATH groff -Tascii -mtty-char 1a\"1b 2"
-actual=$("$nroff" -V 1a\"1b 2)
-diff -u <(echo "$expected") <(echo "$actual")
+nroff -V 1a\"1b 2 | sed "$sedexpr" \
+ | grep -x "test-groff -Tascii -mtty-char 1a\"1b 2"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 02/03: Repair nroff test case.,
G. Branden Robinson <=