[testing-support][intellij-bazel] specs2 gutter triangles + Bazel --test_filter (#SCL-25391)#718
Open
gosha212 wants to merge 3 commits into
Open
Conversation
…5391
Adds runnable gutter icons for each specs2 test ("x" in {…}, >>, !)
and scope expression ("x" should {…}, can). Mirrors the
ScalaTestTestLocationsFinder pattern: a new Specs2TestLocationsFinder
walks the class body and collects the operation refs of every
ScInfixExpr that TestNodeProvider recognises as a specs2 test or
scope.
Wires the result into ScalaTestRunLineMarkerProvider#infoForTestMethodRef
behind a Specs2TestFramework branch.
The companion test (Specs2RunLineMarkerProviderTest, plus its
WithSpecs2_4 fixture trait) will land in a follow-up commit on the
same PR once the locally-built specs2-core test classpath is verified.
…ts and scopes #SCL-25391 Following SCL-24481 (PR JetBrains#709) which added ScalaTest+ZIO single-test support to BazelScalaTestRunLineMarkerLogic, this restores specs2 parity. Without it, clicking the gutter on a specs2 spec produces --test_filter=<classFQN>, which fails to match specs2-junit's scope-prefixed Description display names; bazel's JUnit4Runner reports "No tests found matching RegEx". Specs2BazelTestFilter is a Scala 3 port of the deleted Google IJwB plugin (bazelbuild/intellij commit f62b2670648d, file scala/src/com/google/idea/blaze/scala/run/Specs2Utils.java). Filter format identical to Google's: - test ref: <classFQN>#\Q<scope> should::<test>\E$ - scope ref: <classFQN>#\Q<scope> should\E:: A specs2 class identifier itself (no enclosing test/scope expression) falls back to <classFQN>.* which empirically works for scala_specs2_junit_test targets. The helper lives in testing-support (Scala 2.13) rather than intellij-bazel (Scala 3) because it is a pure PSI-to-string utility with no bazel-runtime dependency, and testing-support already has the ScalaFixtureTestCase infrastructure used to unit-test it (Specs2BazelTestFilterTest).
…ixed Mirrors ScalaTestRunLineMarkerProviderTest_Scalatest_3_2_Scala2 against a Specs2 mutable.Specification with both `should` and `can` scopes and all three test operators (`in`, `>>`, `!`). Asserts seven gutters: class identifier, both scope refs, and all four test refs. Expected offsets were computed by manual character counting of the fixture source. If JetBrains CI surfaces a mismatch, the assertion's `expected:<…> but was:<…>` output gives us the actuals to swap in.
Collaborator
|
Thanks for the contribution. I will run it in our internal CI to see if the tests pass and I will do a review afterwards. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #SCL-25391.
Two related fixes for IntelliJ Scala's Specs2 support:
[testing-support]Per-test gutter triangles for specs2.ScalaTestRunLineMarkerProvider#infoForTestMethodRefpreviously had cases for ScalaTest and MUnit but not Specs2, so individual tests ("x" in {…},>>,!) and scope blocks (should,can) had no gutter icons even though the class itself did. Adds aSpecs2TestLocationsFinderparallel toScalaTestTestLocationsFinder, using the existingTestNodeProvider.isSpecs2TestExpr/isSpecs2ScopeExprpredicates already shared withSpecs2ConfigurationProducer.[intellij-bazel]Bazel--test_filterfor specs2. Following SCL-24481 (PR SCL-24481: Support running separate ScalaTest tests via Bazel #709) which wired ScalaTest+ZIO single-test filters viaBazelScalaTestRunLineMarkerLogic, this restores specs2 parity. Without it, clicking the gutter on a specs2 spec produces--test_filter=<classFQN>, which fails to whole-string-match specs2-junit's scope-prefixedDescriptionnames —JUnit4RunnerreportsNo tests found matching RegEx. AddsSpecs2BazelTestFilter, a Scala 3 port of Google's deleted IJwBSpecs2Utils.java(commitf62b2670648d, removed in36a4550602"Remove IJwB build (#7868)"). Filter format identical to Google's:<classFQN>#\Q<scope> should::<test>\E$<classFQN>#\Q<scope> should\E::Architecture note
Specs2BazelTestFilterlives intesting-support(Scala 2.13) rather thanintellij-bazel(Scala 3) for two reasons:BazelScalaTestRunLineMarkerLogicis bazel-specific.intellij-bazelhas no test source root today;testing-supportalready hasScalaFixtureTestCaseinfrastructure used by the unit test (Specs2BazelTestFilterTest).Tests
Specs2BazelTestFilterTest(new) — 7 cases covering top-levelin, scopedin/>>(undershould),inundercan,shouldscope,canscope, and a non-test-element negative case. Uses the newWithSpecs2_4fixture trait.Specs2RunLineMarkerProviderTestfor the gutter side will land as a follow-up commit on this branch — the IntelliJ test fixture boot is slow on our hardware and we wanted to surface the changes for review without further delay.Verification
sbt testing-support/Test/compileandsbt intellij-bazel/Compile/compileboth pass on JDK 21.scala_specs2_junit_testBazel target in the sandboxed IDE, clicked gutter triangles on test/scope/class, confirmed each generates the expected filter and runs.Related
bazelbuild/intellijcommitf62b2670648d— Google IJwB Scala plugin's specs2 producer (since deleted), source of the proposed filter format.