Skip to content
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
21 changes: 21 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ lazy val enso = (project in file("."))
`std-microsoft`,
`std-snowflake`,
`std-table`,
`std-tests`,
`std-tableau`,
`std-saas`,
`std-duckdb`,
Expand Down Expand Up @@ -5525,6 +5526,26 @@ lazy val `std-table` = project
.dependsOn(`poi-wrapper`)
.dependsOn(`std-base` % "provided")

lazy val `std-tests` = project
Copy link
Member Author

@JaroslavTulach JaroslavTulach Nov 12, 2025

Choose a reason for hiding this comment

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

@jdunkerley, it is possible to run these tests quickly:

sbt:enso> std-tests/clean
sbt:enso> std-tests/test
[info] Test run org.enso.base.polyglot.tests.EnsoMetaTest finished: 1 total, 3.595s
[info] Passed: Total 1, Failed 0, Errors 0, Passed 1

e.g. the test finished in less than four seconds (or in eleven seconds on CI).

Copy link
Member Author

Choose a reason for hiding this comment

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

  • originally I wanted to add these tests into std-table
  • but there is recursive project dependency
  • as test-utils depend on std-table (to have Enso distribution fully built)
  • and making std-table depend on test-utils was ... complicated...

.in(file("std-bits") / "tests")
.configs(Test)
.settings(
frgaalJavaCompilerSetting,
commands += WithDebugCommand.withDebug,
Test / fork := true,
autoScalaLibrary := false,
Compile / compile / compileInputs := (Compile / compile / compileInputs)
.dependsOn(SPIHelpers.ensureSPIConsistency)
.value,
libraryDependencies ++= Seq(
"junit" % "junit" % junitVersion % Test,
"com.github.sbt" % "junit-interface" % junitIfVersion % Test
)
)
.dependsOn(`std-base`)
.dependsOn(`std-table`)
.dependsOn(`test-utils`)

lazy val `opencv-wrapper` = project
.in(file("lib/java/opencv-wrapper"))
.enablePlugins(JarExtractPlugin)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.enso.base.polyglot.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.enso.base.polyglot.EnsoMeta;
import org.enso.test.utils.ContextUtils;
import org.graalvm.polyglot.PolyglotException;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;

public class EnsoMetaTest {
@ClassRule public static final ContextUtils ctx = ContextUtils.createDefault();

@BeforeClass
public static void importAll() {
ctx.eval("enso", "from Standard.Base import all");
}

@Test
public void loadErrorType() {
var errorType = EnsoMeta.getType("Standard.Base.Error", "Error");
Copy link
Member Author

Choose a reason for hiding this comment

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

To debug:

  • but breakpoint on line 23
  • let your IDE listen to port 5005
  • invoke following in the sbt
sbt:enso> project std-tests
sbt:std-tests> withDebug --debugger testOnly -- *EnsoMetaTest
obrazek

assertTrue("Is meta object", errorType.isMetaObject());
var fqn = errorType.getMetaQualifiedName();
assertEquals("Standard.Base.Error.Error", fqn);
var error = errorType.invokeMember("throw", "error message");
assertTrue("An error was created", error.isException());
try {
throw error.throwException();
} catch (PolyglotException ex) {
assertEquals("Converted to panic with the same exception", "error message", ex.getMessage());
}
}
}
Loading