diff --git a/DEVELOPING.md b/DEVELOPING.md index 8b1db7b09..40cbfda3a 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -151,14 +151,14 @@ suite with `sbt testOnly` #### Integration tests -Scripted integration tests reside in `sbt/src/sbt-test` and are +Scripted integration tests reside in `sbt-app/src/sbt-test` and are written using the same testing infrastructure sbt plugin authors can use to test their own plugins with sbt. You can read more about this style of tests [here](https://www.scala-sbt.org/1.0/docs/Testing-sbt-plugins). You can run the integration tests with the `sbt scripted` sbt command. To run a single test, such as the test in -`sbt/src/sbt-test/project/global-plugin`, simply run: +`sbt-app/src/sbt-test/project/global-plugin`, simply run: sbt "scripted project/global-plugin" diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index efd856a67..c199329f4 100644 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -1393,11 +1393,10 @@ object Defaults extends BuildCommon { val x = { import analysis.{ apis, relations => rel } rel.internalClassDeps(c).map(intlStamp(_, analysis, s + c)) ++ - rel.externalDeps(c).map(stamp) + - (apis.internal.get(c) match { - case Some(x) => x.compilationTimestamp - case _ => Long.MinValue - }) + rel.externalDeps(c).map(stamp) ++ + rel.productClassName.reverse(c).flatMap { pc => + apis.internal.get(pc).map(_.compilationTimestamp) + } + Long.MinValue }.max if (x != Long.MinValue) { stamps(c) = x diff --git a/sbt-app/src/sbt-test/tests/test-quick/build.sbt b/sbt-app/src/sbt-test/tests/test-quick/build.sbt index 0fb62b441..9fd396d27 100644 --- a/sbt-app/src/sbt-test/tests/test-quick/build.sbt +++ b/sbt-app/src/sbt-test/tests/test-quick/build.sbt @@ -1,9 +1,8 @@ val scalatest = "org.scalatest" %% "scalatest" % "3.0.5" -val scalaxml = "org.scala-lang.modules" %% "scala-xml" % "1.1.1" ThisBuild / scalaVersion := "2.12.12" lazy val root = (project in file(".")) .settings( - libraryDependencies ++= List(scalaxml, scalatest), + libraryDependencies += scalatest % Test, Test / parallelExecution := false ) diff --git a/sbt-app/src/sbt-test/tests/test-quick/changed/MathFunction.scala b/sbt-app/src/sbt-test/tests/test-quick/changed/MathFunction.scala new file mode 100644 index 000000000..1be75e613 --- /dev/null +++ b/sbt-app/src/sbt-test/tests/test-quick/changed/MathFunction.scala @@ -0,0 +1,3 @@ +object MathFunction { + def times2(i: Int): Int = 2 * 2 +} diff --git a/sbt-app/src/sbt-test/tests/test-quick/src/main/scala/MathFunction.scala b/sbt-app/src/sbt-test/tests/test-quick/src/main/scala/MathFunction.scala new file mode 100644 index 000000000..08d0ec501 --- /dev/null +++ b/sbt-app/src/sbt-test/tests/test-quick/src/main/scala/MathFunction.scala @@ -0,0 +1,3 @@ +object MathFunction { + def times2(i: Int): Int = i * 2 +} diff --git a/sbt-app/src/sbt-test/tests/test-quick/src/test/scala/Create.scala b/sbt-app/src/sbt-test/tests/test-quick/src/test/scala/Create.scala index 121de95b0..651807d8d 100644 --- a/sbt-app/src/sbt-test/tests/test-quick/src/test/scala/Create.scala +++ b/sbt-app/src/sbt-test/tests/test-quick/src/test/scala/Create.scala @@ -1,11 +1,10 @@ import org.scalatest.FlatSpec -import org.scalatest.matchers.ShouldMatchers -class Create extends FlatSpec with ShouldMatchers with Base { +class Create extends FlatSpec with Base { "a file" should "not exist" in { A(new B).foo - marker.exists should equal(false) - marker.createNewFile() should equal (true) + assert(marker.exists == false) + assert(marker.createNewFile() == true) } } diff --git a/sbt-app/src/sbt-test/tests/test-quick/src/test/scala/Delete.scala b/sbt-app/src/sbt-test/tests/test-quick/src/test/scala/Delete.scala index cd2eb6617..ff1caacb1 100644 --- a/sbt-app/src/sbt-test/tests/test-quick/src/test/scala/Delete.scala +++ b/sbt-app/src/sbt-test/tests/test-quick/src/test/scala/Delete.scala @@ -1,9 +1,8 @@ import org.scalatest.FlatSpec -import org.scalatest.matchers.ShouldMatchers -class Delete extends FlatSpec with ShouldMatchers with Base { +class Delete extends FlatSpec with Base { "a file" should "exist" in { - marker.exists should equal(true) + assert(marker.exists == true) marker.delete() } diff --git a/sbt-app/src/sbt-test/tests/test-quick/src/test/scala/MathFunctionSpec.scala b/sbt-app/src/sbt-test/tests/test-quick/src/test/scala/MathFunctionSpec.scala new file mode 100644 index 000000000..7ee6336da --- /dev/null +++ b/sbt-app/src/sbt-test/tests/test-quick/src/test/scala/MathFunctionSpec.scala @@ -0,0 +1,7 @@ +import org.scalatest.FlatSpec + +class MathFunctionTest extends FlatSpec { + "times2" should "double the input" in { + assert(MathFunction.times2(4) == 8) + } +} diff --git a/sbt-app/src/sbt-test/tests/test-quick/disabled b/sbt-app/src/sbt-test/tests/test-quick/test similarity index 82% rename from sbt-app/src/sbt-test/tests/test-quick/disabled rename to sbt-app/src/sbt-test/tests/test-quick/test index d88f8a185..c86f0276f 100644 --- a/sbt-app/src/sbt-test/tests/test-quick/disabled +++ b/sbt-app/src/sbt-test/tests/test-quick/test @@ -32,3 +32,9 @@ $ sleep 2000 -> testQuick Create > testQuick Delete > testQuick Create + +# https://github.com/sbt/sbt/issues/5504 +$ copy-file changed/MathFunction.scala src/test/scala/MathFunction.scala +> compile +$ sleep 2000 +-> testQuick MathFunctionTest