* find/testsuite/binary_locations.sh: New file, extracting common code from the test scripts. * find/testsuite/test_escape_c.sh: Source binary_locations.sh. * find/testsuite/test_escapechars.sh: Source binary_locations.sh. --- ChangeLog | 10 ++++++++++ find/testsuite/Makefile.am | 2 +- find/testsuite/binary_locations.sh | 18 ++++++++++++++++++ find/testsuite/test_escape_c.sh | 12 +----------- find/testsuite/test_escapechars.sh | 12 +----------- 5 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 find/testsuite/binary_locations.sh
diff --git a/ChangeLog b/ChangeLog index 39a7a5f..56a3a30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-06-19 James Youngman <[email protected]> + + Extract common test code into a sourced file. + * find/testsuite/binary_locations.sh: New file, extracting common + code from the test scripts. + * find/testsuite/test_escape_c.sh: Source binary_locations.sh. + * find/testsuite/test_escapechars.sh: Source binary_locations.sh. + * find/testsuite/Makefile.am (EXTRA_DIST): Distribute + binary_locations.sh. + 2011-06-18 James Youngman <[email protected]> Remove test-coverage output files for "make clean". diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am index fde9fae..4f2593b 100644 --- a/find/testsuite/Makefile.am +++ b/find/testsuite/Makefile.am @@ -249,7 +249,7 @@ EXTRA_DIST_GOLDEN = \ test_shell_progs = sv-bug-32043.sh test_escapechars.sh test_escape_c.sh EXTRA_DIST = $(EXTRA_DIST_EXP) $(EXTRA_DIST_XO) $(EXTRA_DIST_GOLDEN) \ - $(test_shell_progs) + $(test_shell_progs) binary_locations.sh CLEANFILES = *.log *.sum site.exp site.bak diff --git a/find/testsuite/binary_locations.sh b/find/testsuite/binary_locations.sh new file mode 100644 index 0000000..96943a0 --- /dev/null +++ b/find/testsuite/binary_locations.sh @@ -0,0 +1,18 @@ +# Source this file, don't execute it. + +if [[ -z "${testname}" ]]; then + echo 'Please set $testname before sourcing binary_locations.sh.' >&2 + exit 1 +fi + +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 diff --git a/find/testsuite/test_escape_c.sh b/find/testsuite/test_escape_c.sh index 50351ea..c561c5d 100755 --- a/find/testsuite/test_escape_c.sh +++ b/find/testsuite/test_escape_c.sh @@ -1,17 +1,7 @@ #! /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 +. "${srcdir}"/binary_locations.sh goldenfile="${srcdir}/test_escapechars.golden" expected='hello^.^world' diff --git a/find/testsuite/test_escapechars.sh b/find/testsuite/test_escapechars.sh index 87fe679..54556d5 100755 --- a/find/testsuite/test_escapechars.sh +++ b/find/testsuite/test_escapechars.sh @@ -1,17 +1,7 @@ #! /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 +. "${srcdir}"/binary_locations.sh goldenfile="${srcdir}/test_escapechars.golden" -- 1.7.2.5
