Skip to content

Commit

Permalink
Reworked test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
lefou committed Nov 24, 2023
1 parent 48f3b3a commit 9c7bbad
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 15 deletions.
6 changes: 3 additions & 3 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object Setup {
}
}

val setups = Seq(Setup.R010, Setup.R09, Setup.R07, Setup.R06)
val setups = Seq(Setup.R011, Setup.R010, Setup.R09, Setup.R07, Setup.R06)

object jbake extends Cross[JbakeCross](setups.map(_.millPlatform))
trait JbakeCross extends ScalaModule with PublishModule with Cross.Module[String] {
Expand Down Expand Up @@ -106,8 +106,8 @@ trait ItestCross extends MillIntegrationTestModule with Cross.Module[String] {
override def testInvocations: Target[Seq[(PathRef, Seq[TestInvocation.Targets])]] = T {
Seq(
PathRef(millSourcePath / "src" / "01-simple-site") -> Seq(
TestInvocation.Targets(Seq("verify")),
TestInvocation.Targets(Seq("site.jbake"))
TestInvocation.Targets(Seq("verifyInit")),
TestInvocation.Targets(Seq("verifyBake"))
)
)
}
Expand Down
71 changes: 62 additions & 9 deletions itest/src/01-simple-site/build.sc
Original file line number Diff line number Diff line change
@@ -1,28 +1,81 @@
import mill._
import mill.define._
// import $ivy.`de.tototec::de.tobiasroeser.mill.jbake:0.2.0`
import $exec.plugins
import $file.plugins
import de.tobiasroeser.mill.jbake._
import $ivy.`org.scalatest::scalatest:3.1.4`
import org.scalatest.Assertions

object site extends JBakeModule {

object siteSp extends JBakeModule {
override def jbakeVersion = "2.6.4"

override def jbakeProcessMode = JBakeModule.SubProcess
}

object siteCl extends JBakeModule {
override def jbakeVersion = "2.6.4"

override def jbakeProcessMode = JBakeModule.ClassLoader
}

def verify(): Command[Unit] = T.command {
val A = new Assertions {}

import A._

val A = new Assertions{}
import A._
val sites = Seq(siteSp, siteCl)

def verifyInit(site: JBakeModule): Task[Unit] = T.task {

site.jbakeInit()()
val files = os.walk(site.millSourcePath / "src")

assert(files.contains(site.millSourcePath / "src" / "templates"))
val expected = Seq(
os.sub / "jbake.properties",
os.sub / "templates" / "archive.ftl",
os.sub / "templates" / "feed.ftl",
os.sub / "templates" / "footer.ftl",
os.sub / "templates" / "header.ftl",
os.sub / "templates" / "index.ftl",
os.sub / "templates" / "menu.ftl",
os.sub / "templates" / "page.ftl",
os.sub / "templates" / "post.ftl",
os.sub / "templates" / "sitemap.ftl",
os.sub / "templates" / "tags.ftl",
os.sub / "content" / "about.html",
)

val dir = site.millSourcePath / "src"
val files = os.walk(dir)

for {
file <- expected
} assert(files.contains(dir / file))
}

def verifyBake(site: JBakeModule): Task[Unit] = T.task {
site.jbake()

val expected = Seq(
os.sub / "index.html",
os.sub / "favicon.ico",
os.sub / "feed.xml",
os.sub / "archive.html"

)

val dir = T.workspace / "out" / site.toString() / "jbake.dest"
val files = os.walk(dir)

for {
file <- expected
} assert(files.contains(dir / file))
}

def verifyInit(): Command[Unit] = T.command {
T.traverse(sites)(s => verifyInit(s))()
()
}

def verifyBake(): Command[Unit] = T.command {
// Classloader mode does not work anymore with newer Java
T.traverse(Seq(siteSp))(s => verifyBake(s))()
()
}
7 changes: 4 additions & 3 deletions jbake/src/de/tobiasroeser/mill/jbake/JBakeModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ trait JBakeModule extends Module with TaskModule {
parseVersion(jbakeVersion()) match {
case Success(Array(2, 0 | 1 | 2 | 3 | 4 | 5, _)) =>
(Seq(jbakeDistributionDir().path / "jbake-core.jar") ++
os.list(jbakeDistributionDir().path / 'lib)).map(PathRef(_))
os.list(jbakeDistributionDir().path / "lib")).map(PathRef(_))
case _ =>
os.list(jbakeDistributionDir().path / 'lib).map(PathRef(_))
os.list(jbakeDistributionDir().path / "lib").map(PathRef(_))
}
}

Expand Down Expand Up @@ -109,7 +109,7 @@ trait JBakeModule extends Module with TaskModule {
/**
* Initialized the sources for a new project.
*/
def jbakeInit() = T.command {
def jbakeInit(): Command[PathRef] = T.command {
val src = sources().head.path
if (os.exists(src) && !os.walk(src).isEmpty) {
throw new RuntimeException(s"Source directory ${src} is not empty. Aborting initialization of fresh JBake project")
Expand All @@ -119,6 +119,7 @@ trait JBakeModule extends Module with TaskModule {
// val baseZip = ???
// IO.unpackZip(baseZip, )
}
PathRef(T.ctx().dest)
}

/**
Expand Down

0 comments on commit 9c7bbad

Please sign in to comment.