[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/8] Add a test for "find -printf \c".
From: |
James Youngman |
Subject: |
[PATCH 4/8] Add a test for "find -printf \c". |
Date: |
Sat, 18 Jun 2011 15:50:57 +0100 |
* find/testsuite/Makefile.am (test_shell_progs): New variable,
where we keep the list of shell script tests. This avoids needing
to remember to update both TESTS and EXTRA_DIST. Add
test_escape_c.sh (which is new) and test_escapechars.sh (which we
previously forgot).
* find/testsuite/test_escape_c.sh: New test for "find -printf
\c".
---
ChangeLog | 9 +++++++++
find/testsuite/Makefile.am | 7 +++++--
find/testsuite/test_escape_c.sh | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+), 2 deletions(-)
create mode 100755 find/testsuite/test_escape_c.sh
diff --git a/ChangeLog b/ChangeLog
index f25ea28..6ca10fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2011-06-18 James Youngman <address@hidden>
+ Add a test for "find -printf \c".
+ * find/testsuite/Makefile.am (test_shell_progs): New variable,
+ where we keep the list of shell script tests. This avoids needing
+ to remember to update both TESTS and EXTRA_DIST. Add
+ test_escape_c.sh (which is new) and test_escapechars.sh (which we
+ previously forgot).
+ * find/testsuite/test_escape_c.sh: New test for "find -printf
+ \c".
+
Remove an unnecessary argument from insert_fprintf.
* find/print.c (insert_fprintf): Eliminate the 'func' argument,
since it is always pref_fprintf.
diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am
index 6ca56d5..e944456 100644
--- a/find/testsuite/Makefile.am
+++ b/find/testsuite/Makefile.am
@@ -242,14 +242,17 @@ find.posix/exec-one.exp \
find.posix/user-empty.exp \
find.posix/user-missing.exp
-EXTRA_DIST = $(EXTRA_DIST_EXP) $(EXTRA_DIST_XO) sv-bug-32043.sh
+test_shell_progs = sv-bug-32043.sh test_escapechars.sh test_escape_c.sh
+
+EXTRA_DIST = $(EXTRA_DIST_EXP) $(EXTRA_DIST_XO) \
+ $(test_shell_progs)
CLEANFILES = *.log *.sum site.exp site.bak
#DIST_SUBDIRS = config
-TESTS = sv-bug-32043.sh test_escapechars.sh
+TESTS = $(test_shell_progs)
checklists:
cd $(srcdir) && \
diff --git a/find/testsuite/test_escape_c.sh b/find/testsuite/test_escape_c.sh
new file mode 100755
index 0000000..50351ea
--- /dev/null
+++ b/find/testsuite/test_escape_c.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+testname="$(basename $0)"
+
+parent="$(cd .. && pwd)"
+if [[ -f "${parent}/ftsfind" ]]; then
+ ftsfind="${parent}/ftsfind"
+ oldfind="${parent}/find"
+elif [[ -f "${parent}/oldfind" ]]; then
+ ftsfind="${parent}/find"
+ oldfind="${parent}/oldfind"
+else
+ echo "Cannot find the executables to test." >&2
+ exit 1
+fi
+
+goldenfile="${srcdir}/test_escapechars.golden"
+expected='hello^.^world'
+
+for executable in "$oldfind" "$ftsfind"
+do
+ if result="$($executable . -maxdepth 0 \
+ -printf 'hello^\cthere' \
+ -exec printf %s {} \; \
+ -printf '^world\n' )"; then
+ if [[ "${result}" != "${expected}" ]]; then
+ exec >&2
+ echo "$executable produced incorrect output:"
+ echo "${result}"
+ echo "Expected output was:"
+ echo "${expected}"
+ exit 1
+ fi
+ else
+ echo "$executable returned $?" >&2
+ exit 1
+ fi
+done
--
1.7.2.5
- [PATCH 0/8] Print refactoring, James Youngman, 2011/06/18
- [PATCH 3/8] Remove an unnecessary argument from insert_fprintf., James Youngman, 2011/06/18
- [PATCH 5/8] Add a test for find -printf ... %%., James Youngman, 2011/06/18
- [PATCH 7/8] Reserve format specifiers %(, %{ and %[ for future use., James Youngman, 2011/06/18
- [PATCH 6/8] Additional test cases for printf field width, precision and sign., James Youngman, 2011/06/18
- [PATCH 4/8] Add a test for "find -printf \c".,
James Youngman <=
- [PATCH 2/8] Add new test for octal and letter escapes in -printf format., James Youngman, 2011/06/18
- [PATCH 1/8] Split find's printf-related code into a new file., James Youngman, 2011/06/18
- [PATCH 8/8] Move the printing code into print.c., James Youngman, 2011/06/18