Skip to content

Commit 76ed6a9

Browse files
authored
Update run test.sh (#72)
1 parent e34e077 commit 76ed6a9

File tree

1 file changed

+72
-24
lines changed

1 file changed

+72
-24
lines changed

run_test.sh

100755100644
Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#!/bin/bash
22

3-
read -rd "\000" helpmessage <<EOF
4-
$(basename $0): Run common workflow tool description language conformance tests.
3+
func() {
4+
helpmessage=$(cat)
5+
}
6+
func <<EOF
7+
$(basename "$0"): Run common workflow tool description language conformance tests.
58
69
Syntax:
7-
$(basename $0) [RUNNER=/path/to/cwl-runner]
10+
$(basename "$0") [RUNNER=/path/to/cwl-runner]
811
[EXTRA=--optional-arguments-to-cwl-runner]
912
1013
Options:
@@ -17,24 +20,33 @@ Options:
1720
FILENAME
1821
--classname=CLASSNAME In the JUnit XML, tag the results with the given
1922
CLASSNAME
23+
--timeout=TIMEOUT cwltest timeout in seconds.
2024
--verbose Print the cwltest invocation and pass --verbose to
2125
cwltest
26+
--self Test CWL and test .cwl files themselves. If this flag
27+
is given, any other flags will be ignored.
28+
--badgedir=DIRNAME Specifies the directory to store JSON files for badges.
29+
--tags TAGS Tags to be tested
2230
2331
Note:
2432
EXTRA is useful for passing --enable-dev to the CWL reference runner:
2533
Example: RUNNER=cwltool EXTRA=--enable-dev
2634
EOF
2735

36+
CWL_VER=v1.2
2837
TEST_N=""
2938
JUNIT_XML=""
3039
RUNNER=cwl-runner
3140
PLATFORM=$(uname -s)
32-
COVERAGE="python"
3341
EXTRA=""
3442
CLASS=""
3543
VERBOSE=""
44+
SELF=""
45+
BADGE=""
46+
TIMEOUT=""
47+
TAGS=""
3648

37-
while [[ -n "$1" ]]
49+
while [ -n "$1" ]
3850
do
3951
arg="$1"; shift
4052
case "$arg" in
@@ -64,13 +76,44 @@ do
6476
--verbose)
6577
VERBOSE=$arg
6678
;;
79+
--self)
80+
SELF=1
81+
;;
82+
--badgedir=*)
83+
BADGE=$arg
84+
;;
85+
--timeout=*)
86+
TIMEOUT=$arg
87+
;;
88+
--tags=*)
89+
TAGS=$arg
90+
;;
6791
*=*)
68-
eval $(echo $arg | cut -d= -f1)=\"$(echo $arg | cut -d= -f2-)\"
92+
eval "$(echo "$arg" | cut -d= -f1)"=\""$(echo "$arg" | cut -d= -f2-)"\"
6993
;;
7094
esac
7195
done
7296

73-
if ! runner="$(which $RUNNER)" ; then
97+
if [ -n "${SELF}" ]; then
98+
# Ensure schema-salad-tool command
99+
if [ ! -x "$(command -v schema-salad-tool)" ]; then
100+
pip install --quiet schema_salad
101+
fi
102+
# This is how CWL should be written.
103+
DEFINITION=./CommonWorkflowLanguage.yml
104+
# Let's test each files
105+
find tests -type f -name "*.cwl" | \
106+
while read -r target;
107+
do
108+
schema-salad-tool ${DEFINITION} "${target}" --quiet || {
109+
echo "[INVALID] ${target}"
110+
exit 1
111+
}
112+
done
113+
exit 0
114+
fi
115+
116+
if ! runner="$(command -v $RUNNER)" ; then
74117
echo >&2 "$helpmessage"
75118
echo >&2
76119
echo >&2 "runner '$RUNNER' not found"
@@ -80,40 +123,45 @@ fi
80123
runs=0
81124
failures=0
82125

83-
checkexit() {
84-
if [[ "$?" != "0" ]]; then
85-
failures=$((failures+1))
86-
fi
87-
}
88-
89126
runtest() {
90-
echo "--- Running CWL Conformance Tests on $1 ---"
127+
echo "--- Running CWL Conformance Tests $CWL_VER on $1 ---"
91128

92129
"$1" --version
93130

94131
runs=$((runs+1))
95132
(COMMAND="cwltest --tool $1 \
96-
--test=conformance_tests.yaml ${CLASS} ${TEST_N} \
97-
${VERBOSE} ${TEST_L} ${TEST_J} ${ONLY_TOOLS} ${JUNIT_XML} \
98-
-- ${EXTRA}"
99-
if [[ $VERBOSE == "--verbose" ]]; then echo ${COMMAND}; fi
133+
--test=conformance_tests.yaml ${CLASS} ${TEST_N} \
134+
${VERBOSE} ${TEST_L} ${TEST_J} ${ONLY_TOOLS} ${JUNIT_XML} \
135+
${TIMEOUT} ${BADGE} ${TAGS} -- ${EXTRA}"
136+
if [ "$VERBOSE" = "--verbose" ]; then echo "${COMMAND}"; fi
100137
${COMMAND}
101-
)
102-
checkexit
138+
) || failures=$((failures+1))
103139
}
104140

105-
if [[ $PLATFORM == "Linux" ]]; then
106-
runtest "$(readlink -f $runner)"
141+
if [ "$PLATFORM" = "Linux" ]; then
142+
runtest "$(readlink -f "$runner")"
107143
else
108-
runtest "$(greadlink -f $runner)"
144+
runtest "$(greadlink -f "$runner")"
109145
fi
110146

111-
if [[ -n "$TEST_L" ]] ; then
147+
if [ -n "$TEST_L" ] ; then
112148
exit 0
113149
fi
114150

115151
# Final reporting
116152

117153
echo
118154

155+
if [ $failures != 0 ]; then
156+
echo "$failures tool tests failed"
157+
else
158+
if [ $runs = 0 ]; then
159+
echo >&2 "$helpmessage"
160+
echo >&2
161+
exit 1
162+
else
163+
echo "All tool tests succeeded"
164+
fi
165+
fi
166+
119167
exit $failures

0 commit comments

Comments
 (0)