autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH 3/3] Be nice with file systems that don't handle unusual characte


From: Benoit Sigoure
Subject: [PATCH 3/3] Be nice with file systems that don't handle unusual characters.
Date: Tue, 18 Dec 2007 13:54:08 +0100

        * tests/atlocal.in (func_sanitize_file_name)
        (func_sanitize_dir_name): New shell functions.
        * tests/tools.at (autom4te and whitespace in file names)
        (autotools and whitespace in file names): Use them.
        * tests/torture.at (AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS):
        Cover more potentially problemtic file names.  Use the new
        functions.

Signed-off-by: Benoit Sigoure <address@hidden>
---
This patch does not solve the problems on Windows, it's just my attempt to
avoid testing file names with problematic characters.  I'm sending this in
case someone wants to pursue this, otherwise there are plenty different ways
of tackling this issue (such as not using the problematic characters at all
in the first place).

I have too many spurious failures on Windows, maybe because of my setup but
I fail to see what's wrong.  Unfortunately I won't have time to continue
this work.

The whole mess in torture.at is better viewed with git diff -w (to ignore
whitespace changes)

| --- a/tests/torture.at
| +++ b/tests/torture.at
| @@ -262,12 +262,19 @@ AT_CHECK_CONFIG_CREATION_NOWRITE(link)
|  AT_CHECK([grep ac_write_fail config.status], [1])
|  
|  # Check that --file and --header accept funny file names
| -file='file with  funny \ '\'' \'\'' $ & #!*? name'
| +
| +x=
| +export x
| +for file in \
| +  'with  funny '\'' $x & #! name' \
| +  'file with  funny \ '\'' \'\'' $ & #!*? name' \
| +  'with  funny \ '\'' \'\'' " <a >b & * ? name ' # "restore font-lock
| +do
| +  # The function func_sanitize_file_name comes from tools.at
| +  file=`func_sanitize_file_name "$file"`
|  cat >"$file.in" <<'END'
|  OK
|  END
| -# skip if we cannot create such a file
| -AT_CHECK([test -f "$file.in" || exit 77])
|  AT_CHECK([./config.status "--file=$file:$file.in"],
|        [0], [ignore])
|  AT_CHECK([grep OK "$file"], [], [OK
| @@ -276,15 +283,16 @@ AT_CHECK([./config.status "--header=$file:$file.in"],
|        [0], [ignore])
|  # Run the same test a 2nd time to see that config.status does not recreate
|  # the header (regression test)
| -AT_CHECK([./config.status "--header=$file:$file.in"],
| -      [0], [config.status: creating file with  funny \ ' \' $ & #!*? name
| -config.status: file with  funny \ ' \' $ & #!*? name is unchanged
| +  AT_CHECK_NOESCAPE([./config.status "--header=$file:$file.in"],
| +                 [0], [config.status: creating $file
| +config.status: $file is unchanged
|  ])
| -AT_CHECK([grep ' & ' "$file"], [],
| -[/* file with  funny \ ' \' $ & #!*? name.  Generated from file with  funny 
\ ' \' $ & #!*? name.in by configure.  */
| +  AT_CHECK_NOESCAPE([grep ' & ' "$file"], [],
| +[/* $file.  Generated from $file.in by configure.  */
|  ])
|  AT_CHECK([grep OK "$file"], [], [OK
|  ])
| +done
|  AT_CLEANUP
 
HTH,

 tests/atlocal.in |   26 ++++++++++++++++++++++++++
 tests/tools.at   |    9 ++++-----
 tests/torture.at |   42 +++++++++++++++++++++++++-----------------
 3 files changed, 55 insertions(+), 22 deletions(-)

diff --git a/tests/atlocal.in b/tests/atlocal.in
index dad0ea8..6fbbef5 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -24,3 +24,29 @@ SED='@SED@'
 
 # We need to know if sh -n is ok.
 ac_cv_sh_n_works='@ac_cv_sh_n_works@'
+
+# Check whether the underlying system can manage some unusual
+# symbols in file names.
+unsupported_fs_chars=
+for c in '\' '"' '<' '>' '*' '?'
+do
+  touch "t$c" 2>/dev/null
+  test -f "t$c" && rm -f "t$c" && continue
+  # $c cannot be used in a file name.
+  unsupported_fs_chars=$unsupported_fs_chars$c
+done
+if test -z "$unsupported_fs_chars"; then
+  func_sanitize_file_name () { echo "$@"; }
+else
+  func_sanitize_file_name () { echo "$@" | tr -d \"\$unsupported_fs_chars\"; }
+fi
+
+# Can we create directories with trailing whitespaces in their name?
+rm -rf 'tdir /'
+mkdir 'tdir ' && touch 'tdir /tfile' 2>/dev/null
+if test -f 'tdir /tfile'; then
+  func_sanitize_dir_name () { echo "$@"; }
+  rm -rf 'tdir /'
+else
+  func_sanitize_dir_name () { echo "$@" | sed 's/  *$//'; }
+fi
diff --git a/tests/tools.at b/tests/tools.at
index e5f9ae8..1b3dca5 100644
--- a/tests/tools.at
+++ b/tests/tools.at
@@ -146,15 +146,14 @@ AT_SETUP([autom4te and whitespace in file names])
 x=
 export x
 rm -f a b
-# the first one omits special characters and trailing spaces,
-# which are not w32 safe.
 for funny in \
   'with  funny '\'' $x & #! name' \
   'with  funny \ '\'' \'\'' " <a >b * ? name ' # "restore font-lock
 do
+  funny=`func_sanitize_file_name "$funny"`
   file=" file $funny"
   outfile="$file out "
-  dir=" dir $funny"
+  dir=`func_sanitize_dir_name " dir $funny"`
   cachedir=" cache$dir"
   TMPDIR=" tmp$dir"
   export TMPDIR
@@ -988,13 +987,13 @@ AT_SETUP([autotools and whitespace in file names])
 x=
 export x
 rm -f a b
-# the first one omits special characters that are not w32 safe.
 for funny in \
   'with  funny '\'' $x & #! name ' \
   'with  funny \ '\'' \'\'' " <a >b * ? name '
 do
+  funny=`func_sanitize_file_name "$funny"`
   file=" file $funny"
-  dir=" dir $funny"
+  dir=`func_sanitize_dir_name " dir $funny"`
   TMPDIR=" tmp$dir"
   export TMPDIR
 
diff --git a/tests/torture.at b/tests/torture.at
index c1ec29a..36956b0 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -262,29 +262,37 @@ AT_CHECK_CONFIG_CREATION_NOWRITE(link)
 AT_CHECK([grep ac_write_fail config.status], [1])
 
 # Check that --file and --header accept funny file names
-file='file with  funny \ '\'' \'\'' $ & #!*? name'
-cat >"$file.in" <<'END'
+
+x=
+export x
+for file in \
+  'with  funny '\'' $x & #! name' \
+  'file with  funny \ '\'' \'\'' $ & #!*? name' \
+  'with  funny \ '\'' \'\'' " <a >b & * ? name ' # "restore font-lock
+do
+  # The function func_sanitize_file_name comes from tools.at
+  file=`func_sanitize_file_name "$file"`
+  cat >"$file.in" <<'END'
 OK
 END
-# skip if we cannot create such a file
-AT_CHECK([test -f "$file.in" || exit 77])
-AT_CHECK([./config.status "--file=$file:$file.in"],
-        [0], [ignore])
-AT_CHECK([grep OK "$file"], [], [OK
+  AT_CHECK([./config.status "--file=$file:$file.in"],
+          [0], [ignore])
+  AT_CHECK([grep OK "$file"], [], [OK
 ])
-AT_CHECK([./config.status "--header=$file:$file.in"],
-        [0], [ignore])
-# Run the same test a 2nd time to see that config.status does not recreate
-# the header (regression test)
-AT_CHECK([./config.status "--header=$file:$file.in"],
-        [0], [config.status: creating file with  funny \ ' \' $ & #!*? name
-config.status: file with  funny \ ' \' $ & #!*? name is unchanged
+  AT_CHECK([./config.status "--header=$file:$file.in"],
+          [0], [ignore])
+  # Run the same test a 2nd time to see that config.status does not recreate
+  # the header (regression test)
+  AT_CHECK_NOESCAPE([./config.status "--header=$file:$file.in"],
+                   [0], [config.status: creating $file
+config.status: $file is unchanged
 ])
-AT_CHECK([grep ' & ' "$file"], [],
-[/* file with  funny \ ' \' $ & #!*? name.  Generated from file with  funny \ 
' \' $ & #!*? name.in by configure.  */
+  AT_CHECK_NOESCAPE([grep ' & ' "$file"], [],
+[/* $file.  Generated from $file.in by configure.  */
 ])
-AT_CHECK([grep OK "$file"], [], [OK
+  AT_CHECK([grep OK "$file"], [], [OK
 ])
+done
 AT_CLEANUP
 
 
-- 
1.5.4.rc0.88.g7d4e-dirty





reply via email to

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