Use TruffleLogger bound to the engine to prevent illegal usage (#8169)

Using a `TruffleLogger` in `SerializationManager` that is bound to the engine rather than the context prevents reaching an illegal state when using thread pools.

Also cleaned up some tests for consistency.

To verify the fix
```diff
--- a/engine/runtime/src/main/scala/org/enso/compiler/SerializationManager.scala
+++ b/engine/runtime/src/main/scala/org/enso/compiler/SerializationManager.scala
@@ -31,7 +31,7 @@ final class SerializationManager(compiler: Compiler) {
import SerializationManager._

/** The debug logging level. */
-  private val debugLogLevel = Level.FINE
+  private val debugLogLevel = Level.INFO
```
and run
`sbt:enso> runtime/test`

Closes #8147.
This commit is contained in:
Hubert Plociniczak 2023-10-31 09:53:05 +01:00 committed by GitHub
parent 3d23c6a8d0
commit c1c4c8aa18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 192 additions and 63 deletions

View File

@ -8,6 +8,8 @@ import java.io.ByteArrayOutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.logging.Level;
import org.enso.interpreter.EnsoLanguage; import org.enso.interpreter.EnsoLanguage;
import org.enso.interpreter.runtime.EnsoContext; import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.callable.function.Function; import org.enso.interpreter.runtime.callable.function.Function;
@ -68,8 +70,12 @@ public class ThrowableCatchTest {
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)
.logHandler(new ByteArrayOutputStream()) .logHandler(System.err)
.option(RuntimeOptions.STRICT_ERRORS, "true") .option(RuntimeOptions.STRICT_ERRORS, "true")
.option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.option( .option(
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath()) Paths.get("../../distribution/component").toFile().getAbsolutePath())

View File

@ -7,6 +7,8 @@ import java.io.OutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Map; import java.util.Map;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.logging.Level;
import org.enso.interpreter.node.ClosureRootNode; import org.enso.interpreter.node.ClosureRootNode;
import org.enso.interpreter.runtime.tag.AvoidIdInstrumentationTag; import org.enso.interpreter.runtime.tag.AvoidIdInstrumentationTag;
import org.enso.interpreter.runtime.tag.IdentifiedTag; import org.enso.interpreter.runtime.tag.IdentifiedTag;
@ -38,7 +40,11 @@ public class AvoidIdInstrumentationTagTest {
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath() Paths.get("../../distribution/component").toFile().getAbsolutePath()
) )
.logHandler(OutputStream.nullOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)

View File

@ -21,6 +21,7 @@ import org.junit.Test;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
public class WarningInstrumentationTest { public class WarningInstrumentationTest {
@ -35,7 +36,11 @@ public class WarningInstrumentationTest {
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath() Paths.get("../../distribution/component").toFile().getAbsolutePath()
) )
.logHandler(OutputStream.nullOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)

View File

@ -15,6 +15,7 @@ import org.scalatest.matchers.should.Matchers
import java.io.{ByteArrayOutputStream, File} import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths} import java.nio.file.{Files, Path, Paths}
import java.util.UUID import java.util.UUID
import java.util.logging.Level
@scala.annotation.nowarn("msg=multiarg infix syntax") @scala.annotation.nowarn("msg=multiarg infix syntax")
class BuiltinTypesTest class BuiltinTypesTest
@ -37,14 +38,13 @@ class BuiltinTypesTest
val pkg: Package[File] = val pkg: Package[File] =
PackageManager.Default.create(tmpDir.toFile, packageName, "Enso_Test") PackageManager.Default.create(tmpDir.toFile, packageName, "Enso_Test")
val out: ByteArrayOutputStream = new ByteArrayOutputStream() val out: ByteArrayOutputStream = new ByteArrayOutputStream()
val logOut: ByteArrayOutputStream = new ByteArrayOutputStream()
val executionContext = new PolyglotContext( val executionContext = new PolyglotContext(
Context Context
.newBuilder(LanguageInfo.ID) .newBuilder(LanguageInfo.ID)
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowAllAccess(true) .allowAllAccess(true)
.option(RuntimeOptions.PROJECT_ROOT, pkg.root.getAbsolutePath) .option(RuntimeOptions.PROJECT_ROOT, pkg.root.getAbsolutePath)
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true") .option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false") .option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false") .option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
@ -63,7 +63,7 @@ class BuiltinTypesTest
.getAbsolutePath .getAbsolutePath
) )
.option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev") .option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev")
.logHandler(logOut) .logHandler(System.err)
.out(out) .out(out)
.serverTransport(runtimeServerEmulator.makeServerTransport) .serverTransport(runtimeServerEmulator.makeServerTransport)
.build() .build()

View File

@ -15,6 +15,7 @@ import org.scalatest.matchers.should.Matchers
import java.io.{ByteArrayOutputStream, File} import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths} import java.nio.file.{Files, Path, Paths}
import java.util.UUID import java.util.UUID
import java.util.logging.Level
@scala.annotation.nowarn("msg=multiarg infix syntax") @scala.annotation.nowarn("msg=multiarg infix syntax")
class RuntimeAsyncCommandsTest class RuntimeAsyncCommandsTest
@ -42,7 +43,7 @@ class RuntimeAsyncCommandsTest
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowAllAccess(true) .allowAllAccess(true)
.option(RuntimeOptions.PROJECT_ROOT, pkg.root.getAbsolutePath) .option(RuntimeOptions.PROJECT_ROOT, pkg.root.getAbsolutePath)
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName)
.option( .option(
RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION,
"false" "false"
@ -65,6 +66,7 @@ class RuntimeAsyncCommandsTest
) )
.option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev") .option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev")
.out(out) .out(out)
.logHandler(System.err)
.serverTransport(runtimeServerEmulator.makeServerTransport) .serverTransport(runtimeServerEmulator.makeServerTransport)
.build() .build()
) )

View File

@ -27,7 +27,7 @@ import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths} import java.nio.file.{Files, Path, Paths}
import java.util.UUID import java.util.UUID
import java.util.concurrent.{LinkedBlockingQueue, TimeUnit} import java.util.concurrent.{LinkedBlockingQueue, TimeUnit}
import java.util.logging.Level
import scala.concurrent.duration._ import scala.concurrent.duration._
@scala.annotation.nowarn("msg=multiarg infix syntax") @scala.annotation.nowarn("msg=multiarg infix syntax")
@ -125,7 +125,7 @@ class RuntimeComponentsTest
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
distributionHome.toString distributionHome.toString
) )
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName)
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true") .option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeServerInfo.ENABLE_OPTION, "true") .option(RuntimeServerInfo.ENABLE_OPTION, "true")
.option(RuntimeOptions.INTERACTIVE_MODE, "true") .option(RuntimeOptions.INTERACTIVE_MODE, "true")
@ -134,6 +134,7 @@ class RuntimeComponentsTest
InstrumentTestContext.DISABLE_IR_CACHE InstrumentTestContext.DISABLE_IR_CACHE
) )
.out(out) .out(out)
.logHandler(System.err)
.serverTransport(runtimeServerEmulator.makeServerTransport) .serverTransport(runtimeServerEmulator.makeServerTransport)
.build() .build()
) )

View File

@ -18,7 +18,7 @@ import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach}
import java.io.{ByteArrayOutputStream, File} import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths} import java.nio.file.{Files, Path, Paths}
import java.util.UUID import java.util.UUID
import java.util.logging.Level
import scala.concurrent.duration._ import scala.concurrent.duration._
@scala.annotation.nowarn("msg=multiarg infix syntax") @scala.annotation.nowarn("msg=multiarg infix syntax")
@ -60,7 +60,6 @@ class RuntimeExecutionEnvironmentTest
edition = Some(edition) edition = Some(edition)
) )
val out: ByteArrayOutputStream = new ByteArrayOutputStream() val out: ByteArrayOutputStream = new ByteArrayOutputStream()
val logOut: ByteArrayOutputStream = new ByteArrayOutputStream()
val executionContext = new PolyglotContext( val executionContext = new PolyglotContext(
Context Context
.newBuilder(LanguageInfo.ID) .newBuilder(LanguageInfo.ID)
@ -71,7 +70,7 @@ class RuntimeExecutionEnvironmentTest
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
distributionHome.toString distributionHome.toString
) )
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true") .option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false") .option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false") .option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
@ -82,7 +81,7 @@ class RuntimeExecutionEnvironmentTest
RuntimeOptions.DISABLE_IR_CACHES, RuntimeOptions.DISABLE_IR_CACHES,
InstrumentTestContext.DISABLE_IR_CACHE InstrumentTestContext.DISABLE_IR_CACHE
) )
//.logHandler(logOut) .logHandler(System.err)
.out(out) .out(out)
.serverTransport(runtimeServerEmulator.makeServerTransport) .serverTransport(runtimeServerEmulator.makeServerTransport)
.build() .build()

View File

@ -63,6 +63,7 @@ class RuntimeInstrumentTest
) )
.option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev") .option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev")
.out(out) .out(out)
.logHandler(System.err)
.serverTransport(runtimeServerEmulator.makeServerTransport) .serverTransport(runtimeServerEmulator.makeServerTransport)
.build() .build()
) )

View File

@ -6,6 +6,7 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec import org.scalatest.wordspec.AnyWordSpec
import java.nio.file.Paths import java.nio.file.Paths
import java.util.logging.Level
class RuntimeProjectContextTest extends AnyWordSpec with Matchers { class RuntimeProjectContextTest extends AnyWordSpec with Matchers {
"Runtime Context" should { "Runtime Context" should {
@ -28,7 +29,8 @@ class RuntimeProjectContextTest extends AnyWordSpec with Matchers {
.getAbsolutePath .getAbsolutePath
) )
.option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev") .option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev")
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName)
.logHandler(System.err)
.build() .build()
context.initialize(LanguageInfo.ID) context.initialize(LanguageInfo.ID)
} }

View File

@ -19,6 +19,7 @@ import org.scalatest.matchers.should.Matchers
import java.io.{ByteArrayOutputStream, File} import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths} import java.nio.file.{Files, Path, Paths}
import java.util.UUID import java.util.UUID
import java.util.logging.Level
@scala.annotation.nowarn("msg=multiarg infix syntax") @scala.annotation.nowarn("msg=multiarg infix syntax")
class RuntimeRefactoringTest class RuntimeRefactoringTest
@ -48,7 +49,7 @@ class RuntimeRefactoringTest
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowAllAccess(true) .allowAllAccess(true)
.option(RuntimeOptions.PROJECT_ROOT, pkg.root.getAbsolutePath) .option(RuntimeOptions.PROJECT_ROOT, pkg.root.getAbsolutePath)
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true") .option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false") .option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false") .option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")

View File

@ -17,7 +17,7 @@ import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths} import java.nio.file.{Files, Path, Paths}
import java.util.UUID import java.util.UUID
import java.util.concurrent.{LinkedBlockingQueue, TimeUnit} import java.util.concurrent.{LinkedBlockingQueue, TimeUnit}
import java.util.logging.Level
import scala.collection.mutable import scala.collection.mutable
import scala.concurrent.duration._ import scala.concurrent.duration._
@ -73,7 +73,7 @@ class RuntimeStdlibTest
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
distributionHome.toString distributionHome.toString
) )
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName)
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true") .option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeServerInfo.ENABLE_OPTION, "true") .option(RuntimeServerInfo.ENABLE_OPTION, "true")
.option(RuntimeOptions.INTERACTIVE_MODE, "true") .option(RuntimeOptions.INTERACTIVE_MODE, "true")
@ -82,6 +82,7 @@ class RuntimeStdlibTest
InstrumentTestContext.DISABLE_IR_CACHE InstrumentTestContext.DISABLE_IR_CACHE
) )
.out(out) .out(out)
.logHandler(System.err)
.serverTransport(runtimeServerEmulator.makeServerTransport) .serverTransport(runtimeServerEmulator.makeServerTransport)
.build() .build()
) )

View File

@ -17,6 +17,7 @@ import org.scalatest.matchers.should.Matchers
import java.io.{ByteArrayOutputStream, File} import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths} import java.nio.file.{Files, Path, Paths}
import java.util.UUID import java.util.UUID
import java.util.logging.Level
@scala.annotation.nowarn("msg=multiarg infix syntax") @scala.annotation.nowarn("msg=multiarg infix syntax")
class RuntimeSuggestionUpdatesTest class RuntimeSuggestionUpdatesTest
@ -43,7 +44,7 @@ class RuntimeSuggestionUpdatesTest
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowAllAccess(true) .allowAllAccess(true)
.option(RuntimeOptions.PROJECT_ROOT, pkg.root.getAbsolutePath) .option(RuntimeOptions.PROJECT_ROOT, pkg.root.getAbsolutePath)
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName)
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true") .option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false") .option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option( .option(
@ -61,6 +62,7 @@ class RuntimeSuggestionUpdatesTest
) )
.option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev") .option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev")
.out(out) .out(out)
.logHandler(System.err)
.serverTransport(runtimeServerEmulator.makeServerTransport) .serverTransport(runtimeServerEmulator.makeServerTransport)
.build() .build()
) )

View File

@ -5,6 +5,8 @@ import java.io.OutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions; import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Language; import org.graalvm.polyglot.Language;
@ -30,7 +32,11 @@ public class InsightForEnsoTest {
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath() Paths.get("../../distribution/component").toFile().getAbsolutePath()
) )
.logHandler(OutputStream.nullOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.out(out) .out(out)

View File

@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions; import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.io.IOAccess; import org.graalvm.polyglot.io.IOAccess;
@ -26,7 +27,7 @@ public class VerifyJavaScriptIsAvailableTest {
.option( .option(
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath()) Paths.get("../../distribution/component").toFile().getAbsolutePath())
.option("log.level", "FINE") .option(RuntimeOptions.LOG_LEVEL, Level.FINE.getName())
.logHandler(handler) .logHandler(handler)
.allowAllAccess(true) .allowAllAccess(true)
.build(); .build();

View File

@ -18,6 +18,7 @@ import java.io.{ByteArrayOutputStream, File}
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Path, Paths} import java.nio.file.{Files, Path, Paths}
import java.util.UUID import java.util.UUID
import java.util.logging.Level
@scala.annotation.nowarn("msg=multiarg infix syntax") @scala.annotation.nowarn("msg=multiarg infix syntax")
class RuntimeVisualizationsTest class RuntimeVisualizationsTest
@ -39,14 +40,13 @@ class RuntimeVisualizationsTest
val pkg: Package[File] = val pkg: Package[File] =
PackageManager.Default.create(tmpDir.toFile, packageName, "Enso_Test") PackageManager.Default.create(tmpDir.toFile, packageName, "Enso_Test")
val out: ByteArrayOutputStream = new ByteArrayOutputStream() val out: ByteArrayOutputStream = new ByteArrayOutputStream()
val logOut: ByteArrayOutputStream = new ByteArrayOutputStream()
val executionContext = new PolyglotContext( val executionContext = new PolyglotContext(
Context Context
.newBuilder() .newBuilder()
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowAllAccess(true) .allowAllAccess(true)
.option(RuntimeOptions.PROJECT_ROOT, pkg.root.getAbsolutePath) .option(RuntimeOptions.PROJECT_ROOT, pkg.root.getAbsolutePath)
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true") .option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false") .option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false") .option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
@ -61,7 +61,7 @@ class RuntimeVisualizationsTest
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile.getAbsolutePath Paths.get("../../distribution/component").toFile.getAbsolutePath
) )
.logHandler(logOut) .logHandler(System.err)
.out(out) .out(out)
.serverTransport(runtimeServerEmulator.makeServerTransport) .serverTransport(runtimeServerEmulator.makeServerTransport)
.build() .build()

View File

@ -4,6 +4,9 @@ import java.io.ByteArrayOutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Engine; import org.graalvm.polyglot.Engine;
import org.graalvm.polyglot.Value; import org.graalvm.polyglot.Value;
@ -35,7 +38,11 @@ public class ArrayProxyBenchmarks {
Engine eng = Engine eng =
Engine.newBuilder() Engine.newBuilder()
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.logHandler(new ByteArrayOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.option( .option(
"enso.languageHomeOverride", "enso.languageHomeOverride",
Paths.get("../../distribution/component").toFile().getAbsolutePath()) Paths.get("../../distribution/component").toFile().getAbsolutePath())

View File

@ -4,6 +4,9 @@ import java.io.ByteArrayOutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value; import org.graalvm.polyglot.Value;
import org.graalvm.polyglot.io.IOAccess; import org.graalvm.polyglot.io.IOAccess;
@ -35,7 +38,11 @@ public class CurriedFunctionBenchmarks {
public void initializeBenchmark(BenchmarkParams params) throws Exception { public void initializeBenchmark(BenchmarkParams params) throws Exception {
var ctx = Context.newBuilder() var ctx = Context.newBuilder()
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.logHandler(new ByteArrayOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)
.option( .option(

View File

@ -9,7 +9,10 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.enso.polyglot.MethodNames.Module; import org.enso.polyglot.MethodNames.Module;
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value; import org.graalvm.polyglot.Value;
import org.graalvm.polyglot.io.IOAccess; import org.graalvm.polyglot.io.IOAccess;
@ -61,7 +64,11 @@ public class EqualsBenchmarks {
var ctx = Context.newBuilder() var ctx = Context.newBuilder()
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.logHandler(new ByteArrayOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)
.option( .option(

View File

@ -8,9 +8,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.enso.interpreter.test.TestBase; import org.enso.interpreter.test.TestBase;
import org.enso.polyglot.MethodNames.Module; import org.enso.polyglot.MethodNames.Module;
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value; import org.graalvm.polyglot.Value;
import org.graalvm.polyglot.io.IOAccess; import org.graalvm.polyglot.io.IOAccess;
@ -43,13 +45,17 @@ public class IfVsCaseBenchmarks extends TestBase {
private Value caseBench6; private Value caseBench6;
private Value createVec; private Value createVec;
private Value inputVec; private Value inputVec;
private OutputStream out = new ByteArrayOutputStream();
@Setup @Setup
public void initializeBench(BenchmarkParams params) throws IOException { public void initializeBench(BenchmarkParams params) throws IOException {
OutputStream out = new ByteArrayOutputStream();
ctx = Context.newBuilder("enso") ctx = Context.newBuilder("enso")
.allowAllAccess(true) .allowAllAccess(true)
.logHandler(out) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.out(out) .out(out)
.err(out) .err(out)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)

View File

@ -4,6 +4,9 @@ import java.io.ByteArrayOutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value; import org.graalvm.polyglot.Value;
import org.graalvm.polyglot.io.IOAccess; import org.graalvm.polyglot.io.IOAccess;
@ -42,7 +45,11 @@ public class ListBenchmarks {
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)
.logHandler(new ByteArrayOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.option( .option(
"enso.languageHomeOverride", "enso.languageHomeOverride",
Paths.get("../../distribution/component").toFile().getAbsolutePath() Paths.get("../../distribution/component").toFile().getAbsolutePath()

View File

@ -6,6 +6,9 @@ import java.nio.file.Paths;
import java.util.AbstractList; import java.util.AbstractList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value; import org.graalvm.polyglot.Value;
import org.graalvm.polyglot.io.IOAccess; import org.graalvm.polyglot.io.IOAccess;
@ -41,7 +44,11 @@ public class NestedPatternCompilationBenchmarks {
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)
.logHandler(new ByteArrayOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.option( .option(
"enso.languageHomeOverride", "enso.languageHomeOverride",
Paths.get("../../distribution/component").toFile().getAbsolutePath() Paths.get("../../distribution/component").toFile().getAbsolutePath()

View File

@ -3,6 +3,9 @@ package org.enso.interpreter.bench.benchmarks.semantic;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value; import org.graalvm.polyglot.Value;
import org.graalvm.polyglot.io.IOAccess; import org.graalvm.polyglot.io.IOAccess;
@ -35,7 +38,11 @@ public class SieveBenchmarks {
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)
.logHandler(new ByteArrayOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.option( .option(
"enso.languageHomeOverride", "enso.languageHomeOverride",
Paths.get("../../distribution/component").toFile().getAbsolutePath() Paths.get("../../distribution/component").toFile().getAbsolutePath()

View File

@ -4,6 +4,9 @@ import java.io.ByteArrayOutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value; import org.graalvm.polyglot.Value;
import org.graalvm.polyglot.io.IOAccess; import org.graalvm.polyglot.io.IOAccess;
@ -38,7 +41,11 @@ public class StringBenchmarks {
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)
.logHandler(new ByteArrayOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.option( .option(
"enso.languageHomeOverride", "enso.languageHomeOverride",
Paths.get("../../distribution/component").toFile().getAbsolutePath() Paths.get("../../distribution/component").toFile().getAbsolutePath()

View File

@ -1,6 +1,7 @@
package org.enso.interpreter.bench.benchmarks.semantic; package org.enso.interpreter.bench.benchmarks.semantic;
import org.enso.polyglot.MethodNames.Module; import org.enso.polyglot.MethodNames.Module;
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value; import org.graalvm.polyglot.Value;
import org.graalvm.polyglot.io.IOAccess; import org.graalvm.polyglot.io.IOAccess;
@ -12,6 +13,7 @@ import java.io.ByteArrayOutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.logging.Level;
@BenchmarkMode(Mode.AverageTime) @BenchmarkMode(Mode.AverageTime)
@ -31,7 +33,11 @@ public class TypePatternBenchmarks {
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)
.logHandler(new ByteArrayOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.option( .option(
"enso.languageHomeOverride", "enso.languageHomeOverride",
Paths.get("../../distribution/component").toFile().getAbsolutePath() Paths.get("../../distribution/component").toFile().getAbsolutePath()

View File

@ -5,6 +5,9 @@ import java.nio.file.Paths;
import java.util.AbstractList; import java.util.AbstractList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value; import org.graalvm.polyglot.Value;
import org.graalvm.polyglot.io.IOAccess; import org.graalvm.polyglot.io.IOAccess;
@ -39,7 +42,11 @@ public class VectorBenchmarks {
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)
.logHandler(new ByteArrayOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.option( .option(
"enso.languageHomeOverride", "enso.languageHomeOverride",
Paths.get("../../distribution/component").toFile().getAbsolutePath() Paths.get("../../distribution/component").toFile().getAbsolutePath()

View File

@ -765,13 +765,14 @@ public final class EnsoContext {
} }
/** /**
* Gets a logger for the specified class. * Gets a logger for the specified class that is bound to this engine.
* Such logger may then be safely used in threads defined in a thread-pool.
* *
* @param klass the class to name log entries with * @param clazz the class to name log entries with
* @return a new logger for the specified {@code path} * @return a new logger for the specified {@code path}
*/ */
public TruffleLogger getLogger(Class<?> klass) { public TruffleLogger getLogger(Class<?> clazz) {
return TruffleLogger.getLogger(LanguageInfo.ID, klass); return environment.getLogger(clazz);
} }
/** /**

View File

@ -37,14 +37,14 @@ final class TruffleCompilerContext implements CompilerContext {
private final EnsoContext context; private final EnsoContext context;
private final TruffleLogger loggerCompiler; private final TruffleLogger loggerCompiler;
private final TruffleLogger loggerManager; private final TruffleLogger loggerSerializationManager;
private final RuntimeStubsGenerator stubsGenerator; private final RuntimeStubsGenerator stubsGenerator;
private final SerializationManager serializationManager; private final SerializationManager serializationManager;
TruffleCompilerContext(EnsoContext context) { TruffleCompilerContext(EnsoContext context) {
this.context = context; this.context = context;
this.loggerCompiler = context.getLogger(Compiler.class); this.loggerCompiler = context.getLogger(Compiler.class);
this.loggerManager = context.getLogger(SerializationManager.class); this.loggerSerializationManager = context.getLogger(SerializationManager.class);
this.serializationManager = new SerializationManager(this); this.serializationManager = new SerializationManager(this);
this.stubsGenerator = new RuntimeStubsGenerator(context.getBuiltins()); this.stubsGenerator = new RuntimeStubsGenerator(context.getBuiltins());
} }
@ -90,7 +90,7 @@ final class TruffleCompilerContext implements CompilerContext {
@Override @Override
public void logSerializationManager(Level level, String msg, Object... args) { public void logSerializationManager(Level level, String msg, Object... args) {
loggerManager.log(level, msg, args); loggerSerializationManager.log(level, msg, args);
} }
@Override @Override

View File

@ -2,6 +2,7 @@ package org.enso.compiler;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions; import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
@ -28,7 +29,11 @@ public class ExecCompilerTest {
Paths.get("../../distribution/component").toFile().getAbsolutePath() Paths.get("../../distribution/component").toFile().getAbsolutePath()
) )
.option(RuntimeOptions.STRICT_ERRORS, "false") .option(RuntimeOptions.STRICT_ERRORS, "false")
.logHandler(OutputStream.nullOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.allowAllAccess(true) .allowAllAccess(true)
.build(); .build();
assertNotNull("Enso language is supported", ctx.getEngine().getLanguages().get("enso")); assertNotNull("Enso language is supported", ctx.getEngine().getLanguages().get("enso"));

View File

@ -14,6 +14,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.logging.Formatter; import java.util.logging.Formatter;
import java.util.logging.Handler; import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord; import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter; import java.util.logging.SimpleFormatter;
import org.enso.compiler.core.ir.Module; import org.enso.compiler.core.ir.Module;
@ -118,6 +119,7 @@ public class SerdeCompilerTest {
.option( .option(
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath()) Paths.get("../../distribution/component").toFile().getAbsolutePath())
.option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.logHandler(mockHandler) .logHandler(mockHandler)
.option("log.enso.org.enso.compiler.Compiler.level", "FINE") .option("log.enso.org.enso.compiler.Compiler.level", "FINE")
.allowAllAccess(true) .allowAllAccess(true)

View File

@ -5,9 +5,9 @@ import static org.junit.Assert.assertNotNull;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.enso.interpreter.runtime.EnsoContext; import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.SerializationManager; import org.enso.interpreter.runtime.SerializationManager;
import org.enso.pkg.PackageManager; import org.enso.pkg.PackageManager;
@ -28,7 +28,8 @@ public class SerializerTest {
.option( .option(
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath()) Paths.get("../../distribution/component").toFile().getAbsolutePath())
.logHandler(OutputStream.nullOutputStream()) .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.logHandler(System.err)
.allowAllAccess(true) .allowAllAccess(true)
.build(); .build();
assertNotNull("Enso language is supported", ctx.getEngine().getLanguages().get("enso")); assertNotNull("Enso language is supported", ctx.getEngine().getLanguages().get("enso"));

View File

@ -2,10 +2,10 @@ package org.enso.interpreter.runtime;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.logging.Level;
import org.enso.polyglot.LanguageInfo; import org.enso.polyglot.LanguageInfo;
import org.enso.polyglot.MethodNames; import org.enso.polyglot.MethodNames;
import org.enso.polyglot.RuntimeOptions; import org.enso.polyglot.RuntimeOptions;
@ -29,7 +29,8 @@ public class ModuleSourcesTest {
Engine eng = Engine eng =
Engine.newBuilder() Engine.newBuilder()
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.logHandler(new ByteArrayOutputStream()) .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.logHandler(System.err)
.option( .option(
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath()) Paths.get("../../distribution/component").toFile().getAbsolutePath())

View File

@ -2,10 +2,10 @@ package org.enso.interpreter.runtime;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.logging.Level;
import org.enso.pkg.QualifiedName; import org.enso.pkg.QualifiedName;
import org.enso.polyglot.LanguageInfo; import org.enso.polyglot.LanguageInfo;
import org.enso.polyglot.MethodNames; import org.enso.polyglot.MethodNames;
@ -29,7 +29,8 @@ public class ModuleTest {
Engine eng = Engine eng =
Engine.newBuilder() Engine.newBuilder()
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.logHandler(new ByteArrayOutputStream()) .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.logHandler(System.err)
.option( .option(
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath()) Paths.get("../../distribution/component").toFile().getAbsolutePath())

View File

@ -13,6 +13,7 @@ import java.util.Objects;
import java.util.Queue; import java.util.Queue;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.enso.polyglot.MethodNames.Module; import org.enso.polyglot.MethodNames.Module;
@ -58,9 +59,9 @@ public class DebuggingEnsoTest {
) )
.option( .option(
RuntimeOptions.LOG_LEVEL, RuntimeOptions.LOG_LEVEL,
"FINEST" Level.FINEST.getName()
) )
.logHandler(OutputStream.nullOutputStream()) .logHandler(System.err)
.build(); .build();
context = Context.newBuilder() context = Context.newBuilder()

View File

@ -2,6 +2,7 @@ package org.enso.interpreter.test;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions; import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Context;
@ -18,10 +19,13 @@ public class SharedEngineTest extends TestBase {
@BeforeClass @BeforeClass
public static void initializeSharedEngine() { public static void initializeSharedEngine() {
var out = new ByteArrayOutputStream();
sharedEngine = Engine.newBuilder() sharedEngine = Engine.newBuilder()
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.logHandler(out) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.option(RuntimeOptions.STRICT_ERRORS, "true") .option(RuntimeOptions.STRICT_ERRORS, "true")
.option( .option(
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,

View File

@ -9,11 +9,11 @@ import com.oracle.truffle.api.library.ExportLibrary;
import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.library.ExportMessage;
import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.nodes.RootNode;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.logging.Level;
import org.enso.interpreter.EnsoLanguage; import org.enso.interpreter.EnsoLanguage;
import org.enso.polyglot.MethodNames.Module; import org.enso.polyglot.MethodNames.Module;
import org.enso.polyglot.RuntimeOptions; import org.enso.polyglot.RuntimeOptions;
@ -44,7 +44,8 @@ public abstract class TestBase {
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)
.logHandler(new ByteArrayOutputStream()) .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.logHandler(System.err)
.option(RuntimeOptions.STRICT_ERRORS, "true") .option(RuntimeOptions.STRICT_ERRORS, "true")
.option( .option(
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, RuntimeOptions.LANGUAGE_HOME_OVERRIDE,

View File

@ -12,6 +12,7 @@ import org.scalatest.matchers.should.Matchers
import java.io.{ByteArrayOutputStream, File, FileFilter} import java.io.{ByteArrayOutputStream, File, FileFilter}
import java.nio.file.{Files, Paths, StandardCopyOption} import java.nio.file.{Files, Paths, StandardCopyOption}
import java.util.logging.Level
trait ModifiedTest trait ModifiedTest
extends AnyFlatSpec extends AnyFlatSpec
@ -62,7 +63,7 @@ trait ModifiedTest
.option(RuntimeOptions.DISABLE_IR_CACHES, "false") .option(RuntimeOptions.DISABLE_IR_CACHES, "false")
.out(output) .out(output)
.in(System.in) .in(System.in)
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.logHandler(System.err) .logHandler(System.err)
.build() .build()
context.initialize(LanguageInfo.ID) context.initialize(LanguageInfo.ID)

View File

@ -17,6 +17,7 @@ import org.scalatest.wordspec.AnyWordSpecLike
import java.io.{ByteArrayOutputStream, ObjectOutputStream} import java.io.{ByteArrayOutputStream, ObjectOutputStream}
import java.nio.file.Paths import java.nio.file.Paths
import java.util.logging.Level
/** Tests a single package with multiple modules for import/export resolution. /** Tests a single package with multiple modules for import/export resolution.
* Checks whether the exported symbols and defined entities metadata of the modules * Checks whether the exported symbols and defined entities metadata of the modules
@ -41,7 +42,7 @@ class ImportExportTest
.allowCreateThread(false) .allowCreateThread(false)
.out(out) .out(out)
.err(out) .err(out)
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.option(RuntimeOptions.DISABLE_IR_CACHES, "true") .option(RuntimeOptions.DISABLE_IR_CACHES, "true")
.logHandler(System.err) .logHandler(System.err)
.option( .option(

View File

@ -28,6 +28,7 @@ import java.io.{
} }
import java.nio.file.Paths import java.nio.file.Paths
import java.util.UUID import java.util.UUID
import java.util.logging.Level
case class LocationsInstrumenter(instrument: CodeLocationsTestInstrument) { case class LocationsInstrumenter(instrument: CodeLocationsTestInstrument) {
var bindings: List[EventBinding[LocationsEventListener]] = List() var bindings: List[EventBinding[LocationsEventListener]] = List()
@ -122,7 +123,7 @@ class InterpreterContext(
.allowCreateThread(false) .allowCreateThread(false)
.out(output) .out(output)
.err(err) .err(err)
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.option(RuntimeOptions.DISABLE_IR_CACHES, "true") .option(RuntimeOptions.DISABLE_IR_CACHES, "true")
.environment("NO_COLOR", "true") .environment("NO_COLOR", "true")
.logHandler(System.err) .logHandler(System.err)

View File

@ -8,6 +8,7 @@ import org.scalatest.matchers.should.Matchers
import java.io.{ByteArrayOutputStream, File} import java.io.{ByteArrayOutputStream, File}
import java.nio.file.Paths import java.nio.file.Paths
import java.util.logging.Level
trait PackageTest extends AnyFlatSpec with Matchers with ValueEquality { trait PackageTest extends AnyFlatSpec with Matchers with ValueEquality {
val output = new ByteArrayOutputStream() val output = new ByteArrayOutputStream()
@ -35,7 +36,7 @@ trait PackageTest extends AnyFlatSpec with Matchers with ValueEquality {
.option(RuntimeOptions.DISABLE_IR_CACHES, "true") .option(RuntimeOptions.DISABLE_IR_CACHES, "true")
.out(output) .out(output)
.in(System.in) .in(System.in)
.option(RuntimeOptions.LOG_LEVEL, "WARNING") .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.logHandler(System.err) .logHandler(System.err)
.build() .build()
context.initialize(LanguageInfo.ID) context.initialize(LanguageInfo.ID)

View File

@ -7,6 +7,7 @@ import java.io.PrintWriter;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.FilerException; import javax.annotation.processing.FilerException;
@ -44,6 +45,7 @@ public class BenchProcessor extends AbstractProcessor {
"import java.util.List;", "import java.util.List;",
"import java.util.Objects;", "import java.util.Objects;",
"import java.util.concurrent.TimeUnit;", "import java.util.concurrent.TimeUnit;",
"import java.util.logging.Level;",
"import org.openjdk.jmh.annotations.Benchmark;", "import org.openjdk.jmh.annotations.Benchmark;",
"import org.openjdk.jmh.annotations.BenchmarkMode;", "import org.openjdk.jmh.annotations.BenchmarkMode;",
"import org.openjdk.jmh.annotations.Mode;", "import org.openjdk.jmh.annotations.Mode;",
@ -113,7 +115,11 @@ public class BenchProcessor extends AbstractProcessor {
.allowExperimentalOptions(true) .allowExperimentalOptions(true)
.allowIO(IOAccess.ALL) .allowIO(IOAccess.ALL)
.allowAllAccess(true) .allowAllAccess(true)
.logHandler(new ByteArrayOutputStream()) .option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.option(RuntimeOptions.PROJECT_ROOT, projectRootDir.getAbsolutePath()) .option(RuntimeOptions.PROJECT_ROOT, projectRootDir.getAbsolutePath())
.option(RuntimeOptions.LANGUAGE_HOME_OVERRIDE, ensoHomeOverride.getAbsolutePath()) .option(RuntimeOptions.LANGUAGE_HOME_OVERRIDE, ensoHomeOverride.getAbsolutePath())
.build()) { .build()) {
@ -242,7 +248,8 @@ public class BenchProcessor extends AbstractProcessor {
out.println(" .allowExperimentalOptions(true)"); out.println(" .allowExperimentalOptions(true)");
out.println(" .allowIO(IOAccess.ALL)"); out.println(" .allowIO(IOAccess.ALL)");
out.println(" .allowAllAccess(true)"); out.println(" .allowAllAccess(true)");
out.println(" .logHandler(new ByteArrayOutputStream())"); out.println(" .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())");
out.println(" .logHandler(System.err)");
out.println(" .option("); out.println(" .option(");
out.println(" RuntimeOptions.LANGUAGE_HOME_OVERRIDE,"); out.println(" RuntimeOptions.LANGUAGE_HOME_OVERRIDE,");
out.println(" languageHomeOverride.getAbsolutePath()"); out.println(" languageHomeOverride.getAbsolutePath()");