lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master d7ab80c6 04/27: Clean up beforehand, not afte


From: Greg Chicares
Subject: [lmi-commits] [lmi] master d7ab80c6 04/27: Clean up beforehand, not afterward
Date: Mon, 25 Apr 2022 12:56:13 -0400 (EDT)

branch: master
commit d7ab80c647e93d5b798e8d501c93a636ffcf3dd5
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Clean up beforehand, not afterward
    
    Formerly, files created as testing artifacts in a temporary directory
    were obliterated at the end of the run. This made it less easy to
    discern the reason for any failure. And anything left over from an
    earlier run became a demonstration of Murphy's Law. And the cleanup
    command was in effect
      rm "$throwaway_dir"/*
    which could have a surprising effect under various circumstances.
    
    Now, the temporary directory is obliterated before its first use, by
      rm -rf "$throwaway_dir"
    which is less unsafe to copy and paste to the command line--so no old
    artifacts can cause trouble, and the files remain for analysis after
    the run completes (or fails to complete). This does waste two megabytes
    of storage, but anyone who cares can clean up manually.
---
 nychthemeral_test.sh | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/nychthemeral_test.sh b/nychthemeral_test.sh
index af3e40a5..919984c1 100755
--- a/nychthemeral_test.sh
+++ b/nychthemeral_test.sh
@@ -362,8 +362,11 @@ java -jar /opt/lmi/third_party/rng/jing.jar -c xrc.rnc 
./*.xrc 2>&1 \
   | tee "$log_dir"/xrc
 
 # Run the following tests in a throwaway directory so that the files
-# they create can be cleaned up easily.
+# they create can be cleaned up easily. To guard against interference
+# from any files left over from previous runs, destroy that directory
+# first, then recreate it.
 throwaway_dir="$log_dir"/tmp
+rm -rf "$throwaway_dir"
 mkdir --parents "$throwaway_dir"
 cd "$throwaway_dir"
 
@@ -411,11 +414,6 @@ printf '%b' "\
 srcdir=. datadir=. /opt/lmi/src/lmi/mst_to_xst.sh
 cmp eraseme.xst eraseme.touchstone
 
-# Clean up stray output. (The zsh '(N)' glob qualifier turns on
-# null_glob for a single expansion.)
-# shellcheck disable=SC2039,SC3002
-for z in "$throwaway_dir"/*(N); do rm "$z"; done
-
 printf '\n# test PETE rebuild\n\n'
 
 # Automatically-generated PETE files are in the repository.



reply via email to

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