forked from Distributive-Network/PythonMonkey
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer-reject.bash
More file actions
executable file
·47 lines (40 loc) · 1005 Bytes
/
timer-reject.bash
File metadata and controls
executable file
·47 lines (40 loc) · 1005 Bytes
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
#! /bin/bash
#
# @file timer-reject.bash
# A peter-jr test which shows that unhandled rejections in timers get shown on stderr,
# exit with status 1, and aren't delayed because of pending events.
#
# @author Wes Garland, wes@distributive.network
# @date July 2023
#
# timeout: 10
set -u
set -o pipefail
panic()
{
echo "FAIL: $*" >&2
exit 2
}
cd `dirname "$0"` || panic "could not change to test directory"
"${PMJS:-../../pmjs}" ./timer-reject.js 2>&1 1>/dev/null \
| egrep 'hello|goodbye|fire' \
| (
read line
if [[ "$line" =~ hello ]]; then
echo "found expected '$line'"
else
panic "expected hello, found '${line}'"
fi
read line
if [[ "$line" =~ Error:.goodbye ]]; then
echo "found expected '$line'"
else
panic "expected Error: goodbye, found '${line}'"
fi
)
exitCode="$?"
if [ "${exitCode}" = "1" ]; then
echo pass
exit 0
fi
[ "$exitCode" = 2 ] || panic "Exit code was $exitCode"