Skip to content

[2.x] fix: Fixes explicitlySpecified and selectors for testOnly#8727

Merged
eed3si9n merged 11 commits intosbt:developfrom
Eruis2579:fix/5609-do-not-discover-testonly
Feb 13, 2026
Merged

[2.x] fix: Fixes explicitlySpecified and selectors for testOnly#8727
eed3si9n merged 11 commits intosbt:developfrom
Eruis2579:fix/5609-do-not-discover-testonly

Conversation

@Eruis2579
Copy link
Copy Markdown
Contributor

@Eruis2579 Eruis2579 commented Feb 10, 2026

Fixes #5609

Problem
When the user runs testOnly with an explicit suite name (e.g. testOnly com.example.MySuite), ScalaTest suites annotated with @DoNotDiscover were not run because sbt always passed explicitlySpecified=false to the test framework.

Solution
In Tests.processOptions, when the user has specified test filters (orderedFilters.nonEmpty), mark the filtered tests as explicitlySpecified=true with SuiteSelector so frameworks can run @DoNotDiscover suites when explicitly requested.

  • main-actions: set explicitlySpecified and selectors in processOptions for testOnly path
  • scripted test: tests/i5609-do-not-discover-testonly (testOnly com.test.TestSpec2)

@Eruis2579 Eruis2579 force-pushed the fix/5609-do-not-discover-testonly branch 2 times, most recently from eb3d64e to b645acc Compare February 10, 2026 14:40
…cover suites run (sbt#5609)

**Problem**
When the user runs testOnly with an explicit suite name (e.g. testOnly com.example.MySuite),
ScalaTest suites annotated with @DoNotDiscover were not run because sbt always passed
explicitlySpecified=false to the test framework.

**Solution**
In Tests.processOptions, when the user has specified test filters (orderedFilters.nonEmpty),
mark the filtered tests as explicitlySpecified=true with SuiteSelector so frameworks
can run @DoNotDiscover suites when explicitly requested.

- main-actions: set explicitlySpecified and selectors in processOptions for testOnly path
- scripted test: tests/i5609-do-not-discover-testonly (testOnly com.test.TestSpec2)
@Eruis2579 Eruis2579 force-pushed the fix/5609-do-not-discover-testonly branch from b645acc to cfa88c3 Compare February 10, 2026 14:43
@Eruis2579
Copy link
Copy Markdown
Contributor Author

Hi, @eed3si9n Can you check my PR, please? Thanks

…n 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
…ndling

- Define ExplicitlyRequestedNames(names: Seq[String]) extends TestOption
- In processOptions: declare explicitlyRequestedNames, isExplicitFqn, match case
- Fixes actionsProj/Compile compilation failure in CI
@Eruis2579 Eruis2579 requested a review from eed3si9n February 11, 2026 07:10
@Eruis2579
Copy link
Copy Markdown
Contributor Author

Hi, @eed3si9n , Please check again if you have time. Enjoy your travel.

Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's still missing the test for

> clean
> testOnly com.test...

scenario where you run testOnly but pass in a pattern filter.

Address review: cover scenario where testOnly is run with a pattern
rather than an explicit FQN; @DoNotDiscover remains excluded.
@Eruis2579
Copy link
Copy Markdown
Contributor Author

Hi, @eed3si9n , Please review my changes again.
Thank you for your review.

@Eruis2579 Eruis2579 requested a review from eed3si9n February 12, 2026 06:00
PandaMan and others added 7 commits February 12, 2026 21:37
…tions

- isExplicitFqn now checks for '...' in addition to '*' and '?'
- Add testOnly com.test... block with assertions (TestSpec should run, TestSpec2 should not)
- Addresses reviewer feedback: patterns like com.test... should not set explicitlySpecified=true
…alue

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.
Was replacing all selectors with SuiteSelector, now uses t.selectors
to preserve the original test's selectors.
…tions

The test was failing because files from testOnly com.test.TestSpec2 persisted after clean.
Now:
- Check files absent immediately after clean (before testOnly com.test...)
- Use negative assertions (-$ exists) instead of $ absent for better clarity

The core fix is working correctly - com.test... is properly filtered as a pattern
and TestSpec2 is not run.
The > clean command doesn't remove individual test output files in scripted tests.
Now explicitly delete all marker files before running testOnly com.test... to ensure
a clean state for the final test block.
@Eruis2579 Eruis2579 requested a review from eed3si9n February 12, 2026 16:17
@Eruis2579
Copy link
Copy Markdown
Contributor Author

Eruis2579 commented Feb 12, 2026

Hi, @eed3si9n , I have added your suggest code. When I committed your suggestion, there was error while testing. That is cuz clean doesn't remove individual test output files in the scripted test environment. Using explicit $ delete commands works. Thank you for your review again.

@Eruis2579
Copy link
Copy Markdown
Contributor Author

Eruis2579 commented Feb 13, 2026

Hi, @eed3si9n , If you have time, please check my updates for your feedback

@eed3si9n eed3si9n changed the title fix: Pass explicitlySpecified and selectors for testOnly so @DoNotDis… [2.x] fix: Fixes explicitlySpecified and selectors for testOnly Feb 13, 2026
Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! LGTM

@eed3si9n eed3si9n merged commit c7da2b7 into sbt:develop Feb 13, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass in correct explicitlySpecified and selectors when creating TestDefinitions

2 participants