-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add NativeImageTest and nativeImageTestRun * add nativeImageTestRunAgent * add basic-test * fix imports in basic-test * add cross-build-test * fix nativeImageTestRunAgent * add agent-test * remove new line from test output * nativeImageTestAgentOutputDir same as nativeImageAgentOutputDir by default * add nativeImageTestRunOptions * log command
- Loading branch information
Showing
20 changed files
with
365 additions
and
3 deletions.
There are no files selected for viewing
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
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,21 @@ | ||
lazy val example = project | ||
.settings( | ||
scalaVersion := "2.12.12", | ||
mainClass.in(Compile) := Some("example.Hello6"), | ||
nativeImageTestOptions ++= Seq( | ||
s"-H:ReflectionConfigurationFiles=${target.value / "native-image-configs" / "reflect-config.json"}", | ||
"--initialize-at-build-time=scala.collection.immutable.VM", | ||
), | ||
mainClass.in(Test) := Some("org.scalatest.tools.Runner"), | ||
nativeImageTestRunOptions ++= Seq("-o", "-R", classDirectory.in(Test).value.absolutePath), | ||
nativeImageCommand := List( | ||
sys.env.getOrElse( | ||
"NATIVE_IMAGE_COMMAND", | ||
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " + | ||
"To fix this problem, manually install GraalVM native-image and update the environment " + | ||
"variable to point to the absolute path of this binary." | ||
) | ||
), | ||
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.14" % "test" | ||
) | ||
.enablePlugins(NativeImagePlugin) |
22 changes: 22 additions & 0 deletions
22
plugin/src/sbt-test/sbt-native-image/agent-test/example/src/main/scala/example/Hello6.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package example | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
import java.nio.charset.StandardCharsets | ||
|
||
object Hello6 { | ||
def main(args: Array[String]): Unit = { | ||
val cl = this.getClass.getClassLoader | ||
val c = cl.loadClass("example.Hello6") | ||
val h3 = c.getConstructor().newInstance() | ||
val text = h3.toString | ||
Files.write( | ||
Paths.get("hello6.obtained"), | ||
text.getBytes(StandardCharsets.UTF_8) | ||
) | ||
} | ||
} | ||
|
||
class Hello6 { | ||
override def toString: String = "Hello 6" | ||
} |
23 changes: 23 additions & 0 deletions
23
.../src/sbt-test/sbt-native-image/agent-test/example/src/test/scala/example/Hello6Spec.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package example | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
|
||
import java.io.File | ||
import java.nio.charset.StandardCharsets | ||
import java.nio.file.{Files, Paths, StandardOpenOption} | ||
|
||
class Hello6Spec extends AnyFlatSpec { | ||
|
||
behavior of "Hello6" | ||
|
||
it should "append Hello6 output" in { | ||
Hello6.main(Array.empty) | ||
assert(new File("Hello6.obtained").exists()) | ||
|
||
Files.write( | ||
Paths.get("Hello6.obtained"), | ||
"-tested".getBytes(StandardCharsets.UTF_8), | ||
StandardOpenOption.APPEND | ||
) | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
plugin/src/sbt-test/sbt-native-image/agent-test/hello6.expected
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 @@ | ||
Hello 6-tested |
1 change: 1 addition & 0 deletions
1
plugin/src/sbt-test/sbt-native-image/agent-test/project/plugins.sbt
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 @@ | ||
addSbtPlugin("org.scalameta" % "sbt-native-image" % sys.props("plugin.version")) |
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 @@ | ||
> example/nativeImageTestRunAgent | ||
$ delete hello6.obtained | ||
> example/nativeImageTest | ||
$ absent hello6.obtained | ||
> example/nativeImageTestRun | ||
$ must-mirror hello6.expected hello6.obtained |
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,20 @@ | ||
lazy val example = project | ||
.settings( | ||
scalaVersion := "2.12.12", | ||
mainClass.in(Compile) := Some("example.Hello4"), | ||
nativeImageCommand := List( | ||
sys.env.getOrElse( | ||
"NATIVE_IMAGE_COMMAND", | ||
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " + | ||
"To fix this problem, manually install GraalVM native-image and update the environment " + | ||
"variable to point to the absolute path of this binary." | ||
) | ||
), | ||
nativeImageTestOptions ++= Seq( | ||
"--initialize-at-build-time=scala.collection.immutable.VM" | ||
), | ||
mainClass.in(Test) := Some("org.scalatest.tools.Runner"), | ||
nativeImageTestRunOptions ++= Seq("-o", "-R", classDirectory.in(Test).value.absolutePath), | ||
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.14" % "test" | ||
) | ||
.enablePlugins(NativeImagePlugin) |
15 changes: 15 additions & 0 deletions
15
plugin/src/sbt-test/sbt-native-image/basic-test/example/src/main/scala/example/Hello4.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package example | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
import java.nio.charset.StandardCharsets | ||
|
||
object Hello4 { | ||
def main(args: Array[String]): Unit = { | ||
val text = List(1, 2, 3, 4).toString() | ||
Files.write( | ||
Paths.get("hello4.obtained"), | ||
text.getBytes(StandardCharsets.UTF_8) | ||
) | ||
} | ||
} |
Oops, something went wrong.