-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun-test.sh
executable file
·70 lines (52 loc) · 2.05 KB
/
run-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
#!/bin/sh
# =============================================================================
# ShellSpec による動的/単体テストの実行スクリプト
# =============================================================================
# -----------------------------------------------------------------------------
# Constants
# -----------------------------------------------------------------------------
PATH_DIR_REPO="$(dirname "$(cd "$(dirname "$0")" && pwd)")"
PATH_DIR_RETURN="$(cd . && pwd)"
SUCCESS=0
FAILURE=1
echo '==============================================================================='
echo ' Requirement Check for ShellSpec'
echo '==============================================================================='
# ShellSpec のインストールチェック
which shellspec 1>/dev/null 2>/dev/null || {
echo >&2 "shellspec がインストールされていません"
echo >&2 "参考文献: https://github.com/shellspec/shellspec#installation"
exit $FAILURE
}
echo "- ShellSpec $(shellspec --version)"
# -----------------------------------------------------------------------------
# Functions
# -----------------------------------------------------------------------------
runShellSpec() {
printf "%s" '- ShellSpec '
result=$(shellspec 2>&1) || {
printf >&2 ": NG\n%s" "$result"
return $FAILURE
}
echo "$(echo "$result" | head -n 2 | tail -n 1)" 'OK'
}
# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------
set -eu
cd "$PATH_DIR_REPO" || {
echo >&2 "Failed to change dir to: ${PATH_DIR_REPO}"
exit $FAILURE
}
echo '-------------------------------------------------------------------------------'
echo ' Running unit tests'
echo '-------------------------------------------------------------------------------'
status=$SUCCESS
runShellSpec || {
status=$FAILURE
}
cd "$PATH_DIR_RETURN" || {
echo >&2 "Failed to change dir to: ${PATH_DIR_RETURN}"
exit $FAILURE
}
exit $status