mirror of https://github.com/sbt/sbt.git
Adapt scripted tests to recent API changes
This commit is contained in:
parent
bf12a2b9c6
commit
33a7f6395a
|
|
@ -2,11 +2,11 @@ logLevel := Level.Debug
|
|||
|
||||
incOptions ~= { _.withApiDebug(true) }
|
||||
|
||||
TaskKey[Unit]("show-apis") <<= (compile in Compile, scalaSource in Compile, javaSource in Compile) map { (a: sbt.internal.inc.Analysis, scalaSrc: java.io.File, javaSrc: java.io.File) =>
|
||||
TaskKey[Unit]("show-apis") <<= (compile in Compile, scalaSource in Compile, javaSource in Compile) map { case (a: sbt.internal.inc.Analysis, scalaSrc: java.io.File, javaSrc: java.io.File) =>
|
||||
val aApi = a.apis.internalAPI(scalaSrc / "A.scala").api
|
||||
val jApi = a.apis.internalAPI(javaSrc / "test/J.java").api
|
||||
import xsbt.api.DefaultShowAPI
|
||||
import DefaultShowAPI._
|
||||
DefaultShowAPI.showSource.show(aApi)
|
||||
DefaultShowAPI.showSource.show(jApi)
|
||||
DefaultShowAPI(aApi)
|
||||
DefaultShowAPI(jApi)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// checks number of compilation iterations performed since last `clean` run
|
||||
InputKey[Unit]("check-number-of-compiler-iterations") <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
|
||||
(argTask, compile in Compile) map { (args: Seq[String], a: sbt.internal.inc.Analysis) =>
|
||||
(argTask, compile in Compile) map { case (args: Seq[String], a: sbt.internal.inc.Analysis) =>
|
||||
assert(args.size == 1)
|
||||
val expectedIterationsNumber = args(0).toInt
|
||||
val allCompilationsSize = a.compilations.allCompilations.size
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
incOptions := IncOptions.Default
|
||||
incOptions := xsbti.compile.IncOptionsUtil.defaultIncOptions
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ incOptions := incOptions.value.withNameHashing(false).withAntStyle(true)
|
|||
* b) checks overall number of compilations performed
|
||||
*/
|
||||
TaskKey[Unit]("check-compilations") := {
|
||||
val analysis = (compile in Compile).value
|
||||
val analysis = (compile in Compile).value match { case analysis: Analysis => analysis }
|
||||
val srcDir = (scalaSource in Compile).value
|
||||
def relative(f: java.io.File): java.io.File = f.relativeTo(srcDir) getOrElse f
|
||||
val allCompilations = analysis.compilations.allCompilations
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
TaskKey[Unit]("verify-binary-deps") <<= (compile in Compile, classDirectory in Compile, baseDirectory) map {
|
||||
(a: sbt.internal.inc.Analysis, classDir: java.io.File, base: java.io.File) =>
|
||||
case (a: sbt.internal.inc.Analysis, classDir: java.io.File, base: java.io.File) =>
|
||||
val nestedPkgClass = classDir / "test/nested.class"
|
||||
val fooSrc = base / "src/main/scala/test/nested/Foo.scala"
|
||||
assert(!a.relations.binaryDeps(fooSrc).contains(nestedPkgClass), a.relations.toString)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ logLevel := Level.Debug
|
|||
|
||||
// dumps analysis into target/analysis-dump.txt file
|
||||
InputKey[Unit]("check-number-of-compiler-iterations") <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
|
||||
(argTask, compile in Compile) map { (args: Seq[String], a: Analysis) =>
|
||||
(argTask, compile in Compile) map { case (args: Seq[String], a: Analysis) =>
|
||||
assert(args.size == 1)
|
||||
val expectedIterationsNumber = args(0).toInt
|
||||
assert(a.compilations.allCompilations.size == expectedIterationsNumber, "a.compilations.allCompilations.size = %d (expected %d)".format(a.compilations.allCompilations.size, expectedIterationsNumber))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
InputKey[Unit]("check-number-of-compiler-iterations") <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
|
||||
(argTask, compile in Compile) map { (args: Seq[String], a: Analysis) =>
|
||||
(argTask, compile in Compile) map { case (args: Seq[String], a: Analysis) =>
|
||||
assert(args.size == 1)
|
||||
val expectedIterationsNumber = args(0).toInt
|
||||
assert(a.compilations.allCompilations.size == expectedIterationsNumber, "a.compilations.allCompilations.size = %d (expected %d)".format(a.compilations.allCompilations.size, expectedIterationsNumber))
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ object TestPlugin extends AutoPlugin {
|
|||
import autoImport._
|
||||
override def projectSettings = Seq(
|
||||
savedReporter := new CollectingReporter,
|
||||
compilerReporter in (Compile, compile) := Some(savedReporter.value),
|
||||
compilerReporter in (Compile, compile) := savedReporter.value,
|
||||
problems := savedReporter.value.problems
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ scalaVersion := "2.10.4"
|
|||
|
||||
crossScalaVersions := List("2.10.4", "2.11.0")
|
||||
|
||||
incOptions := incOptions.value.withNewClassfileManager(
|
||||
ClassfileManager.transactional(
|
||||
incOptions := incOptions.value.withClassfileManagerType(
|
||||
xsbti.Maybe.just(new xsbti.compile.TransactionalManagerType(
|
||||
crossTarget.value / "classes.bak",
|
||||
(streams in (Compile, compile)).value.log
|
||||
)
|
||||
))
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
InputKey[Unit]("check-number-of-compiler-iterations") <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
|
||||
(argTask, compile in Compile) map { (args: Seq[String], a: Analysis) =>
|
||||
(argTask, compile in Compile) map { case (args: Seq[String], a: Analysis) =>
|
||||
assert(args.size == 1)
|
||||
val expectedIterationsNumber = args(0).toInt
|
||||
assert(a.compilations.allCompilations.size == expectedIterationsNumber, "a.compilations.allCompilations.size = %d (expected %d)".format(a.compilations.allCompilations.size, expectedIterationsNumber))
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ val checkIterations = inputKey[Unit]("Verifies the accumlated number of iteratio
|
|||
|
||||
checkIterations := {
|
||||
val expected: Int = (Space ~> NatBasic).parsed
|
||||
val actual: Int = (compile in Compile).value.compilations.allCompilations.size
|
||||
val actual: Int = (compile in Compile).value match { case a: Analysis => a.compilations.allCompilations.size }
|
||||
assert(expected == actual, s"Expected $expected compilations, got $actual")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ val checkIterations = inputKey[Unit]("Verifies the accumlated number of iteratio
|
|||
|
||||
checkIterations := {
|
||||
val expected: Int = (Space ~> NatBasic).parsed
|
||||
val actual: Int = (compile in Compile).value.compilations.allCompilations.size
|
||||
val actual: Int = (compile in Compile).value match { case a: Analysis => a.compilations.allCompilations.size }
|
||||
assert(expected == actual, s"Expected $expected compilations, got $actual")
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ incOptions := incOptions.value.withNameHashing(false)
|
|||
lazy val verifyDeps = taskKey[Unit]("verify inherited dependencies are properly extracted")
|
||||
|
||||
verifyDeps := {
|
||||
val a = compile.in(Compile).value
|
||||
val a = compile.in(Compile).value match { case a: Analysis => a }
|
||||
val baseDir = baseDirectory.value
|
||||
def relative(f: java.io.File): java.io.File = f.relativeTo(baseDir) getOrElse f
|
||||
def toFile(s: String) = relative(baseDir / (s + ".scala"))
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ incOptions := incOptions.value.withNameHashing(false)
|
|||
lazy val verifyDeps = taskKey[Unit]("verify inherited dependencies are properly extracted")
|
||||
|
||||
verifyDeps := {
|
||||
val a = compile.in(Compile).value
|
||||
val a = compile.in(Compile).value match { case a: Analysis => a }
|
||||
same(a.relations.publicInherited.internal.forwardMap, expectedDeps.forwardMap)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Check that a file has not been recompiled during last compilation
|
||||
InputKey[Unit]("check-not-recompiled") <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
|
||||
(argTask, compile in Compile) map { (args: Seq[String], a: Analysis) =>
|
||||
(argTask, compile in Compile) map { case (args: Seq[String], a: Analysis) =>
|
||||
assert(args.size == 1)
|
||||
val fileCompilation = a.apis.internal.collect { case (file, src) if file.name.endsWith(args(0)) => src.compilation }.head
|
||||
val lastCompilation = a.compilations.allCompilations.last
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
name := "test"
|
||||
|
||||
TaskKey[Unit]("check-same") <<= compile in Configurations.Compile map { analysis =>
|
||||
TaskKey[Unit]("check-same") <<= compile in Configurations.Compile map { case analysis: Analysis =>
|
||||
analysis.apis.internal foreach { case (_, api) =>
|
||||
assert( xsbt.api.SameAPI(api.api, api.api) )
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ val checkIterations = inputKey[Unit]("Verifies the accumlated number of iteratio
|
|||
|
||||
checkIterations := {
|
||||
val expected: Int = (Space ~> NatBasic).parsed
|
||||
val actual: Int = (compile in Compile).value.compilations.allCompilations.size
|
||||
val actual: Int = (compile in Compile).value match { case a: Analysis => a.compilations.allCompilations.size }
|
||||
assert(expected == actual, s"Expected $expected compilations, got $actual")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ val checkIterations = inputKey[Unit]("Verifies the accumlated number of iteratio
|
|||
|
||||
checkIterations := {
|
||||
val expected: Int = (Space ~> NatBasic).parsed
|
||||
val actual: Int = (compile in Compile).value.compilations.allCompilations.size
|
||||
val actual: Int = (compile in Compile).value match { case a: Analysis => a.compilations.allCompilations.size }
|
||||
assert(expected == actual, s"Expected $expected compilations, got $actual")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ val checkIterations = inputKey[Unit]("Verifies the accumlated number of iteratio
|
|||
|
||||
checkIterations := {
|
||||
val expected: Int = (Space ~> NatBasic).parsed
|
||||
val actual: Int = (compile in Compile).value.compilations.allCompilations.size
|
||||
val actual: Int = (compile in Compile).value match { case a: Analysis => a.compilations.allCompilations.size }
|
||||
assert(expected == actual, s"Expected $expected compilations, got $actual")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ incOptions := incOptions.value.withRecompileAllFraction(1.0)
|
|||
* b) checks overall number of compilations performed
|
||||
*/
|
||||
TaskKey[Unit]("check-compilations") := {
|
||||
val analysis = (compile in Compile).value
|
||||
val analysis = (compile in Compile).value match { case a: Analysis => a }
|
||||
val srcDir = (scalaSource in Compile).value
|
||||
def relative(f: java.io.File): java.io.File = f.relativeTo(srcDir) getOrElse f
|
||||
val allCompilations = analysis.compilations.allCompilations
|
||||
|
|
|
|||
Loading…
Reference in New Issue