Skip to content

Commit

Permalink
Fix porguard test runner which was never working as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
lefou committed Dec 17, 2020
1 parent 8254789 commit f838a92
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
6 changes: 6 additions & 0 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,12 @@ object contrib extends MillModule {

object proguard extends MillModule {
override def compileModuleDeps = Seq(scalalib)
override def testArgs = T {
Seq(
"-DMILL_SCALA_LIB=" + scalalib.runClasspath().map(_.path).mkString(","),
"-DMILL_PROGUARD_LIB=" + runClasspath().map(_.path).mkString(",")
) ++ scalalib.worker.testArgs()
}
}

object tut extends MillModule {
Expand Down
34 changes: 21 additions & 13 deletions contrib/proguard/test/src/ProguardTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,27 @@ import utest.framework.TestPath

object ProguardTests extends TestSuite {

object Proguard
extends TestUtil.BaseModule
with scalalib.ScalaModule
with Proguard {
object proguard extends TestUtil.BaseModule with ScalaModule with Proguard {
// override build root to test custom builds/modules
override def millSourcePath: Path = TestUtil.getSrcPathStatic()
// override def millSourcePath: Path = TestUtil.getSrcPathStatic()
override def millSourcePath: os.Path =
TestUtil.getSrcPathBase() / millOuterCtx.enclosing.split('.')

override def scalaVersion = "2.12.0"

def proguardContribClasspath = T{
mill.modules.Util.millProjectModule("MILL_PROGUARD_LIB", "mill-contrib-proguard", repositoriesTask())
}

override def runClasspath: Target[Seq[PathRef]] = T{super.runClasspath() ++ proguardContribClasspath()}

}

val testModuleSourcesPath: Path = os.pwd / 'contrib / 'proguard / 'test / 'resources / "proguard"
val testModuleSourcesPath
: Path = os.pwd / 'contrib / 'proguard / 'test / 'resources / "proguard"

def workspaceTest[T](m: TestUtil.BaseModule)(t: TestEvaluator => T)(
implicit tp: TestPath): T = {
implicit tp: TestPath): T = {
val eval = new TestEvaluator(m)
os.remove.all(m.millSourcePath)
os.remove.all(eval.outPath)
Expand All @@ -34,14 +42,14 @@ object ProguardTests extends TestSuite {
}

def tests: Tests = Tests {
'proguard - {
"should download proguard jars" - workspaceTest(Proguard) { eval =>
val Right((agg, _)) = eval.apply(Proguard.proguardClasspath)
assert(!agg.isEmpty)
test("Proguard module") {
test("should download proguard jars") - workspaceTest(proguard) { eval =>
val Right((agg, _)) = eval.apply(proguard.proguardClasspath)
assert(!agg.iterator.toSeq.isEmpty)
}

"create proguarded jar" - workspaceTest(Proguard) { eval =>
val Right((path, _)) = eval.apply(Proguard.proguard)
test("should create a proguarded jar") - workspaceTest(proguard) { eval =>
val Right((path, _)) = eval.apply(proguard.proguard)
assert(os.exists(path.path))
}

Expand Down

0 comments on commit f838a92

Please sign in to comment.