]> Lady’s Gitweb - HOMEDIR/commitdiff
Treat missing output files as empty in diffio
authorLady <redacted>
Sun, 5 Apr 2026 19:29:49 +0000 (15:29 -0400)
committerLady <redacted>
Sun, 5 Apr 2026 20:05:58 +0000 (16:05 -0400)
When writing new tests, it is handy to be able to just run `diffio´ to
  see what will be outputted prior to saving it with
  `do_OVERWRITE=1 testio´.
The previous behaviour of comparing exit status for missing output
  files is simply not that useful here, since `testio´ is exactly as
  usable for such things.

Message-type: text/lesml

sh/diffio.sh

index 799821cfad417e48dfeed66d59081de9d9e4436aef7a50ecad9063f77d4d3dc6..6a4d300fd00827df2a1938ef9da73d5fa83c7c5363ef32fe6c221b9cff83c3db 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env sh
-# @(#)🏠📂 HOMEDIR       sh/diffio.sh    2026-03-23T02:16:54Z
+# @(#)🏠📂 HOMEDIR       sh/diffio.sh    2026-04-05T19:29:49Z
 # SPDX-FileCopyrightText: 2026 Lady <https://www.ladys.computer/about/#lady>
 # SPDX-License-Identifier: MPL-2.0
 
@@ -92,24 +92,15 @@ then :
   exit 9
 fi
 
-## If there is no output file, then the transform is expected to fail.
-## Otherwise, the transformed output is diffed with the result.
+## If there is no output file, it is treated as empty.
 
-if ! "${cmd_TEST}" -f "${inputfile}"
+if ! "${cmd_TEST}" -f "${outputfile}"
 then :
-  if "${cmd_TRANSFORM}" <"${infile}" >/dev/null 2>/dev/null
-  then :
-    "${cmd_PRINTF}" '%s\n' \
-      'diffio: Expected transform failure, but it succeeded.' \
-      >&2
-    exit 10
-  else :
-    "${cmd_PRINTF}" '%s\n' \
-      'diffio: Transform did not succeed, as expected.' \
-      >&2
-  fi
-else :
-  "${cmd_TRANSFORM}" <"${inputfile}" 2>/dev/null |
-  "${cmd_DIFF}" -U 1 - "${outputfile}" |
-  "${cmd_SED}" '1,2d'
+  outputfile=/dev/null
 fi
+
+## The transformed output is diffed with the result.
+
+"${cmd_TRANSFORM}" <"${inputfile}" |
+"${cmd_DIFF}" -U 1 "${outputfile}" - |
+"${cmd_SED}" '1,2d'
This page took 0.37072 seconds and 4 git commands to generate.