Skip to content

Commit

Permalink
add tests.sc to split tests from common.sc
Browse files Browse the repository at this point in the history
  • Loading branch information
sequencer committed Dec 6, 2023
1 parent 8425f40 commit d785936
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 2 deletions.
28 changes: 26 additions & 2 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import mill._
import mill.scalalib._
import mill.scalalib.TestModule._
import mill.scalalib.publish._
import mill.scalalib.scalafmt._
import coursier.maven.MavenRepository
import mill.define.Cross
import mill.scalalib.api.ZincWorkerUtil.matchingVersions
import $file.common
import $file.tests

object v {
val pluginScalaCrossVersions = Seq(
Expand Down Expand Up @@ -276,3 +276,27 @@ trait CIRCTPanamaBinderModuleTest
Seq(PathRef(millSourcePath / "src" / "test"))
}
}

object filecheckutility extends Cross[LitUtility](v.scalaCrossVersions)

trait LitUtility
extends tests.LitUtilityModule
with CrossModuleBase
with ScalafmtModule {
def millSourcePath = super.millSourcePath / "utility"
def circtPanamaBinderModule = circtpanamabinder(crossScalaVersion)
}

object lit extends Cross[Lit](v.scalaCrossVersions)

trait Lit
extends tests.LitModule
with Cross.Module[String] {
def scalaVersion: T[String] = crossValue
def runClasspath: T[Seq[os.Path]] = T(filecheckutility(crossValue).runClasspath().map(_.path))
def pluginJars: T[Seq[os.Path]] = T(Seq(filecheckutility(crossValue).circtPanamaBinderModule.pluginModule.jar().path))
def javaLibraryPath: T[Seq[os.Path]] = T(filecheckutility(crossValue).circtPanamaBinderModule.libraryPaths().map(_.path))
def javaHome: T[os.Path] = T(os.Path(sys.props("java.home")))
def chiselLitDir: T[os.Path] = T(millSourcePath)
def litConfigIn: T[PathRef] = T.source(millSourcePath / "tests" / "lit.site.cfg.py.in")
}
114 changes: 114 additions & 0 deletions tests.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import mill._
import mill.api.Result
import mill.scalalib._
import mill.scalalib.api.CompilationResult
import mill.util.Jvm

import java.util
import scala.jdk.StreamConverters.StreamHasToScala

trait SvsimUnitTestModule
extends TestModule
with ScalaModule
with TestModule.ScalaTest {
def svsimModule: common.SvsimModule

def scalatestIvy: Dep

def scalacheckIvy: Dep

override def moduleDeps = Seq(svsimModule)

override def defaultCommandName() = "test"

override def ivyDeps = super.ivyDeps() ++ Agg(
scalatestIvy,
scalacheckIvy
)
}

trait FirrtlUnitTestModule
extends TestModule
with ScalaModule
with TestModule.ScalaTest {
def firrtlModule: common.FirrtlModule

def scalatestIvy: Dep

def scalacheckIvy: Dep

override def moduleDeps = Seq(firrtlModule)

override def defaultCommandName() = "test"

override def ivyDeps = super.ivyDeps() ++ Agg(
scalatestIvy,
scalacheckIvy
)
}

trait ChiselUnitTestModule
extends TestModule
with ScalaModule
with common.HasChisel
with common.HasMacroAnnotations
with TestModule.ScalaTest {
def scalatestIvy: Dep

def scalacheckIvy: Dep

override def defaultCommandName() = "test"

override def ivyDeps = super.ivyDeps() ++ Agg(
scalatestIvy,
scalacheckIvy
)
}

trait CIRCTPanamaBinderModuleTestModule
extends TestModule
with ScalaModule
with common.HasCIRCTPanamaBinderModule
with common.HasMacroAnnotations
with TestModule.ScalaTest {
def scalatestIvy: Dep

def scalacheckIvy: Dep

override def defaultCommandName() = "test"

override def ivyDeps = super.ivyDeps() ++ Agg(
scalatestIvy,
scalacheckIvy
)
}

trait LitUtilityModule
extends ScalaModule
with common.HasCIRCTPanamaBinderModule
with common.HasMacroAnnotations

trait LitModule
extends Module {
def scalaVersion: T[String]
def runClasspath: T[Seq[os.Path]]
def pluginJars: T[Seq[os.Path]]
def javaLibraryPath: T[Seq[os.Path]]
def javaHome: T[os.Path]
def chiselLitDir: T[os.Path]
def litConfigIn: T[PathRef]
def litConfig: T[PathRef] = T {
os.write(
T.dest / "lit.site.cfg.py",
os.read(litConfigIn().path)
.replaceAll("@SCALA_VERSION@", scalaVersion())
.replaceAll("@RUN_CLASSPATH@", runClasspath().mkString(","))
.replaceAll("@SCALA_PLUGIN_JARS@", pluginJars().mkString(","))
.replaceAll("@JAVA_HOME@", javaHome().toString)
.replaceAll("@JAVA_LIBRARY_PATH@", javaLibraryPath().mkString(","))
.replaceAll("@CHISEL_LIT_DIR@", chiselLitDir().toString)
)
PathRef(T.dest)
}
def run(args: String*) = T.command(os.proc("llvm-lit", litConfig().path).call(T.dest, stdout = os.ProcessOutput.Readlines(line => T.ctx().log.debug("[lit] " + line))))
}

0 comments on commit d785936

Please sign in to comment.