This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Promote v5.36 usage and feature bundles doc
[perl5.git] / runtests.SH
1 #!/bin/sh
2
3 case $PERL_CONFIG_SH in
4 '')
5     if test ! -f config.sh; then
6         ln ../config.sh . || \
7         ln ../../config.sh . || \
8         ln ../../../config.sh . || \
9         (echo "Can't find config.sh."; exit 1)
10     fi 2>/dev/null
11     . ./config.sh
12     ;;
13 esac
14 case "$0" in
15 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
16 esac
17 echo "Extracting runtests (with variable substitutions)"
18 rm -f runtests
19
20 $spitshell >runtests <<!GROK!THIS!
21 $startsh -e
22 # runtests.SH
23
24 !GROK!THIS!
25
26 ## In the following, dollars and backticks do not need the extra backslash.
27 $spitshell >>runtests <<'!NO!SUBS!'
28
29 export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
30
31 # Avoid "warning: jobserver unavailable: using -j1." warnings under GNU make.
32 # When gmake -j N spawns a child, it passes
33 #    MAKEFLAGS=" --jobserver-fds=3,4 -j".
34 # in the environment.  Also, if make recognises that the child is another
35 # make (e.g. it's invoked as $(MAKE) or +command), it keeps open fd's 3
36 # and 4 to allow the child process to access the job server. Otherwise,
37 # those fd's aren't kept open.
38 # In the case where one does 'make -j 16 test_harness', this script is
39 # called with MAKEFLAGS set, but fd's 3 and 4 closed. Later when
40 # descendents of this script run cpan/ExtUtils-Constant/t/Constant.t
41 # which itelf invokes make, the warnings ensue.
42
43 if [ "x$MAKEFLAGS" != "x" ]; then
44     unset MAKEFLAGS
45 fi
46
47 case $# in
48     0)
49         echo "runtests tty_flag ..."
50         exit 1
51         ;;
52 esac
53
54 case $1 in
55     tty)
56         tty=Y
57         ;;
58     no-tty)
59         tty=N
60         ;;
61     choose)
62         if (true </dev/tty) >/dev/null 2>&1; then
63             tty=Y
64         else
65             tty=N
66         fi
67         ;;
68     *)
69         echo "ttyflag should be one of tty, no-tty or choose"
70         exit 1
71         ;;
72 esac
73
74 if test X"$TESTFILE" = X; then
75     TESTFILE=TEST
76 fi
77
78 cd t
79
80 # If this is run under an old shell that doesn't automatically 
81 # update PWD, then we must update it.  Otherwise, t/io/fs.t gets 
82 # mixed up about what directory we are in.
83 case "$PWD" in
84     '')  ;; # Do nothing if it isn't set at all.
85     */t) ;; # Leave it alone if it's properly updated.
86     *) PWD=${PWD}/t; export PWD ;;  # Otherwise, fix it.
87 esac
88
89 !NO!SUBS!
90
91 ## In the following, dollars and backticks do need the extra backslash.
92 $spitshell >>runtests <<!GROK!THIS!
93 # The second branch is for testing without a tty or controlling terminal,
94 # see t/op/stat.t
95 if test \$tty = Y; then
96     ./perl$_exe \$TESTFILE \$TEST_ARGS \$TEST_FILES </dev/tty
97 else
98     PERL_SKIP_TTY_TEST=1 ./perl$_exe \$TESTFILE \$TEST_ARGS \$TEST_FILES
99 fi
100
101 echo "Ran tests" > rantests
102 !GROK!THIS!
103 $eunicefix runtests
104 chmod +x runtests