Skip to content

Commit 295cdd7

Browse files
committed
Added --tee option to psij-ci-run (log AND print output)
1 parent 76ce47f commit 295cdd7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

psij-ci-run

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Usage: ./psij-ci-run [--help] [--repeat] [--reschedule HH:MM] [--log]
1313
--log
1414
Disables output and redirects to a log instead. Used
1515
when running the tests automatically.
16+
--tee
17+
Logs output as if --log was specified, but also prints
18+
on stdout.
1619
EOF
1720
}
1821

@@ -34,6 +37,7 @@ fi
3437
REPEAT=0
3538
RESCHEDULE=0
3639
NO_OUT=0
40+
TEE=0
3741

3842
while [ "$1" != "" ]; do
3943
case "$1" in
@@ -54,6 +58,10 @@ while [ "$1" != "" ]; do
5458
NO_OUT=1
5559
shift
5660
;;
61+
--tee)
62+
TEE=1
63+
shift
64+
;;
5765
*)
5866
echo "Unrecognized command line option: $1."
5967
usage
@@ -62,12 +70,25 @@ while [ "$1" != "" ]; do
6270
esac
6371
done
6472

73+
tee() {
74+
while read LINE; do
75+
echo "$LINE" >&3
76+
echo "$LINE" >>./testing.log
77+
done
78+
}
79+
6580
if [ "$NO_OUT" == "1" ]; then
6681
exec 1<&-
6782
exec 2<&-
6883

6984
exec 1>>./testing.log
7085
exec 2>&1
86+
elif [ "$TEE" == "1" ]; then
87+
exec 3>&1-
88+
exec 2<&-
89+
90+
exec 1> >(tee)
91+
exec 2>&1
7192
fi
7293

7394
if python --version 2>&1 | egrep -q 'Python 3\..*' >/dev/null 2>&1 ; then

0 commit comments

Comments
 (0)