mirror of https://github.com/sbt/sbt.git
Address review: ExplicitlyRequestedNames (FQN only), testFull block in scripted test
- Use ExplicitlyRequestedNames(selected) so explicitlySpecified=true only for complete FQNs (no * or ?), not patterns (per TaskDef) - Pass ExplicitlyRequestedNames from Defaults inputTests0 - Scripted test: add testFull block (exclude @DoNotDiscover), keep clean + testOnly block
This commit is contained in:
parent
cfa88c3cde
commit
68109b8adb
|
|
@ -281,18 +281,16 @@ object Tests {
|
|||
if (orderedFilters.isEmpty) filtered0
|
||||
else orderedFilters.flatMap(f => filtered0.filter(d => f(d.name))).toList.distinct
|
||||
val uniqueTests = distinctBy(tests)(_.name)
|
||||
// When user ran testOnly with explicit args and the filter restricted the set, mark matching
|
||||
// tests as explicitlySpecified so frameworks (e.g. ScalaTest) can run @DoNotDiscover suites.
|
||||
// Do not mark when orderedFilters is "run all" (e.g. test with no args -> selectedFilter(Nil) -> match all).
|
||||
val filteredToSubset = orderedFilters.nonEmpty && uniqueTests.size < discovered.size
|
||||
// Per TaskDef: explicitlySpecified=true only when user supplied a complete FQN (e.g. testOnly com.example.MySuite),
|
||||
// not for patterns (testOnly *Spec) or plain "test". So only mark when test.name is in explicitlyRequestedNames.
|
||||
val testsToUse =
|
||||
if (!filteredToSubset) uniqueTests
|
||||
if (explicitlyRequestedNames.isEmpty) uniqueTests
|
||||
else
|
||||
uniqueTests.map(t =>
|
||||
new TestDefinition(
|
||||
t.name,
|
||||
t.fingerprint,
|
||||
explicitlySpecified = true,
|
||||
explicitlySpecified = explicitlyRequestedNames.contains(t.name),
|
||||
Array(new SuiteSelector: Selector)
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1354,7 +1354,8 @@ object Defaults extends BuildCommon {
|
|||
val st = state.value
|
||||
given display: Show[ScopedKey[?]] = Project.showContextKey(st)
|
||||
val modifiedOpts =
|
||||
Tests.Filters(filter(selected)) +: Tests.Argument(frameworkOptions*) +: config.options
|
||||
Tests.ExplicitlyRequestedNames(selected) +: Tests.Filters(filter(selected)) +:
|
||||
Tests.Argument(frameworkOptions*) +: config.options
|
||||
val newConfig = config.copy(options = modifiedOpts)
|
||||
val output = allTestGroupsTask(
|
||||
s,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,14 @@
|
|||
# #5609: When explicitly requested via testOnly, @DoNotDiscover suite should run
|
||||
# #5609: When explicitly requested via testOnly, @DoNotDiscover suite should run.
|
||||
# First: full test run must exclude @DoNotDiscover (TestSpec2).
|
||||
# Second: testOnly with explicit FQN must run TestSpec2.
|
||||
|
||||
> clean
|
||||
> testFull
|
||||
$ exists target/SuiteStarting-TestSpec
|
||||
$ exists target/SuiteCompleted-TestSpec
|
||||
$ absent target/SuiteStarting-TestSpec2
|
||||
$ absent target/SuiteCompleted-TestSpec2
|
||||
|
||||
> clean
|
||||
> testOnly com.test.TestSpec2
|
||||
$ exists target/SuiteStarting-TestSpec2
|
||||
|
|
|
|||
Loading…
Reference in New Issue