From 2a3ea0837b574c33aaaebcfe4a759e46b4dc2791 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 15 Sep 2024 03:57:48 -0400 Subject: [PATCH] feat: Rename testQuick to test **Problem** We have incremental testing, but it's not used by default. **Solution** This renames testQuick to test, and test to testFull. --- main/src/main/scala/sbt/Defaults.scala | 9 +++++---- main/src/main/scala/sbt/Keys.scala | 5 +++-- .../scala/sbt/internal/server/BuildServerProtocol.scala | 2 +- sbt-app/src/sbt-test/tests/fork-parallel/test | 4 ++-- .../tests/fork-test-group-parallel-custom-tags/build.sbt | 2 +- .../tests/fork-test-group-parallel-custom-tags/test | 4 ++-- .../sbt-test/tests/fork-test-group-parallel/build.sbt | 2 +- sbt-app/src/sbt-test/tests/fork-test-group-parallel/test | 4 ++-- sbt-app/src/sbt-test/tests/fork2/build.sbt | 3 +-- sbt-app/src/sbt-test/tests/fork2/test | 8 ++++---- sbt-app/src/sbt-test/tests/junit-xml-report/test | 6 +++--- sbt-app/src/sbt-test/tests/nested-inproc-seq/test | 2 +- sbt-app/src/sbt-test/tests/nested-subproc/test | 2 +- sbt-app/src/sbt-test/tests/setup-cleanup/test | 8 ++++---- sbt-app/src/sbt-test/tests/single-runner/build.sbt | 2 +- sbt-app/src/sbt-test/tests/single-runner/test | 2 +- sbt-app/src/sbt-test/tests/specs-run/test | 8 ++++---- sbt-app/src/sbt-test/tests/task/build.sbt | 2 +- sbt-app/src/sbt-test/tests/task/test | 2 +- 19 files changed, 39 insertions(+), 38 deletions(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 41ac5bfcc..3782bd24b 100644 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -1375,9 +1375,9 @@ object Defaults extends BuildCommon { } }.value, // ((streams in test, loadedTestFrameworks, testLoader, testGrouping in test, testExecution in test, fullClasspath in test, javaHome in test, testForkedParallel, javaOptions in test) flatMap allTestGroupsTask).value, - Test / test / testResultLogger :== TestResultLogger.SilentWhenNoTests, // https://github.com/sbt/sbt/issues/1185 - test := { - val trl = (Test / test / testResultLogger).value + Test / testFull / testResultLogger :== TestResultLogger.SilentWhenNoTests, // https://github.com/sbt/sbt/issues/1185 + testFull := { + val trl = (Test / testFull / testResultLogger).value val taskName = Project.showContextKey(state.value).show(resolvedScoped.value) try trl.run(streams.value.log, executeTests.value, taskName) finally close(testLoader.value) @@ -1389,7 +1389,8 @@ object Defaults extends BuildCommon { testQuick := { try inputTests(testQuick).evaluated finally close(testLoader.value) - } + }, + test := testQuick.evaluated, ) private def close(sbtLoader: ClassLoader): Unit = sbtLoader match { diff --git a/main/src/main/scala/sbt/Keys.scala b/main/src/main/scala/sbt/Keys.scala index 8da19e030..e602d450e 100644 --- a/main/src/main/scala/sbt/Keys.scala +++ b/main/src/main/scala/sbt/Keys.scala @@ -359,9 +359,10 @@ object Keys { val definedTestNames = taskKey[Seq[String]]("Provides the set of defined test names.").withRank(BMinusTask) val definedTestDigests = taskKey[Map[String, Digest]]("Provides a unique digest of defined tests.").withRank(DTask) val executeTests = taskKey[Tests.Output]("Executes all tests, producing a report.").withRank(CTask) - val test = taskKey[Unit]("Executes all tests.").withRank(APlusTask) + val test = inputKey[Unit]("Executes the tests that either failed before, were not run or whose transitive dependencies changed, among those provided as arguments.").withRank(ATask) + val testFull = taskKey[Unit]("Executes all tests.").withRank(APlusTask) val testOnly = inputKey[Unit]("Executes the tests provided as arguments or all tests if no arguments are provided.").withRank(ATask) - val testQuick = inputKey[Unit]("Executes the tests that either failed before, were not run or whose transitive dependencies changed, among those provided as arguments.").withRank(ATask) + val testQuick = inputKey[Unit]("Alias for test.").withRank(CTask) @cacheLevel(include = Array.empty) val testOptions = taskKey[Seq[TestOption]]("Options for running tests.").withRank(BPlusTask) private[sbt] val testOptionDigests = taskKey[Seq[Digest]]("Digest for testOptions").withRank(DTask) diff --git a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala index 0298bab85..fffa06be9 100644 --- a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala +++ b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala @@ -957,7 +957,7 @@ object BuildServerProtocol { case None => // run allTests in testParams.targets val filter = ScopeFilter.in(testParams.targets.map(workspace.scopes)) - test.all(filter).result + test.toTask("").all(filter).result } Def.task { diff --git a/sbt-app/src/sbt-test/tests/fork-parallel/test b/sbt-app/src/sbt-test/tests/fork-parallel/test index 70e542b98..437da8542 100644 --- a/sbt-app/src/sbt-test/tests/fork-parallel/test +++ b/sbt-app/src/sbt-test/tests/fork-parallel/test @@ -1,8 +1,8 @@ # Note: this test is meaningless on less than four cores -> test +> testFull -> check > clean > set testForkedParallel := true -> test +> testFull > check diff --git a/sbt-app/src/sbt-test/tests/fork-test-group-parallel-custom-tags/build.sbt b/sbt-app/src/sbt-test/tests/fork-test-group-parallel-custom-tags/build.sbt index 059a130a2..52958f00d 100644 --- a/sbt-app/src/sbt-test/tests/fork-test-group-parallel-custom-tags/build.sbt +++ b/sbt-app/src/sbt-test/tests/fork-test-group-parallel-custom-tags/build.sbt @@ -29,5 +29,5 @@ inConfig(Test)(Seq( ), Seq((if (test.name.contains("TestA")) TestATypeTag else TestBTypeTag) -> 1)) } }, - TaskKey[Unit]("test-failure") := test.failure.value + TaskKey[Unit]("test-failure") := testFull.failure.value )) diff --git a/sbt-app/src/sbt-test/tests/fork-test-group-parallel-custom-tags/test b/sbt-app/src/sbt-test/tests/fork-test-group-parallel-custom-tags/test index c3fa9262d..7b7292bcf 100644 --- a/sbt-app/src/sbt-test/tests/fork-test-group-parallel-custom-tags/test +++ b/sbt-app/src/sbt-test/tests/fork-test-group-parallel-custom-tags/test @@ -1,3 +1,3 @@ -> test -> set concurrentRestrictions in Global := Seq(Tags.limitAll(4)) +> testFull +> set Global / concurrentRestrictions := Seq(Tags.limitAll(4)) > testFailure diff --git a/sbt-app/src/sbt-test/tests/fork-test-group-parallel/build.sbt b/sbt-app/src/sbt-test/tests/fork-test-group-parallel/build.sbt index a6b2aaf9d..a8345706f 100644 --- a/sbt-app/src/sbt-test/tests/fork-test-group-parallel/build.sbt +++ b/sbt-app/src/sbt-test/tests/fork-test-group-parallel/build.sbt @@ -23,5 +23,5 @@ inConfig(Test)(Seq( ) ))} }, - TaskKey[Unit]("test-failure") := test.failure.value + TaskKey[Unit]("test-failure") := testFull.failure.value )) diff --git a/sbt-app/src/sbt-test/tests/fork-test-group-parallel/test b/sbt-app/src/sbt-test/tests/fork-test-group-parallel/test index 26c3b2549..22cb58b68 100644 --- a/sbt-app/src/sbt-test/tests/fork-test-group-parallel/test +++ b/sbt-app/src/sbt-test/tests/fork-test-group-parallel/test @@ -1,3 +1,3 @@ > testFailure -> set concurrentRestrictions in Global += Tags.limit(Tags.ForkedTestGroup, 1) -> test +> set Global / concurrentRestrictions += Tags.limit(Tags.ForkedTestGroup, 1) +> testFull diff --git a/sbt-app/src/sbt-test/tests/fork2/build.sbt b/sbt-app/src/sbt-test/tests/fork2/build.sbt index 6c272bbde..17f75a03a 100644 --- a/sbt-app/src/sbt-test/tests/fork2/build.sbt +++ b/sbt-app/src/sbt-test/tests/fork2/build.sbt @@ -1,6 +1,5 @@ val scalatest = "org.scalatest" %% "scalatest" % "3.0.5" -ThisBuild / scalaVersion := "2.12.19" - +scalaVersion := "2.12.19" fork := true libraryDependencies += scalatest % Test diff --git a/sbt-app/src/sbt-test/tests/fork2/test b/sbt-app/src/sbt-test/tests/fork2/test index 46ab1ff8d..bf3b24774 100644 --- a/sbt-app/src/sbt-test/tests/fork2/test +++ b/sbt-app/src/sbt-test/tests/fork2/test @@ -1,12 +1,12 @@ -> test +> testFull $ copy-file changes/Test.scala src/test/scala/Test.scala -> test +> testFull > 'set javaOptions += "-Xno-opt"' --> test +-> testFull > session clear > 'set envVars += ("tests.max.value" -> "0")' --> test +-> testFull diff --git a/sbt-app/src/sbt-test/tests/junit-xml-report/test b/sbt-app/src/sbt-test/tests/junit-xml-report/test index 370227892..55deaf79c 100644 --- a/sbt-app/src/sbt-test/tests/junit-xml-report/test +++ b/sbt-app/src/sbt-test/tests/junit-xml-report/test @@ -1,4 +1,4 @@ --> test +-> testFull > checkReport # there might be discrepancies between the 'normal' and the 'forked' mode @@ -7,5 +7,5 @@ > checkNoReport > set Test / fork := true --> test -> checkReport \ No newline at end of file +-> testFull +> checkReport diff --git a/sbt-app/src/sbt-test/tests/nested-inproc-seq/test b/sbt-app/src/sbt-test/tests/nested-inproc-seq/test index 6481f9187..3a3aaee3c 100644 --- a/sbt-app/src/sbt-test/tests/nested-inproc-seq/test +++ b/sbt-app/src/sbt-test/tests/nested-inproc-seq/test @@ -5,7 +5,7 @@ > clean -> test +> testFull $ exists target/SuiteStarting-NestedSpecs diff --git a/sbt-app/src/sbt-test/tests/nested-subproc/test b/sbt-app/src/sbt-test/tests/nested-subproc/test index faf8391a9..66ee4d122 100644 --- a/sbt-app/src/sbt-test/tests/nested-subproc/test +++ b/sbt-app/src/sbt-test/tests/nested-subproc/test @@ -5,7 +5,7 @@ > clean -> test +> testFull $ exists target/SuiteStarting-NestedSpecs diff --git a/sbt-app/src/sbt-test/tests/setup-cleanup/test b/sbt-app/src/sbt-test/tests/setup-cleanup/test index 0f0a09b94..dc20985b0 100644 --- a/sbt-app/src/sbt-test/tests/setup-cleanup/test +++ b/sbt-app/src/sbt-test/tests/setup-cleanup/test @@ -4,7 +4,7 @@ $ absent tested $ absent cleanup # without Setup configured, the setup file won't exist and the test will fail --> testQuick +-> testFull # check that we are starting clean $ absent setup @@ -15,7 +15,7 @@ $ absent cleanup $ copy-file changes/setup.sbt setup.sbt > reload -> test +> testFull # setup should have been deleted by the test $ absent setup @@ -39,7 +39,7 @@ $ absent tested $ absent cleanup # without Setup configured, the setup file won't exist and the test will fail --> testQuick +-> testFull # check that we are starting clean $ absent setup @@ -50,7 +50,7 @@ $ absent cleanup $ copy-file changes/setup.sbt setup.sbt > reload -> test +> testFull # setup should have been deleted by the test $ absent setup diff --git a/sbt-app/src/sbt-test/tests/single-runner/build.sbt b/sbt-app/src/sbt-test/tests/single-runner/build.sbt index 69ff2b711..d21cfa59e 100644 --- a/sbt-app/src/sbt-test/tests/single-runner/build.sbt +++ b/sbt-app/src/sbt-test/tests/single-runner/build.sbt @@ -1,4 +1,4 @@ val scalatest = "org.scalatest" %% "scalatest" % "3.0.5" -ThisBuild / scalaVersion := "2.12.19" +scalaVersion := "2.12.19" libraryDependencies += scalatest Test / testOptions += Tests.Argument("-C", "custom.CustomReporter") diff --git a/sbt-app/src/sbt-test/tests/single-runner/test b/sbt-app/src/sbt-test/tests/single-runner/test index c7c5eb165..abc883001 100644 --- a/sbt-app/src/sbt-test/tests/single-runner/test +++ b/sbt-app/src/sbt-test/tests/single-runner/test @@ -6,7 +6,7 @@ > clean -> test +> testFull $ exists target/RunStarting diff --git a/sbt-app/src/sbt-test/tests/specs-run/test b/sbt-app/src/sbt-test/tests/specs-run/test index bd08eca91..9b5723cba 100644 --- a/sbt-app/src/sbt-test/tests/specs-run/test +++ b/sbt-app/src/sbt-test/tests/specs-run/test @@ -1,20 +1,20 @@ > clean $ delete src/ $ copy-file changes/ClassFailModuleSuccess.scala src/test/scala/Test.scala --> test:test +-> testFull > clean $ delete src/ $ copy-file changes/ClassFailModuleFail.scala src/test/scala/Test.scala --> test:test +-> testFull > clean $ delete src/ $ copy-file changes/ClassSuccessModuleFail.scala src/test/scala/Test.scala --> test:test +-> testFull > clean $ delete src/ $ copy-file changes/ClassSuccessModuleSuccess.scala src/test/scala/Test.scala -> test:test \ No newline at end of file +> testFull diff --git a/sbt-app/src/sbt-test/tests/task/build.sbt b/sbt-app/src/sbt-test/tests/task/build.sbt index 69ff2b711..d21cfa59e 100644 --- a/sbt-app/src/sbt-test/tests/task/build.sbt +++ b/sbt-app/src/sbt-test/tests/task/build.sbt @@ -1,4 +1,4 @@ val scalatest = "org.scalatest" %% "scalatest" % "3.0.5" -ThisBuild / scalaVersion := "2.12.19" +scalaVersion := "2.12.19" libraryDependencies += scalatest Test / testOptions += Tests.Argument("-C", "custom.CustomReporter") diff --git a/sbt-app/src/sbt-test/tests/task/test b/sbt-app/src/sbt-test/tests/task/test index 9c84af088..1c4d93429 100644 --- a/sbt-app/src/sbt-test/tests/task/test +++ b/sbt-app/src/sbt-test/tests/task/test @@ -5,7 +5,7 @@ > clean -> test +> testFull $ exists target/SuiteStarting-TestSpec