-
Notifications
You must be signed in to change notification settings - Fork 323
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
Run unit tests with truffle-compiler #8467
Merged
Merged
Changes from 22 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
af6d619
logging-service-logback is JPMS module
Akirathan 8f6157e
runtime uses truffle-compiler in tests
Akirathan 2f7521e
Revert "logging-service-logback is JPMS module"
Akirathan 308f8e8
Refactor Test/options to a separate task
Akirathan 5dc8572
Provide a default logback-test logging config for tests
Akirathan b99c4a9
Do not add runtime-with-instruments to --patch-module
Akirathan 9357291
Refactor mutable ListBuffer to List
Akirathan d3c5048
Introduce runtime-fat-jar project.
Akirathan 3e0c531
compileModuleInfo task does not copy anything unless necessary
Akirathan ec95060
Merge branch 'develop' into wip/akirathan/8374-compiler-to-tests
Akirathan 1c516be
JPMSUtils.filterModules filters only distinct modules
Akirathan 0dd0056
Make sure that all GraalVM modules (including truffle langs) are in -…
Akirathan 4a9c962
Create new module org.enso.interpreter.test
Akirathan 81ec91e
module-info.java is not compiled every time
Akirathan ea70d95
Revert "Create new module org.enso.interpreter.test"
Akirathan 1d42a25
Add skeleton of JPMSPlugin auto plugin.
Akirathan 2af02fb
Add runtime-test-instruments project.
Akirathan 95381be
Fix VectorTests in runtime
Akirathan 6997cff
Fix the rest of runtime tests
Akirathan ffd95c4
runtime-with-instruments/test run with truffle-compiler
Akirathan acb27fc
fmt
Akirathan 78c40a1
Fix some sbt issues with lazy val settings
Akirathan b98526e
Use service provider instead of reflection in runtime-test-instruments
Akirathan 07f5fa4
Port NodeCountingTestInstrument into runtime-test-instruments
Akirathan 05b221a
Merge runtime-with-instruments project into runtime/Test
Akirathan b66b3d7
Merge runtime-with-polyglot project into runtime/Test
Akirathan c9bf46f
Run runtime/test without -ea
Akirathan b68412e
fmt
Akirathan a4a82ab
Merge branch 'develop' into wip/akirathan/8374-compiler-to-tests
Akirathan 111cda6
Include insight tool in runtime/Test
Akirathan 256fb9c
withDebug command has better error message
Akirathan efa56f8
Remove BigNumberTest.averageOfMixedArrayOverDouble.
Akirathan b64d2b4
Fix context dispose in MetaObjectTest
Akirathan c3264d7
project-manager/test runs with truffle-compiler
Akirathan 303d272
language-server/test runs with truffle-compiler
Akirathan 0ac7249
JPMSUtils.compileModuleInfo takes an extraModulePath optional argument
Akirathan 283fecb
Merge branch 'develop' into wip/akirathan/8374-compiler-to-tests
Akirathan b9e1c3d
Small fixes after merge
Akirathan 9d5071f
langauge-server/test uses enso TestLogProvider
Akirathan 8c90c5e
Add necessary modules on modulePath to language-server/test
Akirathan 1ce3069
Add --patch-module option to language-server/test
Akirathan a342562
runtime/test uses Enso TestLogProvider
Akirathan 3d097ee
Fix DebuggingEnsoTest.
Akirathan 9ecbd68
Make sure runtime/test is run with -ea
Akirathan e8846cc
Make sure runtime/test is run with -ea
Akirathan e580ed9
Remove dependency on com.sandinh.sbt-java-module-info plugin
Akirathan e7171e9
CLeanup some unused methods
Akirathan e8ca9a9
fmt
Akirathan ef71ecf
project-manager/test uses TestLogProvider
Akirathan 9820863
Remove unused logback-test.xml resource
Akirathan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
engine/runtime-test-instruments/src/main/java/module-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module org.enso.runtime.test { | ||
requires org.graalvm.truffle; | ||
|
||
exports org.enso.interpreter.test.instruments; | ||
|
||
provides com.oracle.truffle.api.instrumentation.provider.TruffleInstrumentProvider with | ||
org.enso.interpreter.test.instruments.CodeIdsTestInstrumentProvider, | ||
org.enso.interpreter.test.instruments.CodeLocationsTestInstrumentProvider; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ter/test/CodeLocationsTestInstrument.java → ...truments/CodeLocationsTestInstrument.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
engine/runtime-with-instruments/src/test/java/module-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
open module org.enso.runtime.with.instruments { | ||
requires org.enso.runtime; | ||
requires org.graalvm.truffle; | ||
// TODO: Provides instrument | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
engine/runtime/src/test/scala/org/enso/interpreter/test/InterpreterTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
lib/scala/logging-service-logback/src/test/resources/logback-test.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<!-- encoders are assigned the type | ||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | ||
<encoder> | ||
<pattern>[%d{HH:mm:ss.SSS}] [%-5level] [%logger{36}] -%kvp- %msg%n</pattern> | ||
</encoder> | ||
<!-- deny all events with a level below WARN, that is INFO, DEBUG and TRACE --> | ||
<!-- Accepts only WARN and ERROR --> | ||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
<level>WARN</level> | ||
</filter> | ||
</appender> | ||
|
||
<root level="debug"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
import sbt.* | ||
import sbt.Keys.* | ||
import sbt.internal.inc.{CompileOutput, PlainVirtualFile} | ||
import sbt.util.CacheStore | ||
import sbtassembly.Assembly.{Dependency, JarEntry, Project} | ||
import sbtassembly.{CustomMergeStrategy, MergeStrategy} | ||
import xsbti.compile.IncToolOptionsUtil | ||
|
||
import java.io.File | ||
|
||
/** An automatic plugin that handles everything related to JPMS modules. One needs to explicitly | ||
* enable this plugin in a project with `.enablePlugins(JPMSPlugin)`. The keys and tasks provided by this plugin | ||
* corresponds to the module-related options of `javac` and `java` commands. | ||
* | ||
* This plugin injects all the module-specific options to `javaOptions`, based on | ||
* the settings of this plugin. | ||
* | ||
* If this plugin is enabled, and no settings/tasks from this plugin are used, then the plugin will | ||
* not inject anything into `javaOptions` or `javacOptions`. | ||
*/ | ||
object JPMSPlugin extends AutoPlugin { | ||
object autoImport { | ||
val javaModuleName = | ||
settingKey[String]("The name of the Java (JPMS) module") | ||
val addModules = settingKey[Seq[String]]( | ||
"Module names that will be added to --add-modules option" | ||
) | ||
val modulePath = taskKey[Seq[File]]( | ||
"Directories (Jar archives or expanded Jar archives) that will be put into " + | ||
"--module-path option" | ||
) | ||
val patchModules = taskKey[Map[String, Seq[File]]]( | ||
""" | ||
|A map of module names to directories (Jar archives or expanded Jar archives) that will be | ||
|put into --patch-module option. | ||
|""".stripMargin | ||
) | ||
val addExports = taskKey[Map[String, Seq[String]]]( | ||
""" | ||
|A map of module names to packages that will be put into --add-exports option. | ||
|The format of `--add-exports` option is `module/package=target-module(,target-module)*` | ||
|The key in the map is `module/package` and the value is a sequence of target modules | ||
|""".stripMargin | ||
) | ||
val addReads = taskKey[Map[String, Seq[String]]]( | ||
""" | ||
|A map of module names to modules that will be put into --add-reads option. | ||
|When a module A reads a module B, it means that it "depends" on it - it has the same | ||
|effect as if module A would have `requires B` in its module-info.java file. | ||
|""".stripMargin | ||
) | ||
val compileModuleInfo = taskKey[Unit]("Compile module-info.java") | ||
val modulePathTestOptions_ = taskKey[Seq[String]]( | ||
"Assembles options for the JVM for running tests with all the required modules. " + | ||
"Including truffle-compiler and org.enso.runtime modules and all their dependencies." | ||
) | ||
} | ||
|
||
import autoImport.* | ||
|
||
override lazy val projectSettings: Seq[Setting[_]] = Seq( | ||
addModules := Seq.empty, | ||
modulePath := Seq.empty, | ||
patchModules := Map.empty, | ||
addExports := Map.empty, | ||
addReads := Map.empty, | ||
compileModuleInfo := {}, | ||
// javacOptions only inject --module-path and --add-modules, not the rest of the | ||
// options. | ||
Compile / javacOptions ++= { | ||
constructOptions( | ||
streams.value.log, | ||
modulePath = (Compile / modulePath).value, | ||
addModules = (Compile / addModules).value | ||
) | ||
}, | ||
Compile / javaOptions ++= { | ||
constructOptions( | ||
streams.value.log, | ||
(Compile / modulePath).value, | ||
(Compile / addModules).value, | ||
(Compile / patchModules).value, | ||
(Compile / addExports).value, | ||
(Compile / addReads).value | ||
) | ||
}, | ||
Test / javacOptions ++= { | ||
constructOptions( | ||
streams.value.log, | ||
modulePath = (Test / modulePath).value, | ||
addModules = (Test / addModules).value | ||
) | ||
}, | ||
Test / javaOptions ++= { | ||
constructOptions( | ||
streams.value.log, | ||
(Test / modulePath).value, | ||
(Test / addModules).value, | ||
(Test / patchModules).value, | ||
(Test / addExports).value, | ||
(Test / addReads).value | ||
) | ||
} | ||
) | ||
|
||
def constructOptions( | ||
log: Logger, | ||
modulePath: Seq[File], | ||
addModules: Seq[String] = Seq.empty, | ||
patchModules: Map[String, Seq[File]] = Map.empty, | ||
addExports: Map[String, Seq[String]] = Map.empty, | ||
addReads: Map[String, Seq[String]] = Map.empty | ||
): Seq[String] = { | ||
val patchOpts: Seq[String] = patchModules.flatMap { | ||
case (moduleName, dirsToPatch) => | ||
ensureDirectoriesExist(dirsToPatch, log) | ||
val patchStr = dirsToPatch | ||
.map(_.getAbsolutePath) | ||
.mkString(File.pathSeparator) | ||
Seq( | ||
"--patch-module", | ||
s"$moduleName=$patchStr" | ||
) | ||
}.toSeq | ||
|
||
ensureDirectoriesExist(modulePath, log) | ||
|
||
val addExportsOpts: Seq[String] = addExports.flatMap { | ||
case (modPkgName, targetModules) => | ||
if (!modPkgName.contains("/")) { | ||
log.error(s"JPMSPlugin: Invalid module/package name: $modPkgName") | ||
} | ||
Seq( | ||
"--add-exports", | ||
modPkgName + "=" + targetModules.mkString(",") | ||
) | ||
}.toSeq | ||
|
||
val modulePathOpts = if (modulePath.isEmpty) { | ||
Seq.empty | ||
} else { | ||
Seq( | ||
"--module-path", | ||
modulePath.map(_.getAbsolutePath).mkString(File.pathSeparator) | ||
) | ||
} | ||
|
||
val addModsOpts = if (addModules.isEmpty) { | ||
Seq.empty | ||
} else { | ||
Seq( | ||
"--add-modules", | ||
addModules.mkString(",") | ||
) | ||
} | ||
|
||
val addReadsOpts = addReads.flatMap { case (modName, targetModules) => | ||
Seq( | ||
"--add-reads", | ||
modName + "=" + targetModules.mkString(",") | ||
) | ||
}.toSeq | ||
|
||
modulePathOpts ++ addModsOpts ++ patchOpts ++ addExportsOpts ++ addReadsOpts | ||
} | ||
|
||
/** Java does not mandate that the directories specified in the module path or | ||
* in --patch-module exist, but it is usefull to report at least warnings. | ||
* @param dirs | ||
* @param log | ||
*/ | ||
private def ensureDirectoriesExist( | ||
dirs: Seq[File], | ||
log: Logger | ||
): Unit = { | ||
dirs.foreach { dir => | ||
if (!dir.exists()) { | ||
log.warn(s"JPMSPlugin: Directory $dir does not exist.") | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate module & module info for test only instruments is a good idea.