Skip to content

Commit d3e3984

Browse files
committed
test: add tests to check pynml fails when wrong files are provided
Fixes #406
1 parent 71d8ae8 commit d3e3984

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Diff for: test-ghactions.sh

+39
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1+
# note that set -e is flimsy
2+
# http://mywiki.wooledge.org/BashFAQ/105
13
set -e
24

35
# CI already installs package and all optional dependencies, so this is redundant.
46
# But we keep it to allow easy local testing.
57
pip install .[dev]
68

9+
# required to test commands that should fail
10+
# need this because other constructs don't work:
11+
# - command || or && does not check that command has failed
12+
# - ! command does not make script error even with set -e because this is considered to be handled
13+
check_should_fail() {
14+
if [ $? -ne 0 ]; then
15+
echo "TEST PASSED: Command failed as expected."
16+
return 0
17+
else
18+
echo "TEST ERROR: Command should have failed!"
19+
exit 1
20+
fi
21+
}
22+
23+
724
echo
825
echo "################################################"
926
echo "## Testing all CLI tools"
@@ -101,6 +118,28 @@ pynml LEMS_NML2_Ex9_FN.xml -spineml
101118
pynml LEMS_NML2_Ex9_FN.xml -sbml
102119

103120

121+
echo
122+
echo "################################################"
123+
echo "## Test wrong file types"
124+
125+
set +e
126+
127+
# these should fail, but we need to check them explicity because constructs
128+
# like `! command` are not recognised by `set -e`
129+
pynml NML2_SingleCompHHCell.nml ; check_should_fail
130+
pynml NML2_SingleCompHHCell.nml -dlems ; check_should_fail
131+
pynml NML2_SingleCompHHCell.nml -brian ; check_should_fail
132+
pynml NML2_SingleCompHHCell.nml -cvode ; check_should_fail
133+
pynml NML2_SingleCompHHCell.nml -sbml ; check_should_fail
134+
pynml NML2_SingleCompHHCell.nml -matlab ; check_should_fail
135+
pynml -validate LEMS_NML2_Ex9_FN.xml ; check_should_fail
136+
pynml LEMS_NML2_Ex9_FN.xml -swc ; check_should_fail
137+
pynml LEMS_NML2_Ex9_FN.xml -png ; check_should_fail
138+
pynml -validate test_data/valid_doc.sbml ; check_should_fail
139+
pynml LEMS_NML2_Ex9_FN.xml -validate-sbml ; check_should_fail
140+
141+
set -e
142+
104143
echo
105144
echo "################################################"
106145
echo "## Simple SBML validation example"

0 commit comments

Comments
 (0)