Skip to content

Commit

Permalink
feat(fs): support for copyFile methods
Browse files Browse the repository at this point in the history
- feat: implement `copyFile` methods in `fs` and `fs/promises`
- feat: initial `GuestExecutor` support
- feat: guest executor infra
- test: add tests for `copyFile` methods
- fix: reduce requisite syscalls for file reads
- fix: encoding parameter should default to utf8 for `readFile`
- fix: bugfixes for behavior in callback behavior for `fs`
- fix: support for UTF-32 in `fs` module
- fix: js error handling in `fs` module
- fix: dependency base for gvm tests with executor
- chore: update `runtime` module with new facade exports
- chore: unwire direct executor from `fs`
- chore: update `graalvm` module pin
- chore: wire in guest executors

Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Jul 6, 2024
1 parent 5174091 commit a8dddbd
Show file tree
Hide file tree
Showing 36 changed files with 1,743 additions and 308 deletions.
20 changes: 20 additions & 0 deletions packages/engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import elide.internal.conventions.publishing.publish

plugins {
kotlin("jvm")
kotlin("kapt")
kotlin("plugin.serialization")
alias(libs.plugins.micronaut.minimal.library)
alias(libs.plugins.micronaut.graalvm)
Expand Down Expand Up @@ -54,4 +55,23 @@ dependencies {
api(libs.graalvm.polyglot)
implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.serialization.json)

testApi(projects.packages.base)
testApi(projects.packages.graalvm)
testAnnotationProcessor(mn.micronaut.inject.java)
}

val testInternals by configurations.registering {
extendsFrom(configurations.testImplementation.get())
isCanBeConsumed = true
isCanBeResolved = false
}

val testJar by tasks.registering(Jar::class) {
archiveBaseName.set("engine-test")
from(sourceSets.test.get().output)
}

artifacts {
add(testInternals.name, testJar)
}
1 change: 1 addition & 0 deletions packages/engine/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>ForbiddenComment:AbstractLanguageConfig.kt$AbstractLanguageConfig$// @TODO: don't unconditionally mount all members</ID>
<ID>MatchingDeclarationName:GuestTestExecutor.kt$GuestTestExecutorFactory : GuestExecutorProvider</ID>
<ID>ReturnCount:Version.kt$Version$public override operator fun compareTo(other: Version): Int</ID>
<ID>TooGenericExceptionThrown:AbstractLanguagePlugin.kt$AbstractLanguagePlugin$throw Exception("Failed to resolve language resources with key $manifestKey for language $languageId", cause)</ID>
</CurrentIssues>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package elide.runtime.gvm.test

import io.micronaut.context.annotation.Requires
import elide.annotations.Eager
import elide.annotations.Factory
import elide.annotations.Singleton
import elide.runtime.gvm.GuestExecution
import elide.runtime.gvm.GuestExecutor
import elide.runtime.gvm.GuestExecutorProvider

/**
* Guest Test Executor Factory
*
* Initializes a direct executor for use during test execution.
*/
@Requires(env = ["test"])
@Eager @Factory internal class GuestTestExecutorFactory : GuestExecutorProvider {
@Singleton override fun executor(): GuestExecutor = GuestExecution.direct()
}
1 change: 1 addition & 0 deletions packages/graalvm-py/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ dependencies {
kaptTest(mn.micronaut.inject.java)
testImplementation(projects.packages.test)
testImplementation(projects.packages.graalvm)
testApi(project(":packages:engine", configuration = "testInternals"))
testImplementation(project(":packages:graalvm", configuration = "testBase"))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package elide.runtime.gvm
import org.graalvm.polyglot.Value
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
import kotlinx.coroutines.test.runTest
import elide.runtime.core.DelicateElideApi
import elide.runtime.core.PolyglotContext
import elide.runtime.core.PolyglotEngineConfiguration
Expand All @@ -32,7 +33,7 @@ abstract class PythonTest : AbstractDualTest<AbstractDualTest.Python>() {
}

@Suppress("SameParameterValue")
private fun executeGuestInternal(ctx: PolyglotContext, bindUtils: Boolean, op: Python,): Value {
private fun executeGuestInternal(ctx: PolyglotContext, bindUtils: Boolean, op: Python): Value {
// resolve the script
val script = op.invoke(ctx)

Expand Down Expand Up @@ -71,8 +72,8 @@ abstract class PythonTest : AbstractDualTest<AbstractDualTest.Python>() {
}

// Run the provided `op` on the host, and the provided `guest` via `executeGuest`.
override fun dual(bind: Boolean, op: () -> Unit): DualTestExecutionProxy<Python> {
op.invoke()
override fun dual(bind: Boolean, op: suspend () -> Unit): DualTestExecutionProxy<Python> {
runTest { op.invoke() }
return object : DualTestExecutionProxy<Python>() {
override fun guest(guestOperation: Python) = GuestTestExecution(::withContext) {
executeGuestInternal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.graalvm.polyglot.Value
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
import java.util.function.Function
import kotlinx.coroutines.test.runTest
import elide.runtime.core.DelicateElideApi
import elide.runtime.core.PolyglotContext
import elide.runtime.core.PolyglotEngineConfiguration
Expand Down Expand Up @@ -79,8 +80,8 @@ abstract class AbstractPythonIntrinsicTest<T : GuestIntrinsic> : AbstractIntrins
}

// Run the provided `op` on the host, and the provided `guest` via `executeGuest`.
override fun dual(bind: Boolean, op: () -> Unit): DualTestExecutionProxy<Python> {
op.invoke()
override fun dual(bind: Boolean, op: suspend () -> Unit): DualTestExecutionProxy<Python> {
runTest { op.invoke() }
return object : DualTestExecutionProxy<Python>() {
override fun guest(guestOperation: Python) = GuestTestExecution(::withContext) {
executeGuestInternal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package elide.runtime.gvm
import org.graalvm.polyglot.Value
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
import kotlinx.coroutines.test.runTest
import elide.runtime.core.DelicateElideApi
import elide.runtime.core.PolyglotContext
import elide.runtime.core.PolyglotEngineConfiguration
Expand Down Expand Up @@ -75,8 +76,8 @@ ctx: PolyglotContext,
}

// Run the provided `op` on the host, and the provided `guest` via `executeGuest`.
override fun dual(bind: Boolean, op: () -> Unit): DualTestExecutionProxy<Ruby> {
op.invoke()
override fun dual(bind: Boolean, op: suspend () -> Unit): DualTestExecutionProxy<Ruby> {
runTest { op.invoke() }
return object : DualTestExecutionProxy<Ruby>() {
override fun guest(guestOperation: Ruby) = GuestTestExecution(::withContext) {
executeGuestInternal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.graalvm.polyglot.Value
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
import java.util.function.Function
import kotlinx.coroutines.test.runTest
import elide.runtime.core.DelicateElideApi
import elide.runtime.core.PolyglotContext
import elide.runtime.core.PolyglotEngineConfiguration
Expand Down Expand Up @@ -85,8 +86,8 @@ ctx: PolyglotContext,
}

// Run the provided `op` on the host, and the provided `guest` via `executeGuest`.
override fun dual(bind: Boolean, op: () -> Unit): DualTestExecutionProxy<Ruby> {
op.invoke()
override fun dual(bind: Boolean, op: suspend () -> Unit): DualTestExecutionProxy<Ruby> {
runTest { op.invoke() }
return object : DualTestExecutionProxy<Ruby>() {
override fun guest(guestOperation: Ruby) = GuestTestExecution(::withContext) {
executeGuestInternal(
Expand Down
5 changes: 5 additions & 0 deletions packages/graalvm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# `graalvm`

Main logic module for Elide's integration points with GraalVM.


Loading

0 comments on commit a8dddbd

Please sign in to comment.