This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest
executable file
·103 lines (86 loc) · 2.38 KB
/
test
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# run script/test -h for help
# COLORS
OFF='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
set -e
function usage()
{
echo -e "\t ================== script/test usage =================="
echo -e "\t-h --help : displays help message"
echo -e "\t-k --no-linter : disables linting tests"
echo -e "\t-d --disable-bootstrap : disables bootstrap"
echo -e "\n\t Suggested flags for development: script/test -d"
}
while [ "$1" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
case $PARAM in
-h | --help)
usage
exit
;;
-k | --no-linter)
no_linter=1
;;
-d | --disable-bootstrap)
no_bootstrap=1
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
usage
exit 1
;;
esac
shift
done
# setup
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
[ -z "$RBENV_VERSION" ] && export RBENV_VERSION=$(cat "$DIR/.ruby-version")
if [[ -z $no_bootstrap ]]; then
# bootstrap
echo -e "\n🥾 ${BLUE}Bootstrapping: $(date "+%H:%M:%S")${OFF}\n"
cd "$DIR"
script/bootstrap
else
echo -e "\n⏩ ${BLUE}Skipping Bootstrap${OFF}"
fi
# Run Rubocop
if [[ -z $no_linter ]]; then
echo -e "\n🤖 ${BLUE}Running Rubocop: $(date "+%H:%M:%S")${OFF}\n"
bundle exec bin/rubocop
else
echo -e "\n⏩ ${BLUE}Skipping Rubocop${OFF}"
fi
# run tests
echo -e "\n🧪 ${BLUE}Running tests: $(date "+%H:%M:%S")${OFF}\n"
cd "$(dirname $0)/.."
bundle exec bin/rspec spec && rspec_exit=$? || rspec_exit=$?
total_coverage=$(cat "$DIR/coverage/total-coverage.txt")
if grep -q "100.0" "$DIR/coverage/total-coverage.txt"; then
cov_exit=0
echo -e "\n✅ Total Coverage: ${GREEN}$total_coverage${OFF}"
else
cov_exit=1
echo -e "\n❌ Total Coverage: ${RED}$total_coverage${OFF}"
fi
echo ""
echo "---------------------------------------"
echo "📊 Summary Results"
echo "---------------------------------------"
echo ""
if [[ $rspec_exit == 0 ]]; then
echo -e "✅ ${GREEN}rspec: exitcode=${rspec_exit}${OFF}"
else
echo -e "❌ ${RED}rspec: exitcode=${rspec_exit}${OFF}"
fi
if [[ $cov_exit == 0 ]]; then
echo -e "✅ ${GREEN}coverage: exitcode=${cov_exit}${OFF}"
else
echo -e "❌ ${RED}coverage: exitcode=${cov_exit}${OFF}"
fi
[ $rspec_exit -gt 0 ] && exit 1
[ $cov_exit -gt 0 ] && exit 1
exit 0