mirror of https://github.com/sbt/sbt.git
[2.x] test: Add test for Test/baseDirectory (#9544)
This commit is contained in:
parent
731e666603
commit
67faa44a1d
|
|
@ -4,18 +4,18 @@ import Defaults._
|
|||
val groupSize = 3
|
||||
val groups = 3
|
||||
|
||||
@transient
|
||||
val check = TaskKey[Unit]("check", "Check all files were created and remove them.")
|
||||
val scalatest = "org.scalatest" %% "scalatest" % "3.0.5"
|
||||
val scalaxml = "org.scala-lang.modules" %% "scala-xml" % "1.1.1"
|
||||
val munit = "org.scalameta" %% "munit" % "1.0.4"
|
||||
|
||||
def groupId(idx: Int) = "group_" + (idx + 1)
|
||||
def groupPrefix(idx: Int) = groupId(idx) + "_file_"
|
||||
|
||||
Global / localCacheDirectory := baseDirectory.value / "diskcache"
|
||||
ThisBuild / scalaVersion := "2.12.21"
|
||||
ThisBuild / organization := "org.example"
|
||||
scalaVersion := "3.8.4"
|
||||
organization := "com.example"
|
||||
|
||||
lazy val root = (project in file("."))
|
||||
lazy val root = rootProject
|
||||
.settings(
|
||||
Test / testGrouping := Def.uncached {
|
||||
val tests = (Test / definedTests).value
|
||||
|
|
@ -38,7 +38,15 @@ lazy val root = (project in file("."))
|
|||
},
|
||||
concurrentRestrictions := Tags.limit(Tags.ForkedTestGroup, 2) :: Nil,
|
||||
libraryDependencies ++= List(
|
||||
scalaxml,
|
||||
scalatest % Test
|
||||
munit % Test
|
||||
)
|
||||
)
|
||||
|
||||
lazy val core = project
|
||||
.settings(
|
||||
Test / fork := true,
|
||||
libraryDependencies ++= List(
|
||||
munit % Test
|
||||
),
|
||||
Test / baseDirectory := (LocalRootProject / baseDirectory).value,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
import java.io.File
|
||||
|
||||
import munit.FunSuite
|
||||
|
||||
class FileTest extends FunSuite:
|
||||
test("test baseDirectory") {
|
||||
val x = new File("foo").getAbsoluteFile().getParentFile()
|
||||
assert(x.getName() != "core", s"actual ${x.getName()}")
|
||||
}
|
||||
end FileTest
|
||||
|
|
@ -1,16 +1,17 @@
|
|||
import org.scalatest.FlatSpec
|
||||
import java.io.File
|
||||
|
||||
trait Ensemble extends FlatSpec {
|
||||
def i: Int
|
||||
def prefix = System.getProperty("group.prefix")
|
||||
import munit.FunSuite
|
||||
|
||||
"an ensemble" should "create all files" in {
|
||||
val f = new File(prefix + i)
|
||||
f.createNewFile
|
||||
}
|
||||
}
|
||||
trait Ensemble extends FunSuite:
|
||||
def i: Int
|
||||
def prefix = System.getProperty("group.prefix")
|
||||
|
||||
test("an ensemble should create all files") {
|
||||
val f = new File(prefix + i)
|
||||
f.createNewFile
|
||||
}
|
||||
end Ensemble
|
||||
|
||||
class Ensemble1 extends Ensemble { def i = 1 }
|
||||
class Ensemble2 extends Ensemble { def i = 2 }
|
||||
class Ensemble3 extends Ensemble { def i = 3 }
|
||||
class Ensemble3 extends Ensemble { def i = 3 }
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
> test
|
||||
> check
|
||||
> testFull
|
||||
> check
|
||||
|
||||
> core/testFull
|
||||
|
|
|
|||
Loading…
Reference in New Issue