From: Lady Date: Sun, 5 Apr 2026 19:29:49 +0000 (-0400) Subject: Treat missing output files as empty in diffio X-Git-Tag: 0.2.0~2 X-Git-Url: https://git.ladys.computer/HOMEDIR/commitdiff_plain/25ecaf4403856e2d2bbce5cd76d71482e168be18366704fd4b68272ad8f857eb Treat missing output files as empty in diffio 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 --- diff --git a/sh/diffio.sh b/sh/diffio.sh index 799821c..6a4d300 100755 --- a/sh/diffio.sh +++ b/sh/diffio.sh @@ -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 # 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'