[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 03/05: [man]: Port a test to work with macOS sed.
From: |
G. Branden Robinson |
Subject: |
[groff] 03/05: [man]: Port a test to work with macOS sed. |
Date: |
Mon, 13 Feb 2023 14:15:29 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit a47e8985205d6c564b66e0d780b5893dabc6c84d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Feb 13 11:39:11 2023 -0600
[man]: Port a test to work with macOS sed.
* tmac/tests/an_TS-adds-no-vertical-space.sh: Put semicolons between
commands and closing braces in sed script. Separate command stream
into multiple '-e' expressions, breaking them after branch and label
commands. Resolves test failure observed on macOS.
* HACKING: Document the above problems.
* ANNOUNCE: Drop notice of failing test case, now resolved.
---
ANNOUNCE | 1 -
ChangeLog | 11 +++++++++++
HACKING | 20 ++++++++++++++++++++
tmac/tests/an_TS-adds-no-vertical-space.sh | 11 +++++++++--
4 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/ANNOUNCE b/ANNOUNCE
index 5cb249733..704041334 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -145,7 +145,6 @@ o Some automated test failures (if you run "make check")
are expected on
versions of POSIX-standardized utilities. We hope to resolve these
for final release. The following tests are affected.
- tmac/tests/an_TS-adds-no-vertical-space.sh
tmac/tests/an_use-input-traps-correctly.sh
tmac/tests/doc_heading-font-remapping-works.sh
tmac/tests/latin2_works.sh
diff --git a/ChangeLog b/ChangeLog
index f250eddd8..eba8cc1e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-02-13 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [man]: Port a test to work with macOS sed.
+
+ * tmac/tests/an_TS-adds-no-vertical-space.sh: Put semicolons
+ between commands and closing braces in sed script. Separate
+ command stream into multiple '-e' expressions, breaking them
+ after branch and label commands. Resolves test failure observed
+ on macOS.
+ * HACKING: Document the above problems.
+
2023-02-13 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/groff/tests/\
diff --git a/HACKING b/HACKING
index 58893fbc9..9e1d8c07d 100644
--- a/HACKING
+++ b/HACKING
@@ -85,3 +85,23 @@ Here are some portability notes on writing automated tests.
grep -Eqx '0000000 +A +\\b +B +\\b +C D +\\n'
might need to be weakened to the following on macOS.
grep -Eqx '0000000 +A +\\b +B +\\b +C D +\\n *'
+
+* macOS sed requires semicolons after commands even if they are followed
+ immediately by a closing brace.
+
+ Rewrite
+ sed -n '/Foo\./{n;s/^$/FAILURE/;p}'
+ as follows.
+ sed -n '/Foo\./{n;s/^$/FAILURE/;p;}'
+
+* POSIX doesn't say that sed has to accept semicolons as command
+ separators after label (':') and branch ('t') commands, so it doesn't.
+ GNU sed does.
+
+ So rewrite tidy, compact sed scripts like this:
+ sed -n '/Foo\./{n;s/^$/FAILURE/;tA;s/.*/SUCCESS/;:A;p}'
+ as this more cumbersome alternative.
+ sed -n \
+ -e '/Foo\./{n;s/^$/FAILURE/;tA;' \
+ -e 's/.*/SUCCESS/;:A;' \
+ -e 'p;}')
diff --git a/tmac/tests/an_TS-adds-no-vertical-space.sh
b/tmac/tests/an_TS-adds-no-vertical-space.sh
index f35377e56..d6e790ac7 100755
--- a/tmac/tests/an_TS-adds-no-vertical-space.sh
+++ b/tmac/tests/an_TS-adds-no-vertical-space.sh
@@ -33,8 +33,15 @@ bar
# Bash strips out an empty line, but that's what we're looking for.
output=$(printf "%s" "$input" | "$groff" -t -man -Tascii \
- | sed -n '/Foo\./{n;s/^$/FAILURE/;tA;s/.*/SUCCESS/;:A;p}')
-
+ | sed -n \
+ -e '/Foo\./{n;s/^$/FAILURE/;tA;' \
+ -e 's/.*/SUCCESS/;:A;' \
+ -e 'p;}')
+ # Here's a tidier version accepted by GNU sed but rejected
+ # contemptuously by macOS sed. (POSIX doesn't say you _have_ to
+ # accept semicolons after label ':' and branch 't' commands, so it
+ # doesn't.)
+ # sed -n '/Foo\./{n;s/^$/FAILURE/;tA;s/.*/SUCCESS/;:A;p}'
test "$output" = SUCCESS
# vim:set ai et sw=4 ts=4 tw=72:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 03/05: [man]: Port a test to work with macOS sed.,
G. Branden Robinson <=