Skip to content

Commit a22ffdd

Browse files
committed
Add a shell script for running tests via jep
1 parent 1cb6bdf commit a22ffdd

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

bin/jep-test.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
# Executes the pytest framework through JEP via jgo, so that
4+
# the surrounding JVM includes scijava-table on the classpath.
5+
#
6+
# Arguments to this shell script are translated into an argument
7+
# list to the pytest.main function. A weak attempt at handling
8+
# special characters, e.g. single quotation marks and backslashes,
9+
# is made, but there are surely other non-working cases.
10+
#
11+
# Usage examples:
12+
# bin/jep-test.sh
13+
# bin/jep-test.sh tests/test_basics.py
14+
# bin/jep-test.sh tests/test_convert.py::TestConvert::test2DStringArray
15+
16+
if [ $# -gt 0 ]
17+
then
18+
a=$(echo "$@" | sed 's/\\/\\\\/g') # escape backslashes
19+
a=$(echo "$a" | sed 's/'\''/\\'\''/g') # escape single quotes
20+
a=$(echo "$a" | sed 's/ /'\'','\''/g') # replace space with ','
21+
argString="['$a']"
22+
else
23+
argString=""
24+
fi
25+
echo "import pytest; import sys; pytest.main($argString)" > jep_test.py
26+
jgo -Djava.library.path="$CONDA_PREFIX/lib/python3.10/site-packages/jep" black.ninia:jep:jep.Run+org.scijava:scijava-table jep_test.py
27+
rm jep_test.py

0 commit comments

Comments
 (0)