1
0

perl-run_tests.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. PERL_TESTSDIR="/usr/share/perl/perl-tests"
  3. PERL_LIBDIR="/usr/lib/perl5/%%PERL_VERSION%%/"
  4. PERL_DISABLEDTESTS="%%PERL_DISABLEDTESTS%%"
  5. no_run=""
  6. manual_run=""
  7. manual_run_no_base=""
  8. while [ ! -z "$1" ]; do
  9. case $1 in
  10. -n)
  11. no_run="yes"
  12. ;;
  13. -m)
  14. manual_run="yes"
  15. ;;
  16. -mb)
  17. manual_run="yes"
  18. manual_run_no_base="yes"
  19. ;;
  20. --help)
  21. echo "run_tests.sh [-n|-m|-mb|--help]"
  22. echo ""
  23. echo "Options:"
  24. echo " -n Just prepare the environment. Don't actually run any tests"
  25. echo " -m Run tests manually according to MANIFEST, instead of whatever t/TEST chooses"
  26. echo " -mb Don't run base tests. Implies -m"
  27. echo " --help Print this help ;)"
  28. echo ""
  29. exit 0
  30. ;;
  31. *)
  32. echo "Invalid argument: $1"
  33. ;;
  34. esac
  35. shift
  36. done
  37. if [ ! -f "$PERL_TESTSDIR/__prepared" ]; then
  38. # Many tests insist on having PERL5LIB in $PERL_TESTSDIR/lib. However,
  39. # that directory may also contain tests. Some of them(FindBin.t in particular)
  40. # also demand being located in a directory ending with "lib". So we can't do symlink
  41. # trickery here.
  42. # Our solution is to just copy PERL5LIB over.
  43. if [ -d "$PERL_TESTSDIR/lib" ]; then
  44. cp -a "$PERL_LIBDIR/"* "$PERL_TESTSDIR/lib/"
  45. else
  46. ln -s "$PERL_LIBDIR" "$PERL_TESTSDIR/lib"
  47. fi
  48. ln -s /usr/bin/perl "$PERL_TESTSDIR/perl"
  49. ln -s /usr/bin/perl "$PERL_TESTSDIR/t/perl"
  50. touch "$PERL_TESTSDIR/__prepared"
  51. for i in $PERL_DISABLEDTESTS; do
  52. echo "Disabling $i tests"
  53. sed 's!^'$i'.*$!!' -i $PERL_TESTSDIR/MANIFEST
  54. done
  55. cat $PERL_TESTSDIR/MANIFEST | grep -v '^$' > $PERL_TESTSDIR/MANIFEST_NEW
  56. rm $PERL_TESTSDIR/MANIFEST
  57. mv $PERL_TESTSDIR/MANIFEST_NEW $PERL_TESTSDIR/MANIFEST
  58. fi
  59. if [ -z "$no_run" ]; then
  60. cd "$PERL_TESTSDIR/t"
  61. if [ ! -z "$manual_run" ]; then
  62. for i in $(cat ../MANIFEST | sed 's/\t.*$//g' | grep '\.t$'); do
  63. if [ ! -z "$manual_run_no_base" ] && [ ! -z "$(echo $i | grep '^t/')" ]; then
  64. continue;
  65. fi
  66. echo "Running $i"
  67. ./TEST ../$i
  68. echo ""
  69. done
  70. else
  71. ./perl TEST
  72. fi
  73. fi