Skip to content

Commit 5141de2

Browse files
committed
feat(tests): Add Java version check for bats tests
- Introduced a `_require_java_version` helper function in `agent/test/helper.bash` to allow bats tests to specify a minimum required Java version. Tests will be skipped if the current Java version is below the requirement. - Applied the Java 11 requirement to the `gretty-tomcat` bats tests to ensure they run in a compatible environment.
1 parent ca19ab0 commit 5141de2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

agent/test/gretty-tomcat/gretty-tomcat.bats

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
load '../helper'
44

55
setup_file() {
6+
_require_java_version 11
7+
68
mkdir -p build/log
79

810
export LOG="$(getcwd)/build/log/gretty-tomcat.log"

agent/test/helper.bash

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ export JAVA_VERSION
1414
export JAVA_OUTPUT_OPTIONS="-Xshare:off"
1515

1616

17+
_require_java_version() {
18+
local required_version=$1
19+
if [[ "$(echo -e "$required_version\n$JAVA_VERSION" | sort -V | head -n1)" != "$required_version" ]]; then
20+
skip "Java version $required_version or higher is required (current: $JAVA_VERSION)"
21+
fi
22+
}
23+
1724
_curl() {
1825
curl -sfH 'Accept: application/json,*/*' "${@}"
1926
}

0 commit comments

Comments
 (0)