Skip to content

Commit 4a1bc1d

Browse files
committed
Fix netCDF-Java regression testing workflow
The netCDF-Java regression testing workflow broke when netCDF-Java upgraded to gradle 9.x (Unidata/netcdf-java#1501). This fixes the regression test script to restore the netCDF-java testing functionalty.
1 parent f96bf42 commit 4a1bc1d

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests-regression/run_netcdf_tests.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,17 +639,38 @@ fi
639639
if [ "x$RUNJAVA" == "xTRUE" ]; then
640640
echo -e "o Testing netcdf-java"
641641

642+
MINIMUM_BUILD_JDK="17"
643+
MINIMUM_TEST_JDK="8"
644+
645+
# install the JDK requested to run the tests with
642646
${SUDOCMD} apt update && sudo apt install -y openjdk-${JDKVER}-jdk
647+
648+
# ensure the minimum build version of the JDK is installed to run gradle
649+
# install after the requested test JDK to ensure it is the active JDK when running the gradle command
650+
if [ "$JDKVER" != "$MINIMUM_BUILD_JDK" ]; then
651+
${SUDOCMD} apt update && sudo apt install -y openjdk-${MINIMUM_BUILD_JDK}-jdk
652+
fi
653+
654+
# set test task name
655+
TEST_TASK="testWithJdk$JDKVER"
656+
if [ "$JDKVER" == "$MINIMUM_TEST_JDK" ]; then
657+
TEST_TASK="test"
658+
fi
659+
643660
cd ${WORKING_DIRECTORY}/netcdf-java
644661

662+
# allow gradle to auto-detect JDK versions
663+
AUTO_DETECT_KEY="org.gradle.java.installations.auto-detect"
664+
sed -i -e "s/${AUTO_DETECT_KEY}.*/${AUTO_DETECT_KEY}=true/g" ${WORKING_DIRECTORY}/netcdf-java/gradle.properties
665+
645666
GRADLE_OPTS="-DrunSlowTests=True"
646667
if [ -d "/share/testdata/cdmUnitTest" ]; then
647668
GRADLE_OPTS="${GRADLE_OPTS} -Dunidata.testdata.path=/share/testdata"
648669
fi
649670

650671
# run netCDF-Java tests that rely on the netCDF-C library
651672
# and do not trigger trap on failure
652-
JNA_PATH=${LIBDIR} ./gradlew ${GRADLE_OPTS} clean :netcdf4:test ; CHECKERRJAVA
673+
JNA_PATH=${LIBDIR} ./gradlew ${GRADLE_OPTS} clean :netcdf4:${TEST_TASK} ; CHECKERRJAVA
653674

654675

655676
cd ${WORKING_DIRECTORY}

0 commit comments

Comments
 (0)