From b4f0358f1efe83ca8e453b2417920842b4d66393 Mon Sep 17 00:00:00 2001 From: Eruis2579 Date: Thu, 12 Feb 2026 09:27:18 -0500 Subject: [PATCH] Fix: always create TestDefinitions with correct explicitlySpecified value Previously only created new TestDefinitions when explicitlyRequestedNames was non-empty, leaving uniqueTests with potentially incorrect explicitlySpecified values. Now always map to create new TestDefinitions with explicitlySpecified based on whether the test name is in explicitlyRequestedNames. --- main-actions/src/main/scala/sbt/Tests.scala | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/main-actions/src/main/scala/sbt/Tests.scala b/main-actions/src/main/scala/sbt/Tests.scala index 2d2fda9b6..2fe359d1f 100644 --- a/main-actions/src/main/scala/sbt/Tests.scala +++ b/main-actions/src/main/scala/sbt/Tests.scala @@ -293,17 +293,14 @@ object Tests { val uniqueTests = distinctBy(tests)(_.name) // 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 (explicitlyRequestedNames.isEmpty) uniqueTests - else - uniqueTests.map(t => - new TestDefinition( - t.name, - t.fingerprint, - explicitlySpecified = explicitlyRequestedNames.contains(t.name), - Array(new SuiteSelector: Selector) - ) - ) + val testsToUse = uniqueTests.map(t => + new TestDefinition( + t.name, + t.fingerprint, + explicitlySpecified = explicitlyRequestedNames.contains(t.name), + Array(new SuiteSelector: Selector) + ) + ) new ProcessedOptions( testsToUse.toVector, setup.toVector,