Skip to content

Commit

Permalink
More intermediate refactoring, added forked module for thirdparty tests
Browse files Browse the repository at this point in the history
Changed Jawn tests to not run under Java 11.
  • Loading branch information
lefou committed Apr 9, 2022
1 parent 92b0341 commit 0af0a24
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 66 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ jobs:
buildcmd:
- ci/test-mill-release.sh
- ci/test-mill-dev.sh
# bootstrap tests
- ci/test-mill-bootstrap-0.sh
- ci/test-mill-bootstrap-1.sh
- ./mill -i -k "{main,scalalib,scalajslib,scalanativelib,bsp}.__.test"
- ./mill -i "integration.{local,forked}"
- ./mill -i -k "contrib.__.prepareOffline" + "contrib._.test"
# unit and module tests
- ./mill -i -k "{main,scalalib,scalajslib,scalanativelib,testrunner,bsp}.__.test"
# additional integration tests
- ./mill -i -k "integration.{local,forked}"
# integrtion tests of thirdparty repos
- ./mill -i -k "integration.test"
- ./mill -i -k "integration.test.forked"
# contrib tests
- ./mill -i -k "contrib._.test"
# - ./mill -i integration.test "mill.integration.local.JawnTests"
- ./mill -i integration.test "mill.integration.local.{AcyclicTests,AmmoniteTests}"
#- ./mill -i integration.test "mill.integration.local.{AcyclicTests,AmmoniteTests}"
- ./mill -i docs.antora.githubPages
# Caffeine tests require a published testng contrib module
- |
./mill -i contrib.testng.publishLocal
./mill -i integration.test "mill.integration.local.CaffeineTests"
include:
- java-version: 8
# buildcmd: ./mill -i integration.test "mill.integration.local.{BetterFilesTests,UpickleTests}"
buildcmd: ./mill -i integration.test "mill.integration.local.UpickleTests"
# Just some reporting to enable reasoning about library upgrades
- java-version: 8
buildcmd: |
Expand Down
68 changes: 41 additions & 27 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,8 @@ def testRepos = T {
)
}

val DefaultLocalMillReleasePath = s"target/mill-release${if (scala.util.Properties.isWin) ".bat" else ""}"
val DefaultLocalMillReleasePath =
s"target/mill-release${if (scala.util.Properties.isWin) ".bat" else ""}"

/**
* Build and install Mill locally.
Expand Down Expand Up @@ -924,49 +925,62 @@ def installLocalTask(binFile: Task[String], ivyRepo: String = null): Task[os.Pat

object integration extends MillScalaModule {
override def moduleDeps = Seq(main.moduledefs, scalalib, scalajslib, scalanativelib)
override def testArgs = T {
scalajslib.testArgs() ++
scalalib.worker.testArgs() ++
scalalib.backgroundwrapper.testArgs() ++
scalanativelib.testArgs() ++
Seq(
"-DMILL_TESTNG=" + contrib.testng.runClasspath().map(_.path).mkString(","),
"-DMILL_VERSION=" + millVersion(),
"-DMILL_SCALA_LIB=" + scalalib.runClasspath().map(_.path).mkString(","),
"-Djna.nosys=true"
)
}
override def forkArgs = testArgs()

/** Deploy freshly build mill for use in tests */
def testMill: Target[PathRef] = {
val name = if (scala.util.Properties.isWin) "mill.bat" else "mill"
T { PathRef(installLocalTask(binFile = T.task((T.dest / name).toString()))()) }
}

trait Tests extends super.Tests {
def workspaceDir = T.persistent {
PathRef(T.dest)
}
trait ITests extends super.Tests {
def workspaceDir = T.persistent { PathRef(T.dest) }
override def forkArgs: Target[Seq[String]] = T {
super.forkArgs() ++ Seq(
s"-DMILL_WORKSPACE_PATH=${workspaceDir().path}"
)
super.forkArgs() ++
scalajslib.testArgs() ++
scalalib.worker.testArgs() ++
scalalib.backgroundwrapper.testArgs() ++
scalanativelib.testArgs() ++
Seq(
s"-DMILL_WORKSPACE_PATH=${workspaceDir().path}",
s"-DMILL_TESTNG=${contrib.testng.runClasspath().map(_.path).mkString(",")}",
s"-DMILL_VERSION=${millVersion()}",
s"-DMILL_SCALA_LIB=${scalalib.runClasspath().map(_.path).mkString(",")}",
"-Djna.nosys=true"
)
}
}

// Test of various third-party repositories
object test extends Tests {
// TODO: rename to thirdparty
object test extends ITests {
override def forkArgs: Target[Seq[String]] = T {
super.forkArgs() ++
(for ((k, v) <- testRepos()) yield s"-D$k=$v")
super.forkArgs() ++ (for ((k, v) <- testRepos()) yield s"-D$k=$v")
}

override def runClasspath: T[Seq[PathRef]] = T {
// we need to trigger installation of testng-contrib for Caffeine
contrib.testng.publishLocal()()
super.runClasspath()
}
object forked extends ITests {
override def moduleDeps: Seq[JavaModule] = super.moduleDeps ++ Seq(integration.test)
override def forkEnv: Target[Map[String, String]] = super.forkEnv() ++ Map(
"MILL_TEST_RELEASE" -> testMill().path.toString()
)
override def forkArgs: Target[Seq[String]] = T {
super.forkArgs() ++ (for ((k, v) <- testRepos()) yield s"-D$k=$v")
}
}
}
object local extends Tests
object forked extends Tests {

// Integration test of Mill
object local extends ITests
object forked extends ITests {
override def moduleDeps: Seq[JavaModule] = super.moduleDeps ++ Seq(integration.local)

override def forkEnv: Target[Map[String, String]] = super.forkEnv() ++ Map(
"MILL_TEST_RELEASE" -> testMill().path.toString()
)
override def moduleDeps: Seq[JavaModule] = super.moduleDeps ++ Seq(integration.local)
}
}

Expand Down
10 changes: 10 additions & 0 deletions integration/test/forked/src/Tests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package mill.integration
package forked

object AcyclicTests extends AcyclicTests(fork = true)
object AmmoniteTests extends AmmoniteTests(fork = true)
object BetterFilesTests extends BetterFilesTests(fork = true)
object JawnTests extends JawnTests(fork = true)
object UpickleTests extends UpickleTests(fork = true)
object PlayJsonTests extends PlayJsonTests(fork = true)
object CaffeineTests extends CaffeineTests(fork = true)
26 changes: 15 additions & 11 deletions integration/test/src/JawnTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ class JawnTests(fork: Boolean) extends IntegrationTestSuite("MILL_JAWN_REPO", "j
initWorkspace()

def check(scalaVersion: String) = {
val firstCompile = eval(s"jawn[$scalaVersion].parser.test")
if (!sys.props("java.version").startsWith("1.")) {
println(s"*** Beware: Tests is not supported with this Java version! ***")
} else {
val firstCompile = eval(s"jawn[$scalaVersion].parser.test")

assert(
firstCompile,
os.walk(workspacePath).exists(_.last == "AsyncParser.class"),
os.walk(workspacePath).exists(_.last == "CharBuilderSpec.class")
)
assert(
firstCompile,
os.walk(workspacePath).exists(_.last == "AsyncParser.class"),
os.walk(workspacePath).exists(_.last == "CharBuilderSpec.class")
)

for (scalaFile <- os.walk(workspacePath).filter(_.ext == "scala")) {
os.write.append(scalaFile, "\n}")
}
for (scalaFile <- os.walk(workspacePath).filter(_.ext == "scala")) {
os.write.append(scalaFile, "\n}")
}

val brokenCompile = eval(s"jawn[$scalaVersion].parser.test")
val brokenCompile = eval(s"jawn[$scalaVersion].parser.test")

assert(!brokenCompile)
assert(!brokenCompile)
}
}

"scala21111" - check("2.11.11")
Expand Down
9 changes: 0 additions & 9 deletions integration/test/src/forked/Tests.scala

This file was deleted.

17 changes: 9 additions & 8 deletions integration/test/src/local/Tests.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package mill.integration.local
package mill.integration
package local

object AcyclicTests extends mill.integration.AcyclicTests(fork = false)
object AmmoniteTests extends mill.integration.AmmoniteTests(fork = false)
object BetterFilesTests extends mill.integration.BetterFilesTests(fork = false)
object JawnTests extends mill.integration.JawnTests(fork = false)
object UpickleTests extends mill.integration.UpickleTests(fork = false)
object PlayJsonTests extends mill.integration.PlayJsonTests(fork = false)
object CaffeineTests extends mill.integration.CaffeineTests(fork = false)
object AcyclicTests extends AcyclicTests(fork = false)
object AmmoniteTests extends AmmoniteTests(fork = false)
object BetterFilesTests extends BetterFilesTests(fork = false)
object JawnTests extends JawnTests(fork = false)
object UpickleTests extends UpickleTests(fork = false)
object PlayJsonTests extends PlayJsonTests(fork = false)
object CaffeineTests extends CaffeineTests(fork = false)

0 comments on commit 0af0a24

Please sign in to comment.