From c1c9bbb31ffc55a1e21466ebabbd4bda5233f1d8 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Tue, 1 Oct 2024 09:44:30 -0700 Subject: [PATCH] CommunitySuite: add Intellij Scala plugin code --- .github/workflows/ci.yml | 2 +- build.sbt | 5 + .../community/common/CommunitySuite.scala | 4 +- .../CommunityIntellijScalaSuite.scala | 98 +++++++++++++++++++ 4 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 scalafmt-tests-community/intellij/src/test/scala/org/scalafmt/community/intellij/CommunityIntellijScalaSuite.scala diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90f1dc8ac0..3aecc763d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: matrix: java: [ '11' ] os: [windows-latest, ubuntu-latest] - group: [Scala2, Scala3, Spark, Other] + group: [Scala2, Scala3, Spark, Intellij, Other] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/build.sbt b/build.sbt index fbc0d143b7..b773c646ee 100644 --- a/build.sbt +++ b/build.sbt @@ -255,6 +255,11 @@ lazy val communityTestsSpark = project .in(file("scalafmt-tests-community/spark")).settings(communityTestsSettings) .enablePlugins(BuildInfoPlugin).dependsOn(communityTestsCommon) +lazy val communityTestsIntellij = project + .in(file("scalafmt-tests-community/intellij")) + .settings(communityTestsSettings).enablePlugins(BuildInfoPlugin) + .dependsOn(communityTestsCommon) + lazy val communityTestsOther = project .in(file("scalafmt-tests-community/other")).settings(communityTestsSettings) .enablePlugins(BuildInfoPlugin).dependsOn(communityTestsCommon) diff --git a/scalafmt-tests-community/common/src/main/scala/org/scalafmt/community/common/CommunitySuite.scala b/scalafmt-tests-community/common/src/main/scala/org/scalafmt/community/common/CommunitySuite.scala index 985b70e928..c4c30f3be6 100644 --- a/scalafmt-tests-community/common/src/main/scala/org/scalafmt/community/common/CommunitySuite.scala +++ b/scalafmt-tests-community/common/src/main/scala/org/scalafmt/community/common/CommunitySuite.scala @@ -64,8 +64,8 @@ abstract class CommunitySuite extends FunSuite { build.checkedFiles * 2, s"expected ${stats.checkedFiles / 2} per run", ) - build.statsPerStyle.get(styleName).foreach { styleStats => - assertEquals(statesVisited, styleStats.expectedStatesVisited) + if (!OsSpecific.isWindows) build.statsPerStyle.get(styleName).foreach { x => + assertEquals(statesVisited, x.expectedStatesVisited) } } diff --git a/scalafmt-tests-community/intellij/src/test/scala/org/scalafmt/community/intellij/CommunityIntellijScalaSuite.scala b/scalafmt-tests-community/intellij/src/test/scala/org/scalafmt/community/intellij/CommunityIntellijScalaSuite.scala new file mode 100644 index 0000000000..2f80f3f141 --- /dev/null +++ b/scalafmt-tests-community/intellij/src/test/scala/org/scalafmt/community/intellij/CommunityIntellijScalaSuite.scala @@ -0,0 +1,98 @@ +package org.scalafmt.community.intellij + +import org.scalafmt.community.common.CommunityRepoSuite +import org.scalafmt.community.common.TestStats + +import scala.meta._ + +abstract class CommunityIntellijScalaSuite(name: String) + extends CommunityRepoSuite( + "https://github.com/JetBrains/intellij-scala.git", + name, + ) + +class CommunityIntellijScala_2024_2_Suite + extends CommunityIntellijScalaSuite("intellij-scala-2024.2") { + + override protected def builds = Seq(getBuild( + "2024.2.28", + dialects.Scala213, + 3469, + excluded = "glob:**/{testdata,testData,resources}/**" :: Nil, + fileOverride = """|{ + | "glob:**/sbt/sbt-impl/workspace-entities/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/structure-view/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/repl/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/tasty-reader/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/package-search-client/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/integration/textAnalysis/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/integration/features-trainer/**" { + | runner.dialect = scala33 + | } + |} + |""".stripMargin, + )) + +} + +class CommunityIntellijScala_2024_3_Suite + extends CommunityIntellijScalaSuite("intellij-scala-2024.3") { + + override protected def builds = Seq(getBuild( + "2024.3.4", + dialects.Scala213, + 3475, + excluded = "glob:**/{testdata,testData,resources}/**" :: Nil, + fileOverride = """|{ + | "glob:**/sbt/sbt-impl/workspace-entities/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/structure-view/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/repl/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/tasty-reader/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/package-search-client/**" { + | runner.dialect = scala33 + | } + | "glob:**/scalac-patches/scalac3-patches/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/integration/textAnalysis/**" { + | runner.dialect = scala33 + | } + | "glob:**/scala/integration/features-trainer/**" { + | runner.dialect = scala33 + | } + |} + |""".stripMargin, + statsPerStyle = Map( + "classic" -> TestStats.Style(expectedStatesVisited = 5134862), + "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 5139218), + "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 5134172), + "fold" -> TestStats.Style(expectedStatesVisited = 7953034), + "keep" -> TestStats.Style(expectedStatesVisited = 4737913), + "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 4739065), + "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 4748954), + "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 5167360), + "unfold" -> TestStats.Style(expectedStatesVisited = 5611808), + ), + )) + +}