-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.sh
executable file
·73 lines (60 loc) · 1.9 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
73
#!/bin/bash
# Copied from pico-boots-demo/test.sh
# Configuration
game_src_path="$(dirname "$0")/src"
game_config_path="$(dirname "$0")/config"
picoboots_scripts_path="$(dirname "$0")/pico-boots/scripts"
help() {
echo "Test game modules with busted
This is essentially a proxy script for pico-boots/scripts/test_scripts.sh that avoids
passing src/FOLDER every time we want to test a group of scripts in the game.
It doesn't prepend the engine path though, so if you want to test engine folders easily,
use pico-boots/test.sh instead.
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 game folder to test.
Path is relative to src. Sub-folders are supported.
(optional)
-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 game src, so prepend it before passing to actual test script
for folder in "${folders[@]}"; do
roots+=("\"$game_src_path/$folder\"")
done
else
# No folder passed, test the whole game folder
roots=("\"$game_src_path\"")
fi
# Add extra lua root 'src' to enable require for game scripts
"$picoboots_scripts_path/test_scripts.sh" ${roots[@]} --lua-root src -c "$game_config_path/.luacov_game" $@