forked from Distributive-Network/PythonMonkey
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole-stdio.bash
More file actions
executable file
·47 lines (41 loc) · 935 Bytes
/
console-stdio.bash
File metadata and controls
executable file
·47 lines (41 loc) · 935 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 console-stdio.bash
# A peter-jr test which ensures that the console object uses the right file descriptors.
#
# @author Wes Garland, wes@distributive.network
# @date July 2023
set -u
set -o pipefail
panic()
{
echo "FAIL: $*" >&2
exit 2
}
cd `dirname "$0"` || panic "could not change to test directory"
"${PMJS:-pmjs}" \
-e 'console.log("stdout")' \
-e 'console.debug("stdout")' \
-e 'console.info("stdout")' \
< /dev/null \
| tr -d '\r' \
| grep -c '^stdout$' \
| while read qty
do
echo "stdout: $qty"
[ "$qty" != "3" ] && panic qty should not be $qty
break
done || exit $?
"${PMJS:-pmjs}" \
-e 'console.error("stderr")' \
-e 'console.warn("stderr")' \
< /dev/null 2>&1 \
| tr -d '\r' \
| grep -c '^stderr$' \
| while read qty
do
echo "stderr: $qty"
[ "$qty" != "2" ] && panic qty should not be $qty
break
done || exit $?
echo "done"