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 groupSize = 3
|
||||||
val groups = 3
|
val groups = 3
|
||||||
|
|
||||||
|
@transient
|
||||||
val check = TaskKey[Unit]("check", "Check all files were created and remove them.")
|
val check = TaskKey[Unit]("check", "Check all files were created and remove them.")
|
||||||
val scalatest = "org.scalatest" %% "scalatest" % "3.0.5"
|
val munit = "org.scalameta" %% "munit" % "1.0.4"
|
||||||
val scalaxml = "org.scala-lang.modules" %% "scala-xml" % "1.1.1"
|
|
||||||
|
|
||||||
def groupId(idx: Int) = "group_" + (idx + 1)
|
def groupId(idx: Int) = "group_" + (idx + 1)
|
||||||
def groupPrefix(idx: Int) = groupId(idx) + "_file_"
|
def groupPrefix(idx: Int) = groupId(idx) + "_file_"
|
||||||
|
|
||||||
Global / localCacheDirectory := baseDirectory.value / "diskcache"
|
Global / localCacheDirectory := baseDirectory.value / "diskcache"
|
||||||
ThisBuild / scalaVersion := "2.12.21"
|
scalaVersion := "3.8.4"
|
||||||
ThisBuild / organization := "org.example"
|
organization := "com.example"
|
||||||
|
|
||||||
lazy val root = (project in file("."))
|
lazy val root = rootProject
|
||||||
.settings(
|
.settings(
|
||||||
Test / testGrouping := Def.uncached {
|
Test / testGrouping := Def.uncached {
|
||||||
val tests = (Test / definedTests).value
|
val tests = (Test / definedTests).value
|
||||||
|
|
@ -38,7 +38,15 @@ lazy val root = (project in file("."))
|
||||||
},
|
},
|
||||||
concurrentRestrictions := Tags.limit(Tags.ForkedTestGroup, 2) :: Nil,
|
concurrentRestrictions := Tags.limit(Tags.ForkedTestGroup, 2) :: Nil,
|
||||||
libraryDependencies ++= List(
|
libraryDependencies ++= List(
|
||||||
scalaxml,
|
munit % Test
|
||||||
scalatest % 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
|
import java.io.File
|
||||||
|
|
||||||
trait Ensemble extends FlatSpec {
|
import munit.FunSuite
|
||||||
def i: Int
|
|
||||||
def prefix = System.getProperty("group.prefix")
|
|
||||||
|
|
||||||
"an ensemble" should "create all files" in {
|
trait Ensemble extends FunSuite:
|
||||||
val f = new File(prefix + i)
|
def i: Int
|
||||||
f.createNewFile
|
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 Ensemble1 extends Ensemble { def i = 1 }
|
||||||
class Ensemble2 extends Ensemble { def i = 2 }
|
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
|
> testFull
|
||||||
> check
|
> check
|
||||||
|
|
||||||
|
> core/testFull
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue