Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail if testOnly does not match any test case #3224

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
formatting
  • Loading branch information
lefou committed Jun 21, 2024
commit c3603c65da40774b52475e78bd0593107da31738
6 changes: 4 additions & 2 deletions scalalib/src/mill/scalalib/TestModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ trait TestModule
val (doneMsg, results) = {
upickle.default.read[(String, Seq[TestResult])](jsonOutput)
}
if(results.isEmpty && selectors.nonEmpty) {
if (results.isEmpty && selectors.nonEmpty) {
// no tests ran but we expected some to run, as we applied a filter (e.g. via `testOnly`)
Result.Failure(s"Test selector does not match any test: ${selectors.mkString(" ")}" + "\nRun discoveredTestClasses to see available tests")
Result.Failure(
s"Test selector does not match any test: ${selectors.mkString(" ")}" + "\nRun discoveredTestClasses to see available tests"
)
} else TestModule.handleResults(doneMsg, results, T.ctx(), testReportXml())
} catch {
case e: Throwable =>
Expand Down
7 changes: 5 additions & 2 deletions scalalib/test/src/mill/scalalib/TestRunnerTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ object TestRunnerTests extends TestSuite {
testOnly(eval, Seq("*Bar*", "*bar*"), 2)
}
"noMatch" - workspaceTest(testrunner) { eval =>
val Left(Result.Failure(msg, _)) = eval.apply(testrunner.utest.testOnly("noMatch", "noMatch*2"))
assert(msg == "Test selector does not match any test: noMatch noMatch*2\nRun discoveredTestClasses to see available tests")
val Left(Result.Failure(msg, _)) =
eval.apply(testrunner.utest.testOnly("noMatch", "noMatch*2"))
assert(
msg == "Test selector does not match any test: noMatch noMatch*2\nRun discoveredTestClasses to see available tests"
)
}
}
}
Expand Down