-
Notifications
You must be signed in to change notification settings - Fork 38
/
install.test.sh
executable file
·71 lines (57 loc) · 1.2 KB
/
install.test.sh
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
# shellcheck shell=dash
set -e
assert() {
local _command
_command="$1"
local _string
_string="$2"
local _colored
_colored="$3"
if ! eval "$_command" | grep -q "$_string"; then
local _status
_status="$(failure "Assertion failed:" "$_colored")"
printf "%s '%s' does not contain '%s'\n" "$_status" "$_command" "$_string"
exit 1
fi
}
failure() {
local _string
_string="$1"
local _colored
_colored="$2"
if $_colored; then
_string="\33[1;31m$_string\33[0m"
fi
echo "$_string"
}
success() {
local _string="$1"
local _colored="$2"
if $_colored; then
_string="\33[1;32m$_string\33[0m"
fi
echo "$_string"
}
main() {
sh ./install.sh
export PATH="$PATH:$HOME/.temporalio/bin"
local _colored
_colored=false
if [ -t 2 ]; then
if [ "${TERM+set}" = 'set' ]; then
case "$TERM" in
xterm* | rxvt* | urxvt* | linux* | vt*)
# ansi escapes are valid
_colored=true
;;
esac
fi
fi
assert "temporal -v" "temporal version" $_colored
assert "sh ./install.sh --help" "Temporal CLI" $_colored
local _status
_status="$(success "Tests passed" $_colored)"
printf "%s\n" "$_status"
}
main "$@" || exit 1