perl/Module-Build-Tiny: update to 0.051 for Perl 5.36 and 5.38
[oi-userland.git] / components / shell / bash / bash_test_wrapper
bloba8a964f6a490ea78ef34c17c0a486bae1210971c
1 #!/bin/bash
3 # Override HOME. Bash processes $HOME/.profile.
4 HOME=$(pwd)/home
5 mkdir -p "$HOME"
6 export HOME
8 # Pre-set TMPDIR. The content of system tmp could collide with the tests.
9 TMPDIR=$(pwd)/tmp
10 mkdir -p "$TMPDIR"
11 export TMPDIR
13 if tty -s; then
14 # If we have a tty, just run the tests
15 gmake "$@"
16 else
17 # If we don't have tty, run the tests in screen(1) to make the tests
18 # pass successfully. But screen needs some pty already, so create one
19 # using python. We can't run the tests directly in python as pty module
20 # does not simulate terminal, it merely provides pty device. Also we
21 # set the TERM environment variable to 'xterm' so that screen does not
22 # start confused setting TERM to 'dumb' which breaks the tests again.
23 # Also we have to collect the test output ourselves, since userland
24 # infrastructure captures the screen output which is full of terminal
25 # control codes. To offset anything user may have set in his .screenrc
26 # we use /dev/null as screen config. Last touch is to unset TSTP signal
27 # which is set if we run 'gmake test' via ssh. Unsetting it to default
28 # makes the tests pass even in this case.
29 python -c '
30 import pty;
31 import signal;
32 import sys;
34 signal.signal(signal.SIGTSTP, signal.SIG_DFL)
35 pty.spawn(sys.argv[1:])
36 ' env TERM=xterm /usr/bin/screen -c /dev/null bash -c 'gmake '"$@"' 2>&1 | tee outfile'