-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.sh
executable file
·72 lines (60 loc) · 1.93 KB
/
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
72
#!/bin/bash
# Configuration
picoboots_src_engine_path="$(dirname "$0")/src/engine"
picoboots_config_path="$(dirname "$0")/config"
picoboots_scripts_path="$(dirname "$0")/scripts"
help() {
echo "Test pico-boots modules with busted
This is essentially a proxy script for scripts/test_scripts.sh that avoids
passing src/engine/FOLDER every time we want to test a group of scripts.
Dependencies:
- busted (must be in PATH)
- luacov (must be in PATH)
"
usage
}
usage() {
echo "Usage: test.sh [FOLDER-1 [FOLDER-2 [...]]]
ARGUMENTS
FOLDER Path to engine folder to test.
Path is relative to src/engine. Sub-folders are supported.
(optional)
EXTRA PARAMETERS
Any extra parameter is passed to scripts/test_scripts.sh (besides the ROOT arguments
and --cov-config parameter).
Enter 'scripts/test_scripts.sh --help' (from pico-boots root) for more information.
-h, --help Show this help message
"
}
# Default parameters
folders=()
other_options=()
# Read arguments
# https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
roots=()
while [[ $# -gt 0 ]]; do
case $1 in
-h | --help )
help
exit 0
;;
-* ) # we started adding options
# since we don't support "--" for final positional arguments, just pass all the rest to test_scripts.sh
break
;;
* ) # positional argument: folder
folders+=("$1")
shift # past argument
;;
esac
done
if [[ ${#folders[@]} -ne 0 ]]; then
# Paths are relative to src/engine, so prepend it before passing to actual test script
for folder in "${folders[@]}"; do
roots+=("\"$picoboots_src_engine_path/$folder\"")
done
else
# No folder passed, test the whole engine folder
roots=("\"$picoboots_src_engine_path\"")
fi
"$picoboots_scripts_path/test_scripts.sh" ${roots[@]} -c "$picoboots_config_path/.luacov_engine" $@