-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwrapper.sh
executable file
·92 lines (72 loc) · 1.29 KB
/
wrapper.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# Variables
jshu=$(dirname $(readlink -f "${BASH_SOURCE:-${0}}"))
result=1
# Wrapper modes
case "${1}" in
# Load mode
--load)
# Configure bash
set +e
set +x
# Import jshu
source "${jshu}/jshutest.inc"
# Configure tests package
jshu_pkgname="${2}"
# Start tests
if [ ! -z "${WORKSPACE}" ] && [ -z "${BUILDDIR}" ]; then
BUILDDIR=${WORKSPACE} jshuInit "${3}" "${4}"
else
jshuInit "${3}" "${4}"
fi
# Declare Test function
function Test() {
# Variables
local result
# Create test runner
source <(
cat <<END_OF_TEST
function TestRunner()
{
# Test title
test_title="${1}";
# Test executions
$(cat)
}
END_OF_TEST
)
# Run test
jshu_run_test TestRunner
result=${?}
# Cleanup
unset TestRunner
# Result
return "${result}"
}
# Result
result=0
;;
# Test mode
--test)
# Prepare test name for file name
jshu_test_tag=${4//./_}
jshu_test_tag=${jshu_test_tag// /_}
# Load jshu wrapper
source "${jshu}/wrapper.sh" --load "${2}" "${3}" "${jshu_test_tag}"
# Run single test
Test "${4}" <<§
$(cat)
§
result=${?}
# Finish jshu wrapper
source "${jshu}/wrapper.sh" --finish
;;
# Finish mode
--finish)
# Finalize tests
jshuFinalize
result=${?}
;;
esac
# Result
(exit "${result}")