This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Import perl5321delta.pod
[perl5.git] / runtests.SH
CommitLineData
1f00b0d6
S
1#!/bin/sh
2
9988b539
NC
3case $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 ;;
13esac
14case "$0" in
15*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
16esac
17echo "Extracting runtests (with variable substitutions)"
18rm -f runtests
f1397316 19
9988b539
NC
20$spitshell >runtests <<!GROK!THIS!
21$startsh -e
22# runtests.SH
23#
f1397316 24!GROK!THIS!
9988b539 25
f1397316
AD
26## In the following, dollars and backticks do not need the extra backslash.
27$spitshell >>runtests <<'!NO!SUBS!'
9988b539 28
f1397316
AD
29export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$)
30
8b51b1ff
DM
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
43unset MAKEFLAGS
44
45
f1397316 46case $# in
9988b539
NC
47 0)
48 echo "runtests tty_flag ..."
49 exit 1
50 ;;
51esac
52
f1397316 53case $1 in
9988b539
NC
54 tty)
55 tty=Y
56 ;;
57 no-tty)
58 tty=N
59 ;;
60 choose)
61 if (true </dev/tty) >/dev/null 2>&1; then
62 tty=Y
63 else
64 tty=N
65 fi
66 ;;
67 *)
68 echo "ttyflag should be one of tty, no-tty or choose"
69 exit 1
70 ;;
71esac
72
f1397316 73if test X"$TESTFILE" = X; then
9988b539
NC
74 TESTFILE=TEST
75fi
76
77cd t
9988b539 78
7d18793f
AD
79# If this is run under an old shell that doesn't automatically
80# update PWD, then we must update it. Otherwise, t/io/fs.t gets
81# mixed up about what directory we are in.
82case "$PWD" in
83 '') ;; # Do nothing if it isn't set at all.
84 */t) ;; # Leave it alone if it's properly updated.
85 *) PWD=${PWD}/t; export PWD ;; # Otherwise, fix it.
86esac
87
f1397316
AD
88!NO!SUBS!
89
90## In the following, dollars and backticks do need the extra backslash.
91$spitshell >>runtests <<!GROK!THIS!
9988b539
NC
92# The second branch is for testing without a tty or controlling terminal,
93# see t/op/stat.t
12a67024 94if test \$tty = Y; then
463c96de 95 ./perl$_exe \$TESTFILE \$TEST_ARGS \$TEST_FILES </dev/tty
9988b539 96else
463c96de 97 PERL_SKIP_TTY_TEST=1 ./perl$_exe \$TESTFILE \$TEST_ARGS \$TEST_FILES
9988b539 98fi
6fa4dacc
NC
99
100echo "Ran tests" > rantests
9988b539
NC
101!GROK!THIS!
102$eunicefix runtests
103chmod +x runtests