]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Add undocumented _AS_CLEAN_DIR.
authorEric Blake <ebb9@byu.net>
Fri, 10 Apr 2009 12:26:33 +0000 (06:26 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 10 Apr 2009 12:26:33 +0000 (06:26 -0600)
* lib/m4sugar/m4sh.m4 (_AS_CLEAN_DIR): New macro; fixes m4 quoting
in previous patch.
* lib/autotest/general.m4 (AT_INIT) <at_fn_group_prepare>: Use new
macro.
* tests/m4sh.at (_AS@&t@_CLEAN_DIR): New test.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/autotest/general.m4
lib/m4sugar/m4sh.m4
tests/m4sh.at

index be9ab986745f70f3deb9ed1167699da694168221..7ee10f36d0993b79d44014e11f2faf18049b1522 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-04-10  Eric Blake  <ebb9@byu.net>
+
+       Add undocumented _AS_CLEAN_DIR.
+       * lib/m4sugar/m4sh.m4 (_AS_CLEAN_DIR): New macro; fixes m4 quoting
+       in previous patch.
+       * lib/autotest/general.m4 (AT_INIT) <at_fn_group_prepare>: Use new
+       macro.
+       * tests/m4sh.at (_AS@&t@_CLEAN_DIR): New test.
+       Reported by Ralf Wildenhues.
+
 2009-04-09  Eric Blake  <ebb9@byu.net>
 
        Avoid problems caused by deleting in-use directory.
index 9c6538e4e554fdbfb739f2d581f50438ee13967c..906e481b14ba2684254e1f575f513cbb00930970 100644 (file)
@@ -1099,11 +1099,8 @@ at_fn_group_prepare ()
   # under the shell's notion of the current directory.
   at_group_dir=$at_suite_dir/$at_group_normalized
   at_group_log=$at_group_dir/$as_me.log
-  if test -d "$at_group_dir"; then
-    find "$at_group_dir" -type d ! -perm -700 -exec chmod u+rwx \{\} \;
-    rm -fr "$at_group_dir"/* "$at_group_dir"/.[!.] "$at_group_dir"/.??* ||
+  _AS_CLEAN_DIR("$at_group_dir") ||
     AS_WARN([test directory for $at_group_normalized could not be cleaned.])
-  fi
   # Be tolerant if the above `rm' was not able to remove the directory.
   AS_MKDIR_P(["$at_group_dir"])
 
index 88881b1f6fe8b8d4dc0f5143fb84ce8d61a73eff..2b32802e96033cb4346601f266253ea1ad3626d2 100644 (file)
@@ -1409,6 +1409,17 @@ m4_define([_AS_BOX_INDIR],
 _ASBOX])
 
 
+# _AS_CLEAN_DIR(DIR)
+# ------------------
+# Remove all contents from within DIR, including any unwritable
+# subdirectories, but leave DIR itself untouched.
+m4_define([_AS_CLEAN_DIR],
+[if test -d $1; then
+  find $1 -type d ! -perm -700 -exec chmod u+rwx {} \;
+  rm -fr $1/* $1/.[[!.]] $1/.??*
+fi])
+
+
 # AS_FUNCTION_DESCRIBE(NAME, [ARGS], DESCRIPTION, [WRAP-COLUMN = 79])
 # -------------------------------------------------------------------
 # Output a shell comment describing NAME and its arguments ARGS, then
index def63aa9ea0bdd967a27aa267931ad18b025ae46..d747bfe95a6532059b02ca4d0654ec71aa4adcaf 100644 (file)
@@ -1371,3 +1371,32 @@ AT_CHECK([cat log], [0],
 ]])
 
 AT_CLEANUP
+
+
+## --------------- ##
+## _AS_CLEAN_DIR.  ##
+## --------------- ##
+
+AT_SETUP([_AS@&t@_CLEAN_DIR])
+
+dnl ensure that we can erase all files in a directory.  Note that
+dnl _AS_CLEAN_DIR needs three globs to catch all these files.
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+# Unwritable subdirectories are common during 'make distcheck'.
+mkdir sub sub/unwritable || AS_ERROR([failed to mkdir])
+touch sub/unwritable/file || AS_ERROR([failed to touch])
+chmod a-wx sub/unwritable || AS_ERROR([failed to chmod])
+# Cygwin 1.5 can't touch 'sub/...', so make that file optional.
+touch sub/a sub/aa sub/aaa sub/.a sub/..a sub/.aa \
+  || AS_ERROR([failed to touch])
+touch sub/... 2>/dev/null
+_AS_CLEAN_DIR([sub]) || AS_ERROR([failed to clean])
+# rmdir instead of 'rm -fr' here proves that we emptied sub.
+rmdir sub || AS_ERROR([failed to rmdir])
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([./script])
+
+AT_CLEANUP