[2.x] fix: Fixes explicitlySpecified and selectors for testOnly#8727
[2.x] fix: Fixes explicitlySpecified and selectors for testOnly#8727eed3si9n merged 11 commits intosbt:developfrom
Conversation
eb3d64e to
b645acc
Compare
…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)
b645acc to
cfa88c3
Compare
|
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
|
Hi, @eed3si9n , Please check again if you have time. Enjoy your travel. |
eed3si9n
left a comment
There was a problem hiding this comment.
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.
|
Hi, @eed3si9n , Please review my changes again. |
Co-authored-by: eugene yokota <[email protected]>
…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.
|
Hi, @eed3si9n , I have added your suggest code. When I committed your suggestion, there was error while testing. That is cuz |
|
Hi, @eed3si9n , If you have time, please check my updates for your feedback |
eed3si9n
left a comment
There was a problem hiding this comment.
Thanks for the contribution! LGTM
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.