Skip to content
Open
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
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ lazy val testkit = project
Compile / exportedModule := (Compile / exportedModuleBin).value,
Compile / exportedModuleBin := (Compile / packageBin).value
)
.dependsOn(`logging-service-logback`)
.dependsOn(`logging-service-logback` % "compile->test")
.dependsOn(`runtime-utils`)

lazy val searcher = project
Expand Down Expand Up @@ -2726,6 +2726,7 @@ lazy val `runtime-integration-tests` =
"-Dtck.inlineVerifierInstrument=false",
"-Dpolyglot.engine.AllowExperimentalOptions=true"
),
Test / javacOptions += "-implicit:none",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR but reduces warnings noise.

Test / javaOptions ++= testLogProviderOptions,
Test / moduleDependencies := {
GraalVM.modules ++ GraalVM.langsPkgs ++ GraalVM.insightPkgs ++ logbackPkg ++ helidon ++ scalaLibrary ++ scalaReflect ++ slf4jApi ++ Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.enso.common.RuntimeOptions;
import org.enso.compiler.Compiler;
import org.enso.compiler.benchmarks.Utils;
Expand Down Expand Up @@ -51,6 +52,7 @@ public void setup() throws IOException {
ctx =
Utils.createDefaultContextBuilder()
.withModifiedContext(bldr -> bldr.option(RuntimeOptions.STRICT_ERRORS, "false"))
.withStdOutLogHandler(Level.WARNING)
.build();
var ensoCtx = ctx.ensoContext();
compiler = ensoCtx.getCompiler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
import org.enso.common.ContextFactory;
import org.enso.common.LanguageInfo;
import org.enso.common.MethodNames.Module;
import org.enso.logger.JulHandler;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;
import org.hamcrest.core.AllOf;
import org.junit.AfterClass;
import org.junit.Rule;
import org.junit.Test;

/**
Expand All @@ -25,6 +28,8 @@ public class ContextInsightSetupTest {

public ContextInsightSetupTest() {}

@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

@AfterClass
public static void cleanupInsightProperty() {
System.getProperties().remove("enso.dev.insight");
Expand All @@ -45,7 +50,7 @@ public void initializeInsightViaProperty() throws Exception {
var out = new ByteArrayOutputStream();
// Need to initialize the Context via ContextFactory, so that ContextInsightSetup is
// triggered.
try (var ctx = ContextFactory.create().out(out).build()) {
try (var ctx = ContextFactory.create().logHandler(JulHandler.get()).out(out).build()) {

var fourtyTwo = evalModule(ctx, """
main = 42
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
import java.io.IOException;
import java.util.function.BiConsumer;
import org.enso.test.utils.ContextUtils;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;

/** Tests recognitions of API changes in Enso code. */
public final class ApiModificationTest {
@ClassRule public static final ContextUtils ctxRule = ContextUtils.createDefault();

@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

@Test
public void reorderingMethods_DoesNotModifyApi() throws IOException {
var prevSrc = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
import org.enso.test.utils.ContextUtils;
import org.enso.test.utils.ProjectUtils;
import org.enso.test.utils.SourceModule;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

public class DocsGenerateTest {
@ClassRule public static final TemporaryFolder TEMP = new TemporaryFolder();
@ClassRule public static final ContextUtils ctxRule = ContextUtils.createDefault();
@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

public DocsGenerateTest() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.enso.test.utils.ContextUtils;
import org.enso.test.utils.IRDumperTestWrapper;
import org.enso.test.utils.ProjectUtils;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
Expand All @@ -34,6 +35,7 @@ public class IRDumpTest {
private static final Path irDumpsDir = Path.of(IRDumpFactoryService.DEFAULT_DUMP_DIR);
private ByteArrayOutputStream out;

@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();
@Rule public PrintOutRule printOutRule = new PrintOutRule();

@BeforeClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import org.enso.test.utils.ContextUtils;
import org.enso.test.utils.ProjectUtils;
import org.enso.test.utils.SourceModule;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import scala.jdk.CollectionConverters;
Expand All @@ -33,6 +35,7 @@
public class BindingsMapResolutionTest {

@ClassRule public static final TemporaryFolder TMP_DIR = new TemporaryFolder();
@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

@Test
public void resolveSingleName_FromSingleImport() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.enso.compiler.test;

import static org.enso.compiler.test.ExecStrictCompilerTest.ctxRule;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
Expand All @@ -15,12 +14,14 @@
import org.enso.common.RuntimeOptions;
import org.enso.compiler.core.ir.expression.errors.Conversion.DeclaredAsPrivate$;
import org.enso.test.utils.ContextUtils;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.graalvm.polyglot.PolyglotException;
import org.graalvm.polyglot.Source;
import org.hamcrest.core.AllOf;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;

public class ExecCompilerTest {
Expand All @@ -30,6 +31,8 @@ public class ExecCompilerTest {
.withModifiedContext(ctxBldr -> ctxBldr.option(RuntimeOptions.STRICT_ERRORS, "false"))
.build();

@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

@After
public void cleanup() {
ctxRule.resetOut();
Expand Down Expand Up @@ -528,7 +531,8 @@ public void illegalPrivateConversion() {
var expectedErrMsg = DeclaredAsPrivate$.MODULE$.explain();
var runMethod = module.invokeMember(Module.EVAL_EXPRESSION, "run");
runMethod.execute(0);
assertThat(ctxRule.getOut(), containsString(expectedErrMsg));
assertThat(
String.join("\n", appenderRule.pendingLogMessages()), containsString(expectedErrMsg));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
import org.enso.common.MethodNames;
import org.enso.common.RuntimeOptions;
import org.enso.test.utils.ContextUtils;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.graalvm.polyglot.PolyglotException;
import org.graalvm.polyglot.Source;
import org.hamcrest.core.AllOf;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;

public class ExecStrictCompilerTest {
Expand All @@ -28,6 +30,8 @@ public class ExecStrictCompilerTest {
.withModifiedContext(ctxBldr -> ctxBldr.option(RuntimeOptions.STRICT_ERRORS, "true"))
.build();

@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

@After
public void cleanMessages() {
ctxRule.resetOut();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.enso.test.utils.ModuleUtils;
import org.enso.test.utils.ProjectUtils;
import org.enso.test.utils.SourceModule;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.graalvm.polyglot.PolyglotException;
import org.hamcrest.Matcher;
import org.junit.Rule;
Expand All @@ -24,6 +25,7 @@

public class ExportCycleDetectionTest {
@Rule public TemporaryFolder tempFolder = new TemporaryFolder();
@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

@Test
public void detectCycleInTwoModules() throws IOException {
Expand Down Expand Up @@ -103,38 +105,26 @@ public void detectCycleInThreeModules() throws IOException {

@Test
public void noCycleDetectedWhenExportingSymbolsFromItself_1() throws IOException {
var mainMod =
new SourceModule(
QualifiedName.fromString("Main"),
"""
expectNoCompilationErrors(
tempFolder.newFolder().toPath(),
"""
type Main_Type
export project.Main.Main_Type
""");
var projDir = tempFolder.newFolder().toPath();
ProjectUtils.createProject("Proj", Set.of(mainMod), projDir);
try (var ctx = ContextUtils.newBuilder().withProjectRoot(projDir).build()) {
var polyCtx = new PolyglotContext(ctx.context());
try {
polyCtx.getTopScope().compile(true);
} catch (PolyglotException e) {
fail("Compilation error not expected. But got: " + e);
}
var exportedSyms = ModuleUtils.getExportedSymbolsFromModule(ctx, "local.Proj.Main");
assertThat(exportedSyms.size(), is(1));
assertThat(exportedSyms, hasKey("Main_Type"));
}
}

@Test
public void noCycleDetectedWhenExportingSymbolsFromItself_2() throws IOException {
var mainMod =
new SourceModule(
QualifiedName.fromString("Main"),
"""
expectNoCompilationErrors(
tempFolder.newFolder().toPath(),
"""
type Main_Type
from project.Main export Main_Type
""");
var projDir = tempFolder.newFolder().toPath();
}

private void expectNoCompilationErrors(Path projDir, String code) throws IOException {
var mainMod = new SourceModule(QualifiedName.fromString("Main"), code);
ProjectUtils.createProject("Proj", Set.of(mainMod), projDir);
try (var ctx = ContextUtils.newBuilder().withProjectRoot(projDir).build()) {
var polyCtx = new PolyglotContext(ctx.context());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
import org.enso.test.utils.ContextUtils;
import org.enso.test.utils.ProjectUtils;
import org.enso.test.utils.SourceModule;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import scala.jdk.javaapi.CollectionConverters;

public class ExportedSymbolsTest {
private Path projDir;

@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

@Before
public void setup() throws IOException {
this.projDir = Files.createTempDirectory("exported-symbols-test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@
import com.oracle.truffle.api.library.ExportLibrary;
import com.oracle.truffle.api.library.ExportMessage;
import org.enso.test.utils.ContextUtils;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.graalvm.polyglot.PolyglotException;
import org.graalvm.polyglot.Value;
import org.hamcrest.Matchers;
import org.hamcrest.core.AllOf;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;

public class IfThenElseTest {
@ClassRule public static final ContextUtils ctxRule = ContextUtils.createDefault();
@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

@Test
public void simpleIfThenElse() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.enso.compiler.data.BindingsMap.ResolvedType;
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.test.utils.ContextUtils;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -47,6 +48,7 @@ public class ImportsAndFQNConsistencyTest {
.withModifiedContext(ctxBldr -> ctxBldr.option(RuntimeOptions.DISABLE_IR_CACHES, "false"))
.build();

@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();
@Rule public final TestRule printCodeRule = new PrintCodeRule();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
import org.enso.common.MethodNames;
import org.enso.common.RuntimeOptions;
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.logger.JulHandler;
import org.enso.pkg.PackageManager;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.io.IOAccess;
import org.junit.Rule;
import org.junit.Test;

public class SerializerTest {
Expand All @@ -28,14 +31,16 @@ public Context ensoContextForPackage(String name, File pkgFile) throws IOExcepti
.option(
RuntimeOptions.LANGUAGE_HOME_OVERRIDE,
Paths.get("../../distribution/component").toFile().getAbsolutePath())
.option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName())
.logHandler(System.err)
.option(RuntimeOptions.LOG_LEVEL, Level.FINE.getName())
.logHandler(JulHandler.get())
.allowAllAccess(true)
.build();
assertNotNull("Enso language is supported", ctx.getEngine().getLanguages().get("enso"));
return ctx;
}

@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

@Test
public void testSerializationOfFQNs() throws Exception {
var testName = "Test_Serializer_FQN";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public abstract class StaticAnalysisTest {
(builder) ->
builder
.option(RuntimeOptions.ENABLE_STATIC_ANALYSIS, "true")
.option(RuntimeOptions.LOG_LEVEL, Level.INFO.getName())
.option(RuntimeOptions.LOG_LEVEL, Level.SEVERE.getName())
.option(RuntimeOptions.LOG_LEVEL, Level.FINE.getName())
.out(OutputStream.nullOutputStream())
.err(OutputStream.nullOutputStream()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@
import org.enso.test.utils.ContextUtils;
import org.enso.test.utils.ModuleUtils;
import org.enso.test.utils.ProjectUtils;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.graalvm.polyglot.Source;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import scala.Option;

public class TypeInferenceTest extends StaticAnalysisTest {
@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

@Test
public void zeroAryCheck() throws Exception {
final URI uri = new URI("memory://zeroAryModuleMethodCheck.enso");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
import org.enso.compiler.pass.analyse.types.InferredType;
import org.enso.compiler.pass.analyse.types.TypeInferenceSignatures;
import org.enso.compiler.pass.analyse.types.TypeRepresentation;
import org.enso.testkit.ReportLogsOnFailureRule;
import org.graalvm.polyglot.Source;
import org.junit.Rule;
import org.junit.Test;
import scala.Option;

public class TypesFromSignaturesTest extends StaticAnalysisTest {
@Rule public ReportLogsOnFailureRule appenderRule = new ReportLogsOnFailureRule();

@Test
public void simpleCheck() throws Exception {
Expand Down
Loading
Loading