-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtest_framework.sh
More file actions
60 lines (53 loc) · 1002 Bytes
/
test_framework.sh
File metadata and controls
60 lines (53 loc) · 1002 Bytes
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
#!/usr/bin/env bash
#
# Shared test framework for gigalixir buildpack repos.
#
# Prerequisites (must be set before sourcing):
# SCRIPT_DIR - absolute path to the test/ directory
# REPO_NAME - name used in the mktemp template
#
ROOT_DIR=$(dirname "$SCRIPT_DIR")
PASSED_ALL_TESTS=false
ECHO_CONTENT=()
# make a temp dir for test files/directories
TEST_DIR=$(mktemp -d -t "${REPO_NAME}_XXXXXXXXXX")
cleanup() {
rm -rf ${TEST_DIR}
if $PASSED_ALL_TESTS; then
/bin/echo -e " \e[0;32mTest Suite PASSED\e[0m"
else
/bin/echo -e " \e[0;31mFAILED\e[0m"
fi
exit
}
trap cleanup EXIT INT TERM
# stub output functions to suppress noise in tests
output_section() {
true
}
output_line() {
true
}
output_warning() {
true
}
output_stderr() {
true
}
output_indent() {
cat > /dev/null
}
# helper functions
test() {
reset_test
failed=false
ECHO_CONTENT=()
/bin/echo " TEST: $@"
}
suite() {
failed=false
/bin/echo -e "\e[0;36mSUITE: $@\e[0m"
}
reset_test() {
true
}