193 lines
5.4 KiB
Diff
193 lines
5.4 KiB
Diff
ChangeLog | 16 +++++++
|
|
find/testsuite/Makefile.am | 3 +
|
|
find/testsuite/config/unix.exp | 9 ++++
|
|
find/testsuite/find.gnu/execdir-multiple.exp | 55 ++++++++++++++++++++++++++
|
|
find/testsuite/find.gnu/execdir-multiple.xo | 24 +++++++++++
|
|
find/testsuite/find.gnu/execdir-pwd1.exp | 20 +++++++++
|
|
6 files changed, 127 insertions(+), 0 deletions(-)
|
|
|
|
diff --git a/ChangeLog b/ChangeLog
|
|
index be93846..34552d5 100644
|
|
--- a/ChangeLog
|
|
+++ b/ChangeLog
|
|
@@ -1,3 +1,19 @@
|
|
+2010-04-10 James Youngman <jay@gnu.org>
|
|
+
|
|
+ Add a test which checks $CWD for find -execdir {} +/;
|
|
+ * find/testsuite/find.gnu/execdir-multiple.exp: New test; verifies
|
|
+ that for -execdir +, all the execs occur with the correct working
|
|
+ directory.
|
|
+ * find/testsuite/find.gnu/execdir-multiple.xo: Expected output for
|
|
+ this test.
|
|
+ * find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add the new test.
|
|
+ (EXTRA_DIST_XO): Add the expected output file.
|
|
+ * find/testsuite/config/unix.exp (mkdir): Create proc "mkdir"
|
|
+ which creates a directory.
|
|
+ * find/testsuite/find.gnu/execdir-pwd1.exp: New test.
|
|
+ * find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add
|
|
+ execdir-pwd1.exp.
|
|
+
|
|
2009-05-16 James Youngman <jay@gnu.org>
|
|
|
|
Apply typo fix from <petrosyan@gmail.com> (tiny change).
|
|
diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am
|
|
index dca30e6..1447132 100644
|
|
--- a/find/testsuite/Makefile.am
|
|
+++ b/find/testsuite/Makefile.am
|
|
@@ -14,6 +14,7 @@ find.gnu/depth.xo \
|
|
find.gnu/depth-d.xo \
|
|
find.gnu/empty.xo \
|
|
find.gnu/execdir-hier.xo \
|
|
+find.gnu/execdir-multiple.xo \
|
|
find.gnu/execdir-one.xo \
|
|
find.gnu/execdir-root-only.xo \
|
|
find.gnu/exec-many-rtn-failure.xo \
|
|
@@ -114,8 +115,10 @@ find.gnu/depth-d.exp \
|
|
find.gnu/empty.exp \
|
|
find.gnu/execdir-hier.exp \
|
|
find.gnu/execdir-in-unreadable.exp \
|
|
+find.gnu/execdir-multiple.exp \
|
|
find.gnu/execdir-one.exp \
|
|
find.gnu/execdir-pwd.exp \
|
|
+find.gnu/execdir-pwd1.exp \
|
|
find.gnu/execdir-root-only.exp \
|
|
find.gnu/exec-many-rtn-failure.exp \
|
|
find.gnu/exec-many-rtn-success.exp \
|
|
diff --git a/find/testsuite/config/unix.exp b/find/testsuite/config/unix.exp
|
|
index 087aeb2..968eb9d 100644
|
|
--- a/find/testsuite/config/unix.exp
|
|
+++ b/find/testsuite/config/unix.exp
|
|
@@ -259,6 +259,15 @@ proc touch args {
|
|
}
|
|
}
|
|
|
|
+proc mkdir { dirname } {
|
|
+ # Not all versions of Tcl offer 'file mkdir'.
|
|
+ set failed [ catch "file mkdir $dirname" result ]
|
|
+ if $failed {
|
|
+ # Fall back on the external command.
|
|
+ send_log "file mkdir does not work, falling back on exec mkdir\n"
|
|
+ exec mkdir "$dirname"
|
|
+ }
|
|
+}
|
|
|
|
|
|
proc safe_path [ ] {
|
|
diff --git a/find/testsuite/find.gnu/execdir-multiple.exp b/find/testsuite/find.gnu/execdir-multiple.exp
|
|
new file mode 100644
|
|
index 0000000..6d4bd66
|
|
--- /dev/null
|
|
+++ b/find/testsuite/find.gnu/execdir-multiple.exp
|
|
@@ -0,0 +1,55 @@
|
|
+# tests for -execdir ... \+
|
|
+
|
|
+# Create 4 empty files in each of 6 directories.
|
|
+# Also create a shell script in each of those 6 directories.
|
|
+# Run a find command which runs the shell script for each empty file.
|
|
+# Check to make sure that each file is mentioned exactly once, and that
|
|
+# the command was run with the correct working directory.
|
|
+#
|
|
+# The output is a sequence of lines of this form:
|
|
+#
|
|
+# cwd ./basename
|
|
+#
|
|
+# cmd is the basename of the current directory at the time the command
|
|
+# is run by -execidr. ./basename is the name of the file that was matched
|
|
+# (that is, it's the value passed in {}).
|
|
+
|
|
+# $body is the body of a shell script we use for testing.
|
|
+# It prints a series of lines of the form described above.
|
|
+# One line is printed for each command-line argument.
|
|
+set body {#! /bin/sh
|
|
+set -e
|
|
+here=`pwd`
|
|
+d=`basename $here`
|
|
+
|
|
+for arg;
|
|
+do
|
|
+ echo "$d" "$arg"
|
|
+done | LC_ALL=C sort
|
|
+}
|
|
+
|
|
+
|
|
+if { [ safe_path ] } {
|
|
+ global SKIP_OLD
|
|
+
|
|
+ exec rm -rf tmp
|
|
+ mkdir tmp
|
|
+
|
|
+ # Put a copy of our shell script in each
|
|
+ # directory, plus some files.
|
|
+ foreach dir { a b c d e f } {
|
|
+ mkdir "tmp/$dir"
|
|
+ set script_name "tmp/$dir/runme"
|
|
+ set f [open "$script_name" "w" 0700 ]
|
|
+ puts $f "$body"
|
|
+ close $f
|
|
+ foreach item { one two three four } {
|
|
+ touch "tmp/$dir/$item"
|
|
+ }
|
|
+ }
|
|
+
|
|
+ set SKIP_OLD 1
|
|
+ find_start p {tmp -type f -empty -execdir sh ./runme \{\} + } ""
|
|
+ set SKIP_OLD 0
|
|
+ exec rm -rf tmp
|
|
+}
|
|
diff --git a/find/testsuite/find.gnu/execdir-multiple.xo b/find/testsuite/find.gnu/execdir-multiple.xo
|
|
new file mode 100644
|
|
index 0000000..a4f93d9
|
|
--- /dev/null
|
|
+++ b/find/testsuite/find.gnu/execdir-multiple.xo
|
|
@@ -0,0 +1,24 @@
|
|
+a ./one
|
|
+a ./two
|
|
+a ./three
|
|
+a ./four
|
|
+b ./one
|
|
+b ./two
|
|
+b ./three
|
|
+b ./four
|
|
+c ./one
|
|
+c ./two
|
|
+c ./three
|
|
+c ./four
|
|
+d ./one
|
|
+d ./two
|
|
+d ./three
|
|
+d ./four
|
|
+e ./one
|
|
+e ./two
|
|
+e ./three
|
|
+e ./four
|
|
+f ./one
|
|
+f ./two
|
|
+f ./three
|
|
+f ./four
|
|
diff --git a/find/testsuite/find.gnu/execdir-pwd1.exp b/find/testsuite/find.gnu/execdir-pwd1.exp
|
|
new file mode 100644
|
|
index 0000000..e9863ac
|
|
--- /dev/null
|
|
+++ b/find/testsuite/find.gnu/execdir-pwd1.exp
|
|
@@ -0,0 +1,20 @@
|
|
+# tests for working directory of -execdir {} \;
|
|
+if { [ safe_path ] } {
|
|
+ global SKIP_OLD
|
|
+
|
|
+ exec rm -rf tmp
|
|
+ exec mkdir tmp
|
|
+
|
|
+ # Create an empty shell script.
|
|
+ exec touch tmp/foo
|
|
+ exec chmod +x tmp/foo
|
|
+
|
|
+ # The -execdir should find the "foo" in the current directory.
|
|
+ # If not, the find command is probably executing the command
|
|
+ # built up by -execdir in the wrong directory.
|
|
+
|
|
+ set SKIP_OLD 1
|
|
+ find_start p {tmp -name foo -execdir sh ./foo \{\} \; } ""
|
|
+ set SKIP_OLD 0
|
|
+ exec rm -rf tmp
|
|
+}
|