From df26e427f97d4f81fe69f1595417ed1728dc66f9 Mon Sep 17 00:00:00 2001 From: Marcel Denia Date: Wed, 1 Jul 2015 15:58:49 +0200 Subject: [PATCH] perl: Improve run_tests.sh - Add some useful options for debugging tests and test failures - Properly handle tests located in lib/ Signed-off-by: Marcel Denia --- lang/perl/files/perl-run_tests.sh | 63 +++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/lang/perl/files/perl-run_tests.sh b/lang/perl/files/perl-run_tests.sh index 288191b43f..bf83c0a3d1 100755 --- a/lang/perl/files/perl-run_tests.sh +++ b/lang/perl/files/perl-run_tests.sh @@ -4,8 +4,52 @@ PERL_TESTSDIR="/usr/share/perl/perl-tests" PERL_LIBDIR="/usr/lib/perl5/%%PERL_VERSION%%/" PERL_DISABLEDTESTS="%%PERL_DISABLEDTESTS%%" +no_run="" +manual_run="" +manual_run_no_base="" + +while [ ! -z "$1" ]; do + case $1 in + -n) + no_run="yes" + ;; + -m) + manual_run="yes" + ;; + -mb) + manual_run="yes" + manual_run_no_base="yes" + ;; + --help) + echo "run_tests.sh [-n|-m|-mb|--help]" + echo "" + echo "Options:" + echo " -n Just prepare the environment. Don't actually run any tests" + echo " -m Run tests manually according to MANIFEST, instead of whatever t/TEST chooses" + echo " -mb Don't run base tests. Implies -m" + echo " --help Print this help ;)" + echo "" + exit 0 + ;; + *) + echo "Invalid argument: $1" + ;; + esac + shift +done + if [ ! -f "$PERL_TESTSDIR/__prepared" ]; then - ln -s "$PERL_LIBDIR" "$PERL_TESTSDIR/lib" + # Many tests insist on having PERL5LIB in $PERL_TESTSDIR/lib. However, + # that directory may also contain tests. Some of them(FindBin.t in particular) + # also demand being located in a directory ending with "lib". So we can't do symlink + # trickery here. + # Our solution is to just copy PERL5LIB over. + if [ -d "$PERL_TESTSDIR/lib" ]; then + cp -a "$PERL_LIBDIR/"* "$PERL_TESTSDIR/lib/" + else + ln -s "$PERL_LIBDIR" "$PERL_TESTSDIR/lib" + fi + ln -s /usr/bin/perl "$PERL_TESTSDIR/perl" ln -s /usr/bin/perl "$PERL_TESTSDIR/t/perl" touch "$PERL_TESTSDIR/__prepared" @@ -20,5 +64,18 @@ if [ ! -f "$PERL_TESTSDIR/__prepared" ]; then mv $PERL_TESTSDIR/MANIFEST_NEW $PERL_TESTSDIR/MANIFEST fi -cd "$PERL_TESTSDIR/t" -./perl TEST +if [ -z "$no_run" ]; then + cd "$PERL_TESTSDIR/t" + if [ ! -z "$manual_run" ]; then + for i in $(cat ../MANIFEST | sed 's/\t.*$//g' | grep '\.t$'); do + if [ ! -z "$manual_run_no_base" ] && [ ! -z "$(echo $i | grep '^t/')" ]; then + continue; + fi + echo "Running $i" + ./TEST ../$i + echo "" + done + else + ./perl TEST + fi +fi -- 2.30.2