From: Gary V. Vaughan Date: Sun, 26 Sep 2010 11:19:18 +0000 (+0700) Subject: tests: DRYing out `tests/sh.test'. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1ace00c27adbd8370522301f4fc21e9d4f0c9651;p=thirdparty%2Flibtool.git tests: DRYing out `tests/sh.test'. * Makefile.am (libtool_m4): Canonical location of libtool.m4 file. (lt_aclocal_m4_deps): Use it. (check_scripts): New variable for list of scripts to be checked by `tests/sh.test'. (legacy_tests_edit): New sed script to substitute `libtool_m4' and `check_scripts' into `tests/defs'. (tests/defs.in): Use it. * tests/defs.m4sh (scripts): Calculate absolute paths of each entry in `check_scripts' before changing directories. (libtool_m4): Save location of `libtool.m4'. (macro_dir, aux_dir): Removed. No longer required by any test. * tests/sh.test: Remove loop around just `$macro_dir/libtool.m4' in favour of a single reference to `$libtool_m4' from above. --- diff --git a/ChangeLog b/ChangeLog index 5825b4c92..91fa8a824 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2010-09-26 Gary V. Vaughan + + tests: DRYing out `tests/sh.test'. + * Makefile.am (libtool_m4): Canonical location of libtool.m4 file. + (lt_aclocal_m4_deps): Use it. + (check_scripts): New variable for list of scripts to be checked + by `tests/sh.test'. + (legacy_tests_edit): New sed script to substitute `libtool_m4' + and `check_scripts' into `tests/defs'. + (tests/defs.in): Use it. + * tests/defs.m4sh (scripts): Calculate absolute paths of each + entry in `check_scripts' before changing directories. + (libtool_m4): Save location of `libtool.m4'. + (macro_dir, aux_dir): Removed. No longer required by any test. + * tests/sh.test: Remove loop around just `$macro_dir/libtool.m4' + in favour of a single reference to `$libtool_m4' from above. + 2010-09-23 Gary V. Vaughan maint: pass directory declarations in configure.ac into Makefile. diff --git a/Makefile.am b/Makefile.am index 121badc63..f06eb844e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,6 +89,7 @@ CLEANFILES += libtool libtoolize configure_ac = $(srcdir)/configure.ac libtoolize_in = $(srcdir)/libtoolize.in ltmain_sh = $(aux_dir)/ltmain.sh +libtool_m4 = $(macro_dir)/libtool.m4 ltversion_in = $(macro_dir)/ltversion.in ltversion_m4 = $(macro_dir)/ltversion.m4 @@ -337,7 +338,7 @@ $(stamp_mk): $(lt_Makefile_in) lt_aclocal_m4_deps = \ $(lt_obsolete_m4) \ $(ltversion_m4) \ - $(macro_dir)/libtool.m4 \ + $(libtool_m4) \ $(macro_dir)/ltoptions.m4 \ $(macro_dir)/ltdl.m4 \ $(macro_dir)/ltsugar.m4 \ @@ -957,11 +958,17 @@ TESTS = $(NONINTERACTIVE_TESTS) $(INTERACTIVE_TESTS) defs = tests/defs defs_in = $(tests_dir)/defs.in +check_scripts = $(ltmain_m4sh) $(libtoolize_m4sh) + EXTRA_DIST += $(defs_in) $(defs_m4sh) \ $(COMMON_TESTS) $(CXX_TESTS) $(F77_TESTS) $(FC_TESTS) \ $(INTERACTIVE_TESTS) DIST_SUBDIRS += $(CONF_SUBDIRS) +legacy_tests_edit = $(SED) \ + -e 's,@check_scripts\@,$(check_scripts),g' \ + -e 's,@libtool_m4\@,$(libtool_m4),g' + # The defs script shouldn't be recreated whenever the Makefile is # regenerated since the source tree can be read-only. check-recursive: $(defs) @@ -971,7 +978,7 @@ $(defs): $(defs_in) $(defs_in): $(defs_m4sh) $(general_m4sh) Makefile.am rm -f '$@' - $(LT_M4SH) '$(defs_m4sh)' > '$@' + $(LT_M4SH) '$(defs_m4sh)' | $(legacy_tests_edit) > '$@' # We need to remove any files that the above tests created. clean-local-legacy: diff --git a/tests/defs.m4sh b/tests/defs.m4sh index 6a4807914..28717a90d 100644 --- a/tests/defs.m4sh +++ b/tests/defs.m4sh @@ -342,9 +342,20 @@ func_exec () # Shared global variables for test scripts prefix=./_inst-`echo "$0" | sed 's,.*/,,; s,-.*,,'` srcdir=`cd $srcdir && pwd` -macro_dir=$srcdir/libltdl/m4 -aux_dir=$srcdir/libltdl/config -scripts="$aux_dir/ltmain.m4sh $srcdir/libtoolize.m4sh" + +# sh.test does some checks on libtool.m4. +func_dirname_and_basename '@libtool_m4@' +libtool_m4="`cd $func_dirname_result && pwd`/$func_basename_result" + +# sh.test does lots of checks on the contests of $scripts. +scripts= +sep= +for script in @check_scripts@ +do + func_dirname_and_basename "$script" + scripts="$scripts$sep`cd $func_dirname_result && pwd`/$func_basename_result" + sep=' ' +done # Unset some MAKE... variables that may cause $MAKE to act like a # recursively invoked sub-make. Any $MAKE invocation in a test is diff --git a/tests/sh.test b/tests/sh.test index 4fd3bb3e6..9fd589963 100755 --- a/tests/sh.test +++ b/tests/sh.test @@ -121,14 +121,11 @@ done # Check for correct usage of $cc_basename. # redirect stderr so we also barf when sed issues diagnostics. -for s in "$macro_dir/libtool.m4" -do - if $SED -n '/case \$cc_basename in/,/esac/ { - /^[ ]*[a-zA-Z][a-zA-Z0-9+]*[^*][ ]*)/p - }' $s 2>&1 | $EGREP .; then - echo "\$cc_basename matches should include a trailing \`*' in $s." - status=$EXIT_FAILURE - fi -done +if $SED -n '/case \$cc_basename in/,/esac/ { + /^[ ]*[a-zA-Z][a-zA-Z0-9+]*[^*][ ]*)/p + }' $libtool_m4 2>&1 | $EGREP .; then + echo "\$cc_basename matches should include a trailing \`*' in $libtool_m4." + status=$EXIT_FAILURE +fi exit $status