-
Notifications
You must be signed in to change notification settings - Fork 9
/
panda
executable file
·96 lines (79 loc) · 1.71 KB
/
panda
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
#!/usr/bin/env bash
_VERSION='0.1.1'
_ME=$(basename "${0}")
BANNER=$(cat <<HEREDOC
Elasticsearch Synonyms
Version: ${_VERSION}
Usage:
${_ME} <command> [--command-options] [<arguments>]
${_ME} -h | --help
${_ME} --version
Options:
-h --help Display this help information.
--version Display version information.
Help:
${_ME} help [<command>]
HEREDOC
)
source ./tools/pandalib.sh
__sigint () {
printf '\n'
_abort 'Cancelled'
}
trap __sigint SIGINT
#================================================
desc 'test:pytest' <<EOF
Usage:
${_ME} test:pytest
Description:
Run Python unit tests.
EOF
test:pytest () {
py.test ${@:-} && rc=$? || rc=$?
return $rc
}
#================================================
desc 'test:install' <<EOF
Usage:
${_ME} test:install
Description:
Run PIP install.
EOF
test:install () {
python setup.py -q develop ${@:-} && rc=$? || rc=$?
return $rc
}
#================================================
desc 'test:dataset' <<EOF
Usage:
${_ME} test:dataset
Description:
Validate synonym datasets
EOF
test:dataset () {
python -m es_synonyms ./data/* && rc=$? || rc=$?
return $rc
}
#================================================
desc 'test:all' <<HEREDOC
Usage:
${_ME} test:all
Description:
Run all tests.
HEREDOC
test:all () {
local steps=('test:pytest' 'test:dataset' 'test:install')
local _lenstep=${#steps[@]}
local _failure=0
for (( i = 0; i < $_lenstep; i++ )); do
_info "[$(($i + 1)) / $_lenstep] Running ${steps[$i]}"
${steps[$i]} || _failure=$(($_failure + 1))
done
if [ $_failure -eq 0 ]; then
_success 'All tests passing'
else
_abort "$_failure of $_lenstep tests failed"
fi
}
#================================================
_main