[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 16/80: [tmac]: Fix Savannah #66479 (1a/2).
From: |
G. Branden Robinson |
Subject: |
[groff] 16/80: [tmac]: Fix Savannah #66479 (1a/2). |
Date: |
Sat, 30 Nov 2024 04:02:14 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 9bf4595fcccea65f6c0b3fa02be7abbe87a09e6f
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Nov 27 03:05:49 2024 -0600
[tmac]: Fix Savannah #66479 (1a/2).
* HACKING: Document macOS wc(1) irritation.
* tmac/tests/an_vertical-margins-are-correct.sh:
* tmac/tests/doc-old_vertical-margins-are-correct.sh:
* tmac/tests/doc_vertical-margins-are-correct.sh: Work around macOS
wc(1)'s right-alignment of its integer output field.
---
ChangeLog | 11 +++++++++++
HACKING | 13 +++++++++++++
tmac/tests/an_vertical-margins-are-correct.sh | 5 ++++-
tmac/tests/doc-old_vertical-margins-are-correct.sh | 5 ++++-
tmac/tests/doc_vertical-margins-are-correct.sh | 5 ++++-
5 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 19b3be599..b6ddb35b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-11-27 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ Fix Savannah #66479 (1a/2).
+
+ * HACKING: Document macOS wc(1) irritation.
+
+ * tmac/tests/an_vertical-margins-are-correct.sh:
+ * tmac/tests/doc-old_vertical-margins-are-correct.sh:
+ * tmac/tests/doc_vertical-margins-are-correct.sh: Work around
+ macOS wc(1)'s right-alignment of its integer output field.
+
2024-11-25 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/input.cpp (token::is_usable_as_delimiter): If
diff --git a/HACKING b/HACKING
index 2702eed18..3c2c8adf9 100644
--- a/HACKING
+++ b/HACKING
@@ -153,6 +153,19 @@ Here are some portability notes on writing automated tests.
# emulate "seq 53"
n=1; while [ $n -le 53 ]; do echo $n; n=$(( n + 1 )); done; unset n
+* The "wc" command on macOS can prefix the numeric count in its output
+ with spaces, which can be undesirable when storing that output to
+ variable that is later expanded within double quotes in the shell.
+
+ Here is a workaround.
+
+ res=$(whatever | wc -l)
+ res=$(expr "$res" + 0) || exit 99
+
+ "expr"'s output is more rigidly specified, and if for some reason we
+ get unacceptable non-integer garbage from "wc", we exit the test
+ script with the code reserved for "hard errors".
+
* The "od" command on macOS can put extra space characters (i.e., spaces
that don't correspond to the input) at the ends of lines when using
the "od -t c" format; GNU od does not.
diff --git a/tmac/tests/an_vertical-margins-are-correct.sh
b/tmac/tests/an_vertical-margins-are-correct.sh
index d12d330b4..f8c211cdf 100755
--- a/tmac/tests/an_vertical-margins-are-correct.sh
+++ b/tmac/tests/an_vertical-margins-are-correct.sh
@@ -89,7 +89,10 @@ output=$(printf "%s" "$input1" "$input2" \
echo "$output"
echo "checking page length" >&2
-test "$(echo "$output" | wc -l)" = 66 || wail
+res=$(echo "$output" | wc -l)
+# macOS `wc` prefixes the line count with spaces. Get rid of them.
+res=$(expr "$res" + 0) || exit 99
+test "$res" = 66 || wail
echo "checking placement of page header" >&2
echo "$output" \
diff --git a/tmac/tests/doc-old_vertical-margins-are-correct.sh
b/tmac/tests/doc-old_vertical-margins-are-correct.sh
index 053157617..e7ce92ed3 100755
--- a/tmac/tests/doc-old_vertical-margins-are-correct.sh
+++ b/tmac/tests/doc-old_vertical-margins-are-correct.sh
@@ -91,7 +91,10 @@ output=$(printf "%s" "$input1" "$input2" \
echo "$output"
echo "checking page length" >&2
-test "$(echo "$output" | wc -l)" = 66 || wail
+res=$(echo "$output" | wc -l)
+# macOS `wc` prefixes the line count with spaces. Get rid of them.
+res=$(expr "$res" + 0) || exit 99
+test "$res" = 66 || wail
echo "checking placement of page header" >&2
echo "$output" \
diff --git a/tmac/tests/doc_vertical-margins-are-correct.sh
b/tmac/tests/doc_vertical-margins-are-correct.sh
index addcfd5fb..90f922393 100755
--- a/tmac/tests/doc_vertical-margins-are-correct.sh
+++ b/tmac/tests/doc_vertical-margins-are-correct.sh
@@ -91,7 +91,10 @@ output=$(printf "%s" "$input1" "$input2" \
echo "$output"
echo "checking page length" >&2
-test "$(echo "$output" | wc -l)" = 66 || wail
+res=$(echo "$output" | wc -l)
+# macOS `wc` prefixes the line count with spaces. Get rid of them.
+res=$(expr "$res" + 0) || exit 99
+test "$res" = 66 || wail
echo "checking placement of page header" >&2
echo "$output" \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 16/80: [tmac]: Fix Savannah #66479 (1a/2).,
G. Branden Robinson <=