Skip to content
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

Re-enabled Caffeine tests and some fixes #1500

Merged
merged 6 commits into from
Sep 27, 2021
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
11 changes: 9 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ jobs:
# - ./mill -i integration.test "mill.integration.local.JawnTests"
- ./mill -i integration.test "mill.integration.local.{AcyclicTests,AmmoniteTests,DocAnnotationsTests}"
- ./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"


runs-on: ubuntu-latest

steps:
Expand All @@ -37,11 +42,13 @@ jobs:
with:
java-version: ${{ matrix.java-version }}

- name: Run '${{ matrix.buildcmd }}'
- name: Prepare git config
run: |
git config --add user.name "Mill GithHub Actions"
git config --add user.email "mill-ci@localhost"
${{ matrix.buildcmd }}

- name: Run '${{ matrix.buildcmd }}'
run: ${{ matrix.buildcmd }}

test-windows:
strategy:
Expand Down
51 changes: 25 additions & 26 deletions integration/test/resources/play-json/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,35 @@ trait PlayJsonModule extends BaseModule with PublishModule /*with MiMa */{
}
}

def scalacOptions = Seq("-deprecation", "-feature", "-unchecked", "-encoding", "utf8")
def javacOptions = Seq("-encoding", "UTF-8", "-Xlint:-options")
override def scalacOptions = Seq("-deprecation", "-feature", "-unchecked", "-encoding", "utf8")
override def javacOptions = Seq("-encoding", "UTF-8", "-Xlint:-options")

def publishVersion = playJsonVersion.current
}

abstract class PlayJson(val platformSegment: String) extends PlayJsonModule {
def crossScalaVersion: String
def millSourcePath = os.pwd / "play-json"
def artifactName = "play-json"
override def millSourcePath = os.pwd / "play-json"
override def artifactName = "play-json"

def sources = T.sources(
override def sources = T.sources(
millSourcePath / platformSegment / "src" / "main",
millSourcePath / "shared" / "src" / "main"
)

def ivyDeps = Agg(
override def ivyDeps = Agg(
ivy"${scalaOrganization()}:scala-reflect:${scalaVersion()}",
ivy"org.typelevel::macro-compat::1.1.1"
)

private val macroParadise = ivy"org.scalamacros:::paradise:2.1.0"

def compileIvyDeps = Agg(
override def compileIvyDeps = Agg(
macroParadise,
ivy"${scalaOrganization()}:scala-compiler:${scalaVersion()}"
)

def scalacPluginIvyDeps = Agg(macroParadise)
override def scalacPluginIvyDeps = Agg(macroParadise)

// def mimaBinaryIssueFilters = Seq(
// // AbstractFunction1 is in scala.runtime and isn't meant to be used by end users
Expand All @@ -89,8 +89,7 @@ abstract class PlayJson(val platformSegment: String) extends PlayJsonModule {
// ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.JsonConfiguration.optionHandlers")
// )

def generatedSources = T {

override def generatedSources = T {

val dir = T.ctx.dest
os.makeDir.all(dir / "play-json")
Expand Down Expand Up @@ -144,11 +143,11 @@ abstract class PlayJson(val platformSegment: String) extends PlayJsonModule {

object playJsonJvm extends Cross[PlayJsonJvm](ScalaVersions:_*)
class PlayJsonJvm(val crossScalaVersion: String) extends PlayJson("jvm") {
def moduleDeps = Seq(playFunctionalJvm(crossScalaVersion))
override def moduleDeps = Seq(playFunctionalJvm(crossScalaVersion))

val jacksonVersion = "2.9.3"

def ivyDeps = super.ivyDeps() ++ Agg(
override def ivyDeps = super.ivyDeps() ++ Agg(
ivy"joda-time:joda-time:2.9.9",
ivy"com.fasterxml.jackson.core:jackson-core:$jacksonVersion",
ivy"com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion",
Expand All @@ -158,7 +157,7 @@ class PlayJsonJvm(val crossScalaVersion: String) extends PlayJson("jvm") {
)

trait Tests extends super.Tests {
def ivyDeps =
override def ivyDeps =
Agg(
ivy"org.scalatest::scalatest:3.0.5-M1",
ivy"org.scalacheck::scalacheck:1.13.5",
Expand All @@ -167,7 +166,7 @@ class PlayJsonJvm(val crossScalaVersion: String) extends PlayJson("jvm") {
specs2Core()
)

def sources = {
override def sources = {
val docSpecs = os.walk(millSourcePath / os.up / "docs" / "manual" / "working" / "scalaGuide")
.filter(os.isDir)
.filter(_.last=="code")
Expand All @@ -190,29 +189,29 @@ class PlayJsonJvm(val crossScalaVersion: String) extends PlayJson("jvm") {

object playJsonJs extends Cross[PlayJsonJs](ScalaVersions:_*)
class PlayJsonJs(val crossScalaVersion: String) extends PlayJson("js") with ScalaJSModule {
def moduleDeps = Seq(playFunctionalJs(crossScalaVersion))
override def moduleDeps = Seq(playFunctionalJs(crossScalaVersion))

def scalaJSVersion = "0.6.32"

// TODO: remove super[PlayJson].Tests with super[ScalaJSModule].Tests hack
object test extends super[PlayJson].Tests with super[ScalaJSModule].Tests with Scalariform with TestModule.ScalaTest /* with Headers*/ {
def ivyDeps =
override def ivyDeps =
Agg(
ivy"org.scalatest::scalatest::3.0.5-M1",
ivy"org.scalacheck::scalacheck::1.13.5",
ivy"com.chuusai::shapeless::2.3.3"
)

def sources = T.sources(
override def sources = T.sources(
millSourcePath / platformSegment / "src" / "test",
millSourcePath / "shared" / "src" / "test"
)
}
}

trait PlayFunctional extends PlayJsonModule {
def millSourcePath = os.pwd / "play-functional"
def artifactName = "play-functional"
override def millSourcePath = os.pwd / "play-functional"
override def artifactName = "play-functional"
}

object playFunctionalJvm extends Cross[PlayFunctionalJvm](ScalaVersions:_*)
Expand All @@ -225,26 +224,26 @@ class PlayFunctionalJs(val crossScalaVersion: String) extends PlayFunctional wit

object playJoda extends Cross[PlayJoda](ScalaVersions:_*)
class PlayJoda(val crossScalaVersion: String) extends PlayJsonModule {
def moduleDeps = Seq(playJsonJvm(crossScalaVersion))
override def moduleDeps = Seq(playJsonJvm(crossScalaVersion))

def millSourcePath = os.pwd / "play-json-joda"
def artifactName = "play-json-joda"
override def millSourcePath = os.pwd / "play-json-joda"
override def artifactName = "play-json-joda"

def ivyDeps = Agg(
override def ivyDeps = Agg(
ivy"joda-time:joda-time:2.9.9"
)

object test extends Tests with TestModule.Specs2 {
def ivyDeps = Agg(specs2Core())
override def ivyDeps = Agg(specs2Core())
}

}

object benchmarks extends Cross[Benchmarks](ScalaVersions:_*)
class Benchmarks(val crossScalaVersion: String) extends BaseModule with Jmh {
def moduleDeps = Seq(playJsonJvm(crossScalaVersion))
override def moduleDeps = Seq(playJsonJvm(crossScalaVersion))

def millSourcePath = os.pwd / "benchmarks"
override def millSourcePath = os.pwd / "benchmarks"
}

// TODO: we should have a way to "take all modules in this build"
Expand Down
51 changes: 51 additions & 0 deletions integration/test/src/CaffeineTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,57 @@ import utest._

class CaffeineTests(fork: Boolean)
extends IntegrationTestSuite("MILL_CAFFEINE_REPO", "caffeine", fork) {

override def initWorkspace() = {
val path = super.initWorkspace()
// Fixes for caffeine test suite under Java11
os.walk(workspacePath).foreach { p =>
p.last match {
case "AsMapTest.java" =>
println(s"Patching ${p} ...")
os.write.over(
p,
os.read.lines(p)
.map(
_.replace(
"map.keySet().toArray(null);",
"map.keySet().toArray((Integer[]) null);"
)
.replace(
"map.values().toArray(null);",
"map.values().toArray((Integer[]) null);"
)
.replace(
"map.entrySet().toArray(null);",
"map.entrySet().toArray((Integer[]) null);"
)
)
.mkString("\n")
)
case "EmptyCachesTest.java" =>
println(s"Patching ${p} ...")
os.write.over(
p,
os.read.lines(p)
.map(
_.replace("keys.toArray(null);", "keys.toArray((Object[]) null);")
.replace(
"values.toArray(null);",
"values.toArray((Object[]) null);"
)
.replace(
"entries.toArray(null);",
"entries.toArray((Entry<Object, Object>[]) null);"
)
)
.mkString("\n")
)
case _ => // no patching needed
}
}
path
}

val tests = Tests {
initWorkspace()
'test - {
Expand Down
43 changes: 1 addition & 42 deletions integration/test/src/IntegrationTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,55 +16,14 @@ abstract class IntegrationTestSuite(repoKey: String, val workspaceSlug: String,
wrapper
}

/** Files to copy into the workspace */
def buildFiles: Seq[os.Path] = os.walk(buildFilePath)

override def initWorkspace() = {
val path = super.initWorkspace()
buildFiles.foreach { file =>
os.copy.over(file, workspacePath / file.last)
}
os.walk(workspacePath).foreach { p =>
if (p.last == "AsMapTest.java") {
os.write.over(
p,
os.read
.lines(p)
.map(
_.replace(
"map.keySet().toArray(null);",
"map.keySet().toArray((Integer[]) null);"
)
.replace(
"map.values().toArray(null);",
"map.values().toArray((Integer[]) null);"
)
.replace(
"map.entrySet().toArray(null);",
"map.entrySet().toArray((Integer[]) null);"
)
)
.mkString("\n")
)
} else if (p.last == "EmptyCachesTest.java") {
os.write.over(
p,
os.read
.lines(p)
.map(
_.replace("keys.toArray(null);", "keys.toArray((Object[]) null);")
.replace(
"values.toArray(null);",
"values.toArray((Object[]) null);"
)
.replace(
"entries.toArray(null);",
"entries.toArray((Entry<Object, Object>[]) null);"
)
)
.mkString("\n")
)
}
}
assert(!os.walk(workspacePath).exists(_.ext == "class"))
path
}
Expand Down