Browse Source

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 <naoir@gmx.net>
Marcel Denia 9 years ago
parent
commit
df26e427f9
1 changed files with 60 additions and 3 deletions
  1. 60
    3
      lang/perl/files/perl-run_tests.sh

+ 60
- 3
lang/perl/files/perl-run_tests.sh View File

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