Skip to content

Commit d4f76a0

Browse files
robertpatrickjeff5
authored andcommitted
Update test of Jython launcher to later Java versions
1 parent 20abf42 commit d4f76a0

1 file changed

Lines changed: 48 additions & 8 deletions

File tree

tests/shell/test-jython.sh

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,29 @@ SPACE_DIR="$TEST_DIR/directory with spaces"
1212

1313
cp -Rp "$1" "$SPACE_DIR"
1414

15+
java_major_version() {
16+
local output version major
17+
output="$("$1" -J-version 2>&1)"
18+
version=`expr "$output" : '.*version "\([^"]*\)"'`
19+
case "$version" in
20+
1.*)
21+
major=${version#1.}
22+
major=${major%%.*}
23+
;;
24+
*)
25+
major=${version%%[!0-9]*}
26+
;;
27+
esac
28+
echo "$major"
29+
}
30+
1531
for JYTHON_HOME in "$SPACE_DIR" "$1" ; do
1632
JYTHON="$JYTHON_HOME/bin/jython"
1733
export JYTHON_HOME
1834
set -ex
1935

2036
# -J passthrough
21-
"$JYTHON" -J-version 2>&1 | [ `egrep -c "^java version "` == 1 ]
37+
"$JYTHON" -J-version 2>&1 | [ `egrep -c "^(java|openjdk) version "` == 1 ]
2238

2339
# Jython reports version
2440
"$JYTHON" --version 2>&1 | [ `egrep -c "^Jython "` == 1 ]
@@ -41,23 +57,47 @@ for JYTHON_HOME in "$SPACE_DIR" "$1" ; do
4157
# Jython executable (don't include newline in case it's \r\n)
4258
[ `"$JYTHON" -c 'import sys; print sys.executable is not None,'` == True ]
4359

60+
JAVA_MAJOR=`java_major_version "$JYTHON"`
61+
4462
# JDB
45-
echo run | "$JYTHON" --jdb -c "print '\ntest'" | [ `egrep -c "^test"` == 1 ]
63+
JDB_OUTPUT="$TEST_DIR/jdb.out"
64+
set +e
65+
(echo run; sleep 3) | "$JYTHON" --jdb -c "print '\ntest'" > "$JDB_OUTPUT" 2>&1
66+
JDB_STATUS=$?
67+
set -e
68+
if [ `egrep -c "^test" "$JDB_OUTPUT"` == 1 ] ; then
69+
:
70+
else
71+
cat "$JDB_OUTPUT" >&2
72+
[ "$JDB_STATUS" -ne 0 ] && exit "$JDB_STATUS"
73+
exit 1
74+
fi
4675

4776
# Jython profiling
48-
"$JYTHON" --profile -c pass 2>&1 | \
49-
[ `egrep -c "^\| Thread depth limit:"` == 1 ]
50-
[ -f profile.txt ] && rm profile.txt
77+
if [ "$JAVA_MAJOR" -lt 13 ] ; then
78+
"$JYTHON" --profile -c pass 2>&1 | \
79+
[ `egrep -c "^\| Most expensive methods"` -ge 1 ]
80+
[ -f profile.txt ] && rm profile.txt
81+
else
82+
"$JYTHON" --profile -c pass 2>&1 | \
83+
[ `egrep -c "^--profile is not supported on Java $JAVA_MAJOR;"` == 1 ]
84+
fi
5185

5286
# $CLASSPATH
5387
CLASSPATH="$JYTHON_HOME/Lib/test/blob.jar" \
5488
"$JYTHON" -c "print __import__('Blob')" | \
5589
[ `egrep -c "Blob"` == 1 ]
5690

5791
# $CLASSPATH + profiling
58-
CLASSPATH="$JYTHON_HOME/Lib/test/blob.jar" \
59-
"$JYTHON" --profile -c "print __import__('Blob')" | \
60-
[ `egrep -c "Blob"` == 1 ]
92+
if [ "$JAVA_MAJOR" -lt 13 ] ; then
93+
CLASSPATH="$JYTHON_HOME/Lib/test/blob.jar" \
94+
"$JYTHON" --profile -c "print __import__('Blob')" | \
95+
[ `egrep -c "Blob"` == 1 ]
96+
else
97+
CLASSPATH="$JYTHON_HOME/Lib/test/blob.jar" \
98+
"$JYTHON" --profile -c "print __import__('Blob')" 2>&1 | \
99+
[ `egrep -c "^--profile is not supported on Java $JAVA_MAJOR;"` == 1 ]
100+
fi
61101

62102
set +ex
63103
done

0 commit comments

Comments
 (0)