Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timaliberdov committed Jul 3, 2023
1 parent acf6564 commit bc6ed30
Show file tree
Hide file tree
Showing 22 changed files with 69 additions and 57 deletions.
6 changes: 4 additions & 2 deletions src/sbt-test/kotlin/basic-tests/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import kotlin.Keys._

import sbt.complete.Parsers.spaceDelimited

import scala.xml.{NodeSeq, XML}
Expand All @@ -13,7 +15,7 @@ checkTestPass := {
val args: Seq[String] = spaceDelimited("<arg>").parsed
val testName = args.head

val xml = XML.load(s"target/test-reports/$testName.xml")
val xml = XML.load(s"target/test-reports/TEST-$testName.xml")
val totalTests = getInt(xml \\ "testsuite" \ "@tests")
val failures = getInt(xml \\ "testsuite" \ "@failures")
val errors = getInt(xml \\ "testsuite" \ "@errors")
Expand All @@ -24,4 +26,4 @@ checkTestPass := {
}
}

def getInt(path: NodeSeq): Int = path.text.toInt
def getInt(path: NodeSeq): Int = path.text.toInt
15 changes: 6 additions & 9 deletions src/sbt-test/kotlin/basic-tests/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
val ver = System.getProperty("plugin.version")
if (ver == null)
throw new RuntimeException("""
|The system property 'plugin.version' is not defined.
|Specify this property using scriptedLaunchOpts -Dplugin.version."""
.stripMargin)
else addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % ver)
}
sys.props.get("plugin.version") match {
case Some(version) => addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % version)
case _ => sys.error(
"""The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -Dplugin.version.""".stripMargin)
}
1 change: 0 additions & 1 deletion src/sbt-test/kotlin/basic-tests/src/main/kotlin/simple.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ package demo
fun main(args: Array<String>) {
println("Hello, world!")
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ class SimpleTest {
assertEquals(4, 2 + 2)
}

}
}
2 changes: 1 addition & 1 deletion src/sbt-test/kotlin/basic-tests/test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
> compile
> test
> "checkTestPass SimpleTest"
> checkTestPass "SimpleTest"
4 changes: 3 additions & 1 deletion src/sbt-test/kotlin/basic/build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import kotlin.Keys._

kotlinLib("stdlib")

val listClasses = taskKey[Unit]("listClasses")

listClasses := {
val classes = (classDirectory in Compile).value.listFiles()
val classes = (Compile / classDirectory).value.listFiles()
streams.value.log.info("classes: " + classes)
}
15 changes: 6 additions & 9 deletions src/sbt-test/kotlin/basic/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
val ver = System.getProperty("plugin.version")
if (ver == null)
throw new RuntimeException("""
|The system property 'plugin.version' is not defined.
|Specify this property using scriptedLaunchOpts -Dplugin.version."""
.stripMargin)
else addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % ver)
}
sys.props.get("plugin.version") match {
case Some(version) => addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % version)
case _ => sys.error(
"""The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -Dplugin.version.""".stripMargin)
}
4 changes: 3 additions & 1 deletion src/sbt-test/kotlin/kotlin-1.2-compat/build.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import kotlin.Keys._

kotlinLib("stdlib")

kotlinVersion := "1.2.71"

val listClasses = taskKey[Unit]("listClasses")

listClasses := {
val classes = (classDirectory in Compile).value.listFiles()
val classes = (Compile / classDirectory).value.listFiles()
streams.value.log.info("classes: " + classes)
}
7 changes: 6 additions & 1 deletion src/sbt-test/kotlin/kotlin-1.2-compat/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % sys.props("plugin.version"))
sys.props.get("plugin.version") match {
case Some(version) => addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % version)
case _ => sys.error(
"""The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -Dplugin.version.""".stripMargin)
}
4 changes: 3 additions & 1 deletion src/sbt-test/kotlin/kotlin-1.3-compat/build.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import kotlin.Keys._

kotlinLib("stdlib")

kotlinVersion := "1.3.41"

val listClasses = taskKey[Unit]("listClasses")

listClasses := {
val classes = (classDirectory in Compile).value.listFiles()
val classes = (Compile / classDirectory).value.listFiles()
streams.value.log.info("classes: " + classes)
}
7 changes: 6 additions & 1 deletion src/sbt-test/kotlin/kotlin-1.3-compat/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % sys.props("plugin.version"))
sys.props.get("plugin.version") match {
case Some(version) => addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % version)
case _ => sys.error(
"""The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -Dplugin.version.""".stripMargin)
}
4 changes: 3 additions & 1 deletion src/sbt-test/kotlin/kotlin-script/build.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import kotlin.Keys._

kotlinLib("stdlib")

kotlinVersion := "1.3.21"

val listClasses = taskKey[Unit]("listClasses")

listClasses := {
val classes = (classDirectory in Compile).value.listFiles()
val classes = (Compile / classDirectory).value.listFiles()
streams.value.log.info("classes: " + classes)
}
1 change: 0 additions & 1 deletion src/sbt-test/kotlin/kotlin-script/project/build.properties

This file was deleted.

7 changes: 6 additions & 1 deletion src/sbt-test/kotlin/kotlin-script/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % sys.props("plugin.version"))
sys.props.get("plugin.version") match {
case Some(version) => addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % version)
case _ => sys.error(
"""The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -Dplugin.version.""".stripMargin)
}
6 changes: 4 additions & 2 deletions src/sbt-test/kotlin/mixed-tests/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import kotlin.Keys._

import sbt.complete.Parsers.spaceDelimited

import scala.xml.{NodeSeq, XML}
Expand All @@ -13,7 +15,7 @@ checkTestPass := {
val args: Seq[String] = spaceDelimited("<arg>").parsed
val testName = args.head

val xml = XML.load(s"target/test-reports/$testName.xml")
val xml = XML.load(s"target/test-reports/TEST-$testName.xml")
val totalTests = getInt(xml \\ "testsuite" \ "@tests")
val failures = getInt(xml \\ "testsuite" \ "@failures")
val errors = getInt(xml \\ "testsuite" \ "@errors")
Expand All @@ -24,4 +26,4 @@ checkTestPass := {
}
}

def getInt(path: NodeSeq): Int = path.text.toInt
def getInt(path: NodeSeq): Int = path.text.toInt
15 changes: 6 additions & 9 deletions src/sbt-test/kotlin/mixed-tests/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
val ver = System.getProperty("plugin.version")
if (ver == null)
throw new RuntimeException("""
|The system property 'plugin.version' is not defined.
|Specify this property using scriptedLaunchOpts -Dplugin.version."""
.stripMargin)
else addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % ver)
}
sys.props.get("plugin.version") match {
case Some(version) => addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % version)
case _ => sys.error(
"""The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -Dplugin.version.""".stripMargin)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class MixedTest {
assertEquals(4, calculator.sum(2, 2))
}

}
}
2 changes: 1 addition & 1 deletion src/sbt-test/kotlin/mixed-tests/test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
> compile
> test
> "checkTestPass MixedTest"
> checkTestPass "MixedTest"
2 changes: 2 additions & 0 deletions src/sbt-test/kotlin/mixed/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import kotlin.Keys._

kotlinLib("stdlib")

kotlincOptions += "-verbose"
15 changes: 5 additions & 10 deletions src/sbt-test/kotlin/mixed/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
val ver = System.getProperty("plugin.version")
if (ver == null)
throw new RuntimeException("""
|The system property 'plugin.version' is not defined.
|Specify this property using scriptedLaunchOpts -Dplugin.version."""
.stripMargin)
else addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % ver)
sys.props.get("plugin.version") match {
case Some(version) => addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % version)
case _ => sys.error(
"""The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -Dplugin.version.""".stripMargin)
}


3 changes: 1 addition & 2 deletions src/sbt-test/kotlin/mixed/src/main/kotlin/script.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

println("Hello from Kotlin script")
println("Hello from Kotlin script")
2 changes: 1 addition & 1 deletion src/sbt-test/kotlin/mixed/tests.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TaskKey[Unit]("check-classes") := {
val classes = (classDirectory in Compile).value
val classes = (Compile / classDirectory).value
val classList = (classes ** "*.class").get
if (classList.size != 7) {
throw new MessageOnlyException(s"Incorrect number of classes: ${classList.size} =>\n${classList.mkString("\n")}")
Expand Down

0 comments on commit bc6ed30

Please sign in to comment.