groff-commit
[Top][All Lists]
Advanced

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

[groff] 02/06: [tmac]: Work around macOS od (mis-)behavior.


From: G. Branden Robinson
Subject: [groff] 02/06: [tmac]: Work around macOS od (mis-)behavior.
Date: Mon, 13 Feb 2023 22:04:37 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 4392979e9d616aebd376f5aac69a08277b7820dc
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Feb 13 18:41:42 2023 -0600

    [tmac]: Work around macOS od (mis-)behavior.
    
    * tmac/tests/latin2_works.sh:
    * tmac/tests/latin5_works.sh:
    * tmac/tests/latin9_works.sh: Port to work around macOS's apparently
      POSIX non-conforming 'od' command.  Use single-byte octal output
      format instead of "character", and update test expectations
      accordingly.  Apparently gratuitously, macOS also puts more spaces
      after the octal address field when using this output format.
    
    * HACKING: Document, and elaborate upon, this problem.
    
    Also distinguish identical test failure diagnostics.
    
    ANNOUNCE: Remove caveat about automated test failures on macOS.
---
 ANNOUNCE                   | 13 ++-----------
 ChangeLog                  | 12 ++++++++++++
 HACKING                    | 13 +++++++++++++
 tmac/tests/latin2_works.sh | 30 ++++++++++++++++--------------
 tmac/tests/latin5_works.sh |  6 +++---
 tmac/tests/latin9_works.sh |  6 +++---
 6 files changed, 49 insertions(+), 31 deletions(-)

diff --git a/ANNOUNCE b/ANNOUNCE
index 441007d0b..2e8211f89 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -140,17 +140,8 @@ o A failure in automated testing occurs (if you run "make 
check") for
   gdiffmk if GNU diffutils 3.9 is used.  This is a known problem with
   that release; see <https://debbugs.gnu.org/db/61/61193.html>.
 
-o Some automated test failures (if you run "make check") are expected on
-  macOS.  These are due to differences between GNU and BSD-descended
-  versions of POSIX-standardized utilities.  We hope to resolve these
-  for final release.  The following tests are affected.
-
-       tmac/tests/latin2_works.sh
-       tmac/tests/latin5_works.sh
-       tmac/tests/latin9_works.sh
-
-o Solaris 10 also has known problems with automated tests; see the
-  "PROBLEMS" file in the distribution archive.
+o Solaris 10 has known problems with automated tests; see the "PROBLEMS"
+  file in the distribution archive.
 
 News
 ====
diff --git a/ChangeLog b/ChangeLog
index c8e687cb1..96d1e6bec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2023-02-13  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * tmac/tests/latin2_works.sh:
+       * tmac/tests/latin5_works.sh:
+       * tmac/tests/latin9_works.sh: Port to work around macOS's
+       apparently POSIX non-conforming 'od' command.  Use single-byte
+       octal output format instead of "character", and update test
+       expectations accordingly.  Apparently gratuitously, macOS also
+       puts more spaces after the octal address field when using this
+       output format.
+       * HACKING: Document, and elaborate upon, this problem.
+
 2023-02-13  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [mdoc]: Port a test to work with macOS sed.
diff --git a/HACKING b/HACKING
index 9084c86b5..54ca770e7 100644
--- a/HACKING
+++ b/HACKING
@@ -92,6 +92,19 @@ Here are some portability notes on writing automated tests.
   might need to be weakened to the following on macOS.
     grep -Eqx '0000000 +A +\\b +B +\\b +C       D +\\n *'
 
+* The "od" command on macOS does not respect the environment variable
+  assignment "LC_ALL=C" when processing byte values 127<x<256 decimal
+  and using the "character" output format (option "-t c").  An
+  alternative output must be used, like bytewise octal (option "-t o1").
+  (macOS od may be non-conforming here, despite the claim of its man
+  page.  POSIX Issue 4 od's description says "The type specifier
+  character c specifies that bytes will be interpreted as characters
+  specified by the current setting of the LC_CTYPE locale category. ...
+  Other non-printable characters will be written as one three-digit
+  octal number for each byte in the character." (p. 538)  The language
+  in Issue 7 (2018) appears unchanged.
+    https://pubs.opengroup.org/onlinepubs/9699919799/utilities/od.html )
+
 * macOS sed requires semicolons after commands even if they are followed
   immediately by a closing brace.
 
diff --git a/tmac/tests/latin2_works.sh b/tmac/tests/latin2_works.sh
index 144fcfb41..0b1ac84b8 100755
--- a/tmac/tests/latin2_works.sh
+++ b/tmac/tests/latin2_works.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.
 #
@@ -43,30 +43,32 @@ input=$(\
 )
 
 output=$(printf "%s\n" "$input" | "$groff" -Tlatin1 -mlatin2 \
-    | LC_ALL=C od -t c)
+    | LC_ALL=C od -t o1)
+printf "%s\n" "$output"
 printf "$output" \
-    | grep -Eq '^0000000 241 242 243 246 251 252 253 254 256 257 +' \
+    | grep -Eq '^0000000 +241 242 243 246 251 252 253 254 256 257 +' \
     || wail "in block 0xA0"
 printf "$output" \
-    | grep -Eq '^0000000 .* 261 262 263 266 271$' \
-    || wail "in block 0xB0"
+    | grep -Eq '^0000000 +.* 261 262 263 266 271$' \
+    || wail "in block 0xB0 (address 0..017)"
 printf "$output" \
-    | grep -Eq '^0000020 272 273 274 275 256 277 +' \
-    || wail "in block 0xB0"
+    | grep -Eq '^0000020 +272 273 274 275 256 277 +' \
+    || wail "in block 0xB0 (address 020..037)"
 printf "$output" \
-    | grep -Eq '^0000020 .* 300 303 305 306 310 312 314 317 +$' \
+    | grep -Eq '^0000020 +.* 300 303 305 306 310 312 314 317 040$' \
     || wail "in block 0xC0"
 printf "$output" \
-    | grep -Eq '^0000040 320 321 322 325 330 331 333 336 +' \
+    | grep -Eq '^0000040 +320 321 322 325 330 331 333 336 +' \
     || wail "in block 0xD0"
 printf "$output" \
-    | grep -Eq '^0000040 .* 340 343 345 346 350 352 354$' \
-    || wail "in block 0xE0"
+    | grep -Eq '^0000040 +.* 340 343 345 346 350 352 354$' \
+    || wail "in block 0xE0 (address 040..057)"
 printf "$output" \
-    | grep -Eq '^0000060 357 +' \
-    || wail "in block 0xE0"
+    | grep -Eq '^0000060 +357 +' \
+    || wail "in block 0xE0 (address 060..077)"
 printf "$output" \
-    | grep -Eq '^0000060 .* 360 361 362 365 370 371 373 376 377 +$' \
+    | grep -Eq \
+        '^0000060 +.* 360 361 362 365 370 371 373 376 377( 012)+$' \
     || wail "in block 0xF0"
 
 test -z "$fail"
diff --git a/tmac/tests/latin5_works.sh b/tmac/tests/latin5_works.sh
index eb33a9dbd..62e1c1111 100755
--- a/tmac/tests/latin5_works.sh
+++ b/tmac/tests/latin5_works.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.
 #
@@ -22,9 +22,9 @@ groff="${abs_top_builddir:-.}/test-groff"
 
 input=$(printf '\\[G ab]\\[g ab]\\[u0130]\\[.i]\\[S ac]\\[s ac]')
 output=$(printf "%s\n" "$input" | "$groff" -Tlatin1 -mlatin5 \
-    | LC_ALL=C od -t c)
+    | LC_ALL=C od -t o1)
 printf "%s\n" "$output"
 printf "$output" \
-    | grep -Eq '^0000000 320 360 335 375 336 376 +'
+    | grep -Eq '^0000000 +320 360 335 375 336 376 +'
 
 # vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/latin9_works.sh b/tmac/tests/latin9_works.sh
index 828c31367..ca5e23b28 100755
--- a/tmac/tests/latin9_works.sh
+++ b/tmac/tests/latin9_works.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.
 #
@@ -22,9 +22,9 @@ groff="${abs_top_builddir:-.}/test-groff"
 
 input=$(printf '\\[Eu]\\[vS]\\[vs]\\[vZ]\\[vz]\\[OE]\\[oe]\\[:Y]\n')
 output=$(printf "%s\n" "$input" | "$groff" -Tlatin1 -mlatin9 \
-    | LC_ALL=C od -t c)
+    | LC_ALL=C od -t o1)
 printf "%s\n" "$output"
 printf "$output" \
-    | grep -Eq '^0000000 244 246 250 264 270 274 275 276 +'
+    | grep -Eq '^0000000 +244 246 250 264 270 274 275 276 +'
 
 # vim:set ai et sw=4 ts=4 tw=72:



reply via email to

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