-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define expected tests output based on GraalVM version
- Loading branch information
Showing
2 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...e-maven-plugin/src/testFixtures/groovy/org/graalvm/buildtools/maven/GraalVMSupport.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.graalvm.buildtools.maven | ||
|
||
class GraalVMSupport { | ||
|
||
static String getJavaHomeVersionString() { | ||
String javaHomeLocation = System.getenv("JAVA_HOME") | ||
return extractVersionString(javaHomeLocation) | ||
} | ||
|
||
static String getGraalVMHomeVersionString() { | ||
String graalvmHomeLocation = System.getenv("GRAALVM_HOME") | ||
return extractVersionString(graalvmHomeLocation) | ||
} | ||
|
||
private static String extractVersionString(String location) { | ||
def sout = new StringBuilder(), serr = new StringBuilder() | ||
String command = getSystemBasedCommand(location); | ||
def proc = command.execute() | ||
proc.consumeProcessOutput(sout, serr) | ||
proc.waitForOrKill(1000) | ||
assert serr.toString().isEmpty() | ||
|
||
return sout.toString() | ||
} | ||
|
||
private static String getSystemBasedCommand(String location) { | ||
if (System.getProperty("os.name", "unknown").contains("Windows")) { | ||
return location + '\\bin\\native-image.cmd --version' | ||
} else { | ||
return location + '/bin/native-image --version' | ||
} | ||
} | ||
} |