Repository navigation
Expand file tree
/
Copy pathRunPerlTest
More file actions
executable file
·105 lines (93 loc) · 3.02 KB
/
Copy pathRunPerlTest
File metadata and controls
executable file
·105 lines (93 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#! /bin/sh
# Script to run the Perl-compatible PCRE2 tests through Perl. For testing
# with different versions of Perl, if the first argument is "-perl" then the
# second is taken as the Perl command to use, and both are then removed.
#
# The argument can be the number of the specific Perl compatible test to run
# (ex: "1", "4", "26" or "27"), otherwise it runs all tests and returns at
# exit, the test number with an incorrect output or the test number plus 32
# if it failed to run completely. It returns with 0 on success.
# This script should be run with the main PCRE2 directory current.
if [ "$1" = "-perl" ]; then
if [ $# -lt 2 ] || [ -z "$2" ]; then
echo "RunPerlTest: Missing perl command after -perl" >&2
exit 1
fi
PERL="$2"
ARGS="$1 $PERL"
shift 2
else
PERL=perl
ARGS=""
fi
if [ -n "$1" ] && [ "$1" != "1" ] && [ "$1" != "4" ] &&
[ "$1" != "26" ] && [ "$1" != "27" ]; then
echo "RunPerlTest: Unsupported test number $1 (expected 1, 4, 26 or 27)" >&2
exit 1
fi
if [ $# -gt 1 ]; then
echo "Usage: RunPerlTest [-perl command] [1|4|26|27]" >&2
exit 1
fi
RC=0
if [ -z "$1" ] || [ "$1" = "1" ]; then
echo "-----------------------------------------------------------------"
echo "Perl test: main functionality (PCRE2 test 1)"
if ./PerlTest.sh $ARGS testdata/testinput1 testtry; then
tail -n +2 testtry > testtry2
diff -u testdata/testoutput1 testtry2 || RC=1
else
RC=33
fi
/bin/rm -f testtry testtry2
echo ""
fi
if [ -z "$1" ] || [ "$1" = "4" ]; then
echo "-----------------------------------------------------------------"
echo "Perl test: UTF-8 and Unicode property features (PCRE2 test 4)"
if ./PerlTest.sh $ARGS -utf8 testdata/testinput4 testtry; then
tail -n +2 testtry > testtry2
diff -u testdata/testoutput4 testtry2 || RC=4
else
RC=36
fi
/bin/rm -f testtry testtry2
echo ""
fi
P=$($PERL -MUnicode::UCD -e 'print Unicode::UCD::UnicodeVersion, "\n"')
if [ -z "$1" ] || [ "$1" = "26" ]; then
echo "-----------------------------------------------------------------"
echo "Perl test: Unicode property tests (PCRE2 test 26)"
U=$(head -5 testdata/testinput26 | $PERL -ne 'print "$1\n" if /tests for version ([\d.]+)$/')
if [ "$U" != "$P" ]; then
echo "SKIPPED: Perl uses Unicode $P but version $U was expected"
else
if ./PerlTest.sh $ARGS testdata/testinput26 testtry; then
tail -n +2 testtry > testtry2
diff -u testdata/testoutput26 testtry2 || RC=26
else
RC=58
fi
/bin/rm -f testtry testtry2
echo ""
fi
fi
if [ -z "$1" ] || [ "$1" = "27" ]; then
echo "-----------------------------------------------------------------"
echo "Perl test: Unicode property tests (PCRE2 test 27)"
U=$(head -5 testdata/testinput27 | $PERL -ne 'print "$1\n" if /tests for version ([\d.]+)$/')
if [ "$U" != "$P" ]; then
echo "SKIPPED: Perl uses Unicode $P but version $U was expected"
else
if ./PerlTest.sh $ARGS testdata/testinput27 testtry; then
tail -n +2 testtry > testtry2
diff -u testdata/testoutput27 testtry2 || RC=27
else
RC=59
fi
/bin/rm -f testtry testtry2
echo ""
fi
fi
exit $RC
# End