bug-texinfo
[Top][All Lists]
Advanced

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

Re: .t2d directory remaining


From: Akim Demaille
Subject: Re: .t2d directory remaining
Date: Wed, 18 Jan 2006 12:56:46 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

Thanks for the report, I could reproduce and solve this issue.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        Sometimes the temporary directory remains.
        Reported by Wybo Dekker.
        * util/defs.in (assert_files): New.
        * util/texi2dvi.test: Use it.
        Extend to check the local builds.
        * util/texi2dvi (aux_file_p, index_file_p, xref_file_p): Check
        that the file exists.
        (generated_files_get): Simplify according to these changes.
        (remove, cleanup): New.
        Use the latter in the cleaning trap.
        (mostly_clean): Use them.

Index: util/defs.in
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/defs.in,v
retrieving revision 1.1
diff -u -u -r1.1 defs.in
--- util/defs.in 30 Sep 2005 17:21:49 -0000 1.1
+++ util/defs.in 18 Jan 2006 11:55:56 -0000
@@ -1,7 +1,7 @@
 # -*- shell-script -*-
 # @configure_input@
 #
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 
2006
 # Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
@@ -200,6 +200,17 @@
   done | sort`
 }
 
+# assert_files (EXPECTED-FILES)
+# -----------------------------
+# Only those files are valid in the current directory.
+assert_files ()
+{
+  if test -n "$VERBOSE"; then
+    ls
+  fi
+  test "`list_files`" = "$*" || exit 1
+}
+
 # Turn on shell traces when VERBOSE is set.
 if test -n "$VERBOSE"; then
   set -x
Index: util/texi2dvi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v
retrieving revision 1.72
diff -u -u -r1.72 texi2dvi
--- util/texi2dvi 17 Jan 2006 11:29:27 -0000 1.72
+++ util/texi2dvi 18 Jan 2006 11:55:56 -0000
@@ -471,6 +471,7 @@
 # Return with success with FILE is an aux file.
 aux_file_p ()
 {
+  test -f "$1" || return 1
   case $1 in
     *.aux) return 0;;
     *)     return 1;;
@@ -482,6 +483,7 @@
 # Return with success with FILE is an index file.
 index_file_p ()
 {
+  test -f "$1" || return 1
   case `sed '1q' $1` in
     "\\entry{"*|"\\indexentry{"*) return 0;;
     *) return 1;;
@@ -493,6 +495,7 @@
 # Return with success if FILE is an xref file (indexes, tables and lists).
 xref_file_p ()
 {
+  test -f "$1" || return 1
   # If the file is not suitable to be an index or xref file, don't
   # process it.  It's suitable if the first character is a
   # backslash or right quote or at, as long as the first line isn't
@@ -524,8 +527,6 @@
   ) |
   # Depending on these files, infer outputs from other tools.
   while read file; do
-    test -f $file ||
-      continue
     echo $file
     case $language in
       (texinfo)
@@ -1094,9 +1095,17 @@
 }
 
 
-# mostly_clean ()
-# ---------------
-# Remove auxiliary files and directories.
+# remove FILES
+# ------------
+remove ()
+{
+  verbose "Removing" "$@"
+  rm -rf "$@"
+}
+
+# mostly_clean
+# ------------
+# Remove auxiliary files and directories.  Changes the current directory.
 mostly_clean ()
 {
   cd_orig
@@ -1105,8 +1114,22 @@
     local log=$work_build/$in_noext.log
     to_remove=$to_remove" $log "$(generated_files_get "$work_build/$in_noext")
   }
-  verbose "Removing" $to_remove
-  rm -rf $to_remove
+  remove $to_remove
+}
+
+
+# cleanup ()
+# ----------
+# Remove what should be removed according to options.
+# Called at the end of each compilation cycle, and at the end of
+# the script.  Changes the current directory.
+cleanup ()
+{
+  case $build_mode in
+    local) cd_orig; remove "$t2ddir";;
+    clean) mostly_clean;;
+    tidy)  ;;
+  esac
 }
 
 
@@ -1379,9 +1402,7 @@
              sed 's,/,!,g'`
   esac
   # Remove it at exit if clean mode.
-  if $clean; then
-    trap "mostly_clean" 0 1 2 15
-  fi
+  trap "cleanup" 0 1 2 15
 
   ensure_dir "$build_dir" "$t2ddir"
 
@@ -1411,10 +1432,7 @@
     compile)
       # Compile the document.
       compile
-      # Remove temporary files.
-      if $clean; then
-       mostly_clean
-      fi
+      cleanup
       ;;
 
     mostly-clean)
Index: util/texi2dvi.test
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi.test,v
retrieving revision 1.8
diff -u -u -r1.8 texi2dvi.test
--- util/texi2dvi.test 2 Jan 2006 19:56:26 -0000 1.8
+++ util/texi2dvi.test 18 Jan 2006 11:55:56 -0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2003, 2005, 2006  Free Software Foundation, Inc.
 #
 # This file is part of GNU Texinfo.
 #
@@ -26,32 +26,43 @@
 @bye
 EOF
 
+# Testing the local build mode.
+TEXI2DVI_pass --batch input.texi
+# There should only be the DVI and the TEXI file.
+assert_files input.aux input.cp input.dvi input.fn input.ky input.log input.pg 
input.texi input.tp input.vr
+rm input.aux input.cp input.dvi input.fn input.ky input.log input.pg input.tp 
input.vr
+
+TEXI2DVI_pass --batch input.texi -o output.dvi
+# There should only be the DVI and the TEXI file.
+assert_files input.aux input.cp input.dvi input.fn input.ky input.log input.pg 
input.texi input.tp input.vr output.dvi
+rm input.aux input.cp input.dvi input.fn input.ky input.log input.pg input.tp 
input.vr output.dvi
 
+# Testing the clean build mode.
 for mode in --clean --build=clean
 do
   TEXI2DVI_pass $mode --batch input.texi
   # There should only be the DVI and the TEXI file.
-  test "`list_files`" = "input.dvi input.texi"
+  assert_files input.dvi input.texi
   rm input.dvi
 
   TEXI2DVI_pass $mode --batch input.texi -o output.dvi
   # There should only be the DVI and the TEXI file.
-  test "`list_files`" = "input.texi output.dvi"
+  assert_files input.texi output.dvi
   rm output.dvi
 done
 
 
-
+# Testing the tidy build mode.
 TEXI2DVI_pass --build=tidy --batch input.texi -o output.dvi
 # There should only be the DVI and the TEXI file.
-test "`list_files`" = "input.texi output.dvi output.t2d"
+assert_files input.texi output.dvi output.t2d
 TEXI2DVI_pass --build=tidy --batch input.texi -o output.dvi --mostly-clean
-test "`list_files`" = "input.texi output.dvi"
+assert_files input.texi output.dvi
 rm output.dvi
 
 cp input.texi input2.texi
 
 TEXI2DVI_pass --clean --batch input.texi input2.texi
 # There should only be the DVI and the TEXI file.
-test "`list_files`" = "input2.dvi input2.texi input.dvi input.texi"
+assert_files input2.dvi input2.texi input.dvi input.texi
 rm input.dvi input2.dvi





reply via email to

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