-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·69 lines (61 loc) · 1.18 KB
/
make.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
#!/bin/sh
USAGE=$(cat << END
make.sh [-h | --help] command [args...]
commands:
tests run tests; args will be propagated to unittest discover
generate [polygen | *]
generate parser;
if "polygen" arg is passed, then regenerates polygen parser
otherwise args are propagated to the polygen
options:
-h | --help print help message and exit
END
)
function usage {
echo "$USAGE"
}
function run_tests {
python -m unittest discover "$@" tests
local exitcode=$1
if [[ $exitcode -ne 0 ]]; then
exit $exitcode
fi
# python tests/test_equivalency.py
exit $?
}
function run_generate {
if [ "$1" = "polygen" ];
then
shift
python -m polygen generate polygen/grammar.peg -b python -o polygen \
-d polygen_imports=true $@
exit $?
fi
python -m polygen generate $@
exit $?
}
while [[ $# -gt 0 ]]; do
case $1 in
tests)
shift
run_tests $@
;;
generate)
shift
run_generate $@
;;
-h|--help)
usage
exit 0
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
echo "Unknown command $1"
exit 1
;;
esac
done
usage