-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.sh
executable file
·55 lines (40 loc) · 1.54 KB
/
tests.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
#!/usr/bin/env bash
# Run tests on the yaml-get.py script from the command line.
#----------------------------------------------------------------------------
# Set up vars.
ASSERT_LIB="tmp/assert.sh"
TARGET="./yaml-get.py"
YAML_FILE="test.yaml"
#----------------------------------------------------------------------------
# Grab a copy of assert.sh if not already present and make it executable.
# Import the assertion functions. Create a temp yaml file to operate on.
function setup {
local DESTINATION="$(dirname "$ASSERT_LIB")"
if [[ ! -d "$DESTINATION" ]]; then
mkdir -p "$DESTINATION"
fi
if [[ ! -x "$ASSERT_LIB" ]]; then
wget -qO "$ASSERT_LIB" https://raw.github.com/lehmannro/assert.sh/v1.1/assert.sh
chmod a+x "$ASSERT_LIB"
fi
source "$ASSERT_LIB"
}
#----------------------------------------------------------------------------
# Wrapper to execute the target script uniformly in all tests. Always provides
# the same sample YAML document to the script.
# Usage: `execute dotted.path`
function execute {
echo "cat '$YAML_FILE' | '$TARGET' $1"
}
#----------------------------------------------------------------------------
# main()
setup
assert "$(execute name)" "Foo.app"
assert "$(execute directories.source)" "./src"
assert "$(execute debug.includes.0)" "./debug"
assert "$(execute debug.enabled)" "True"
assert "$(execute description)" "This is a great app. It can do many things. You should try it."
assert_raises "$(execute foo)" 0
assert_raises "$(execute )" 1
assert_raises "$(execute bad.path)" 2
assert_end "yaml-get.py"