Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update graaljs #1949

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ googleGson = "2.9.0"
googleProtobuf = "3.21.9"
googleProtobufPlugin = "0.9.1"
googleTruth = "1.4.2"
graaljs = "22.0.0" # Latest version that supports Java 8
graaljs = "23.0.5"
grpc = "1.50.2"
grpcKotlinStub = "1.3.0"
imageComparison = "4.4.0"
Expand Down
3 changes: 3 additions & 0 deletions maestro-client/src/main/java/maestro/js/GraalJsEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import java.io.ByteArrayOutputStream
import java.util.concurrent.TimeUnit
import java.util.logging.Handler
import java.util.logging.LogRecord
import org.graalvm.polyglot.HostAccess

private val NULL_HANDLER = object : Handler() {
override fun publish(record: LogRecord?) {}
Expand Down Expand Up @@ -82,6 +83,8 @@ class GraalJsEngine(

val context = Context.newBuilder("js")
.option("js.strict", "true")
.allowHostAccess(HostAccess.ALL)
.allowHostClassLookup { true }
.logHandler(NULL_HANDLER)
.out(outputStream)
.build()
Expand Down
9 changes: 8 additions & 1 deletion maestro-test/src/test/kotlin/maestro/test/IntegrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2712,10 +2712,16 @@ class IntegrationTest {
// given
val commands = readCommands("102_graaljs")
val driver = driver { }
val receivedLogs = mutableListOf<String>()

// when
Maestro(driver).use {
orchestra(it).runFlow(commands)
orchestra(
it,
onCommandMetadataUpdate = { _, metadata ->
receivedLogs += metadata.logMessages
}
).runFlow(commands)
}

// then
Expand All @@ -2725,6 +2731,7 @@ class IntegrationTest {
Event.InputText("bar"),
)
)
assertThat(receivedLogs).containsExactly("0.2")
}

@Test
Expand Down
4 changes: 3 additions & 1 deletion maestro-test/src/test/resources/102_graaljs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ jsEngine: graaljs
---
# Note: The ?? operator is an example of an ES2020 feature and is not supported by RhinoJS
- inputText: ${null ?? 'foo'}
- runFlow: 102_graaljs_subflow.yaml
- runFlow: 102_graaljs_subflow.yaml
- runScript:
file: 102_graaljs_script.js
3 changes: 3 additions & 0 deletions maestro-test/src/test/resources/102_graaljs_script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var BigDec = Java.type('java.math.BigDecimal');
var bd = new BigDec("0.1");
console.log(bd.add(bd).toString());
Loading