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

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

Merged
merged 5 commits into from
Oct 31, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.nio.file.Paths;
import java.util.List;
import java.util.function.Supplier;
import java.util.logging.Level;

import org.enso.interpreter.EnsoLanguage;
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.callable.function.Function;
Expand Down Expand Up @@ -68,8 +70,12 @@ public void setup() {
.allowExperimentalOptions(true)
.allowIO(IOAccess.ALL)
.allowAllAccess(true)
.logHandler(new ByteArrayOutputStream())
.logHandler(System.err)
.option(RuntimeOptions.STRICT_ERRORS, "true")
.option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.option(
RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.nio.file.Paths;
import java.util.Map;
import java.util.function.Predicate;
import java.util.logging.Level;

import org.enso.interpreter.node.ClosureRootNode;
import org.enso.interpreter.runtime.tag.AvoidIdInstrumentationTag;
import org.enso.interpreter.runtime.tag.IdentifiedTag;
Expand Down Expand Up @@ -38,7 +40,11 @@ public void initContext() {
RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath()
)
.logHandler(OutputStream.nullOutputStream())
.option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved
.allowExperimentalOptions(true)
.allowIO(IOAccess.ALL)
.allowAllAccess(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.OutputStream;
import java.nio.file.Paths;
import java.util.Map;
import java.util.logging.Level;

public class WarningInstrumentationTest {

Expand All @@ -35,7 +36,11 @@ public void initContext() {
RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath()
)
.logHandler(OutputStream.nullOutputStream())
.option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.allowExperimentalOptions(true)
.allowIO(IOAccess.ALL)
.allowAllAccess(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.scalatest.matchers.should.Matchers
import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths}
import java.util.UUID
import java.util.logging.Level

@scala.annotation.nowarn("msg=multiarg infix syntax")
class BuiltinTypesTest
Expand All @@ -36,15 +37,14 @@ class BuiltinTypesTest

val pkg: Package[File] =
PackageManager.Default.create(tmpDir.toFile, packageName, "Enso_Test")
val out: ByteArrayOutputStream = new ByteArrayOutputStream()
val logOut: ByteArrayOutputStream = new ByteArrayOutputStream()
val out: ByteArrayOutputStream = new ByteArrayOutputStream()
val executionContext = new PolyglotContext(
Context
.newBuilder(LanguageInfo.ID)
.allowExperimentalOptions(true)
.allowAllAccess(true)
.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.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
Expand All @@ -63,7 +63,7 @@ class BuiltinTypesTest
.getAbsolutePath
)
.option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev")
.logHandler(logOut)
.logHandler(System.err)
.out(out)
.serverTransport(runtimeServerEmulator.makeServerTransport)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.scalatest.matchers.should.Matchers
import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths}
import java.util.UUID
import java.util.logging.Level

@scala.annotation.nowarn("msg=multiarg infix syntax")
class RuntimeAsyncCommandsTest
Expand Down Expand Up @@ -42,7 +43,7 @@ class RuntimeAsyncCommandsTest
.allowExperimentalOptions(true)
.allowAllAccess(true)
.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,
"false"
Expand All @@ -65,6 +66,7 @@ class RuntimeAsyncCommandsTest
)
.option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev")
.out(out)
.logHandler(System.err)
.serverTransport(runtimeServerEmulator.makeServerTransport)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths}
import java.util.UUID
import java.util.concurrent.{LinkedBlockingQueue, TimeUnit}

import java.util.logging.Level
import scala.concurrent.duration._

@scala.annotation.nowarn("msg=multiarg infix syntax")
Expand Down Expand Up @@ -125,7 +125,7 @@ class RuntimeComponentsTest
RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
distributionHome.toString
)
.option(RuntimeOptions.LOG_LEVEL, "WARNING")
.option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName)
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeServerInfo.ENABLE_OPTION, "true")
.option(RuntimeOptions.INTERACTIVE_MODE, "true")
Expand All @@ -134,6 +134,7 @@ class RuntimeComponentsTest
InstrumentTestContext.DISABLE_IR_CACHE
)
.out(out)
.logHandler(System.err)
.serverTransport(runtimeServerEmulator.makeServerTransport)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach}
import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths}
import java.util.UUID

import java.util.logging.Level
import scala.concurrent.duration._

@scala.annotation.nowarn("msg=multiarg infix syntax")
Expand Down Expand Up @@ -59,8 +59,7 @@ class RuntimeExecutionEnvironmentTest
"Enso_Test",
edition = Some(edition)
)
val out: ByteArrayOutputStream = new ByteArrayOutputStream()
val logOut: ByteArrayOutputStream = new ByteArrayOutputStream()
val out: ByteArrayOutputStream = new ByteArrayOutputStream()
val executionContext = new PolyglotContext(
Context
.newBuilder(LanguageInfo.ID)
Expand All @@ -71,7 +70,7 @@ class RuntimeExecutionEnvironmentTest
RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
distributionHome.toString
)
.option(RuntimeOptions.LOG_LEVEL, "WARNING")
.option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeOptions.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
Expand All @@ -82,7 +81,7 @@ class RuntimeExecutionEnvironmentTest
RuntimeOptions.DISABLE_IR_CACHES,
InstrumentTestContext.DISABLE_IR_CACHE
)
//.logHandler(logOut)
.logHandler(System.err)
.out(out)
.serverTransport(runtimeServerEmulator.makeServerTransport)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class RuntimeInstrumentTest
)
.option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev")
.out(out)
.logHandler(System.err)
.serverTransport(runtimeServerEmulator.makeServerTransport)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

import java.nio.file.Paths
import java.util.logging.Level

class RuntimeProjectContextTest extends AnyWordSpec with Matchers {
"Runtime Context" should {
Expand All @@ -28,7 +29,8 @@ class RuntimeProjectContextTest extends AnyWordSpec with Matchers {
.getAbsolutePath
)
.option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev")
.option(RuntimeOptions.LOG_LEVEL, "WARNING")
.option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName)
.logHandler(System.err)
.build()
context.initialize(LanguageInfo.ID)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.scalatest.matchers.should.Matchers
import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths}
import java.util.UUID
import java.util.logging.Level

@scala.annotation.nowarn("msg=multiarg infix syntax")
class RuntimeRefactoringTest
Expand Down Expand Up @@ -48,7 +49,7 @@ class RuntimeRefactoringTest
.allowExperimentalOptions(true)
.allowAllAccess(true)
.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.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths}
import java.util.UUID
import java.util.concurrent.{LinkedBlockingQueue, TimeUnit}

import java.util.logging.Level
import scala.collection.mutable
import scala.concurrent.duration._

Expand Down Expand Up @@ -73,7 +73,7 @@ class RuntimeStdlibTest
RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
distributionHome.toString
)
.option(RuntimeOptions.LOG_LEVEL, "WARNING")
.option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName)
.option(RuntimeOptions.INTERPRETER_SEQUENTIAL_COMMAND_EXECUTION, "true")
.option(RuntimeServerInfo.ENABLE_OPTION, "true")
.option(RuntimeOptions.INTERACTIVE_MODE, "true")
Expand All @@ -82,6 +82,7 @@ class RuntimeStdlibTest
InstrumentTestContext.DISABLE_IR_CACHE
)
.out(out)
.logHandler(System.err)
.serverTransport(runtimeServerEmulator.makeServerTransport)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.scalatest.matchers.should.Matchers
import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path, Paths}
import java.util.UUID
import java.util.logging.Level

@scala.annotation.nowarn("msg=multiarg infix syntax")
class RuntimeSuggestionUpdatesTest
Expand All @@ -43,7 +44,7 @@ class RuntimeSuggestionUpdatesTest
.allowExperimentalOptions(true)
.allowAllAccess(true)
.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.ENABLE_GLOBAL_SUGGESTIONS, "false")
.option(
Expand All @@ -61,6 +62,7 @@ class RuntimeSuggestionUpdatesTest
)
.option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev")
.out(out)
.logHandler(System.err)
.serverTransport(runtimeServerEmulator.makeServerTransport)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.nio.file.Paths;
import java.util.Map;
import java.util.function.Function;
import java.util.logging.Level;

import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Language;
Expand All @@ -30,7 +32,11 @@ public void initContext() throws Exception {
RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath()
)
.logHandler(OutputStream.nullOutputStream())
.option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.allowExperimentalOptions(true)
.allowIO(IOAccess.ALL)
.out(out)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.junit.Assert.assertNotNull;

import java.nio.file.Paths;
import java.util.logging.Level;
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.io.IOAccess;
Expand All @@ -26,7 +27,7 @@ public static void initEnsoContext() {
.option(
RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath())
.option("log.level", "FINE")
.option(RuntimeOptions.LOG_LEVEL, Level.FINE.getName())
.logHandler(handler)
.allowAllAccess(true)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import java.io.{ByteArrayOutputStream, File}
import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Path, Paths}
import java.util.UUID
import java.util.logging.Level

@scala.annotation.nowarn("msg=multiarg infix syntax")
class RuntimeVisualizationsTest
Expand All @@ -38,15 +39,14 @@ class RuntimeVisualizationsTest

val pkg: Package[File] =
PackageManager.Default.create(tmpDir.toFile, packageName, "Enso_Test")
val out: ByteArrayOutputStream = new ByteArrayOutputStream()
val logOut: ByteArrayOutputStream = new ByteArrayOutputStream()
val out: ByteArrayOutputStream = new ByteArrayOutputStream()
val executionContext = new PolyglotContext(
Context
.newBuilder()
.allowExperimentalOptions(true)
.allowAllAccess(true)
.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.ENABLE_PROJECT_SUGGESTIONS, "false")
.option(RuntimeOptions.ENABLE_GLOBAL_SUGGESTIONS, "false")
Expand All @@ -61,7 +61,7 @@ class RuntimeVisualizationsTest
RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile.getAbsolutePath
)
.logHandler(logOut)
.logHandler(System.err)
.out(out)
.serverTransport(runtimeServerEmulator.makeServerTransport)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.logging.Level;

import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Engine;
import org.graalvm.polyglot.Value;
Expand Down Expand Up @@ -35,7 +38,11 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
Engine eng =
Engine.newBuilder()
.allowExperimentalOptions(true)
.logHandler(new ByteArrayOutputStream())
.option(
RuntimeOptions.LOG_LEVEL,
Level.WARNING.getName()
)
.logHandler(System.err)
.option(
"enso.languageHomeOverride",
Paths.get("../../distribution/component").toFile().getAbsolutePath())
Expand Down
Loading