Skip to content

Commit

Permalink
enable scripted tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Sep 28, 2024
1 parent babc7f9 commit b41c8ef
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
3 changes: 1 addition & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ lazy val rules212 = rules
.enablePlugins(ScalafixPlugin)
.dependsOn(myRuleRule % ScalafixConfig)
.settings(
// TODO re-enable if warning-diff-scalafix-plugin released
// Test / test := (Test / test).dependsOn(scripted.toTask("")).value,
Test / test := (Test / test).dependsOn(scripted.toTask("")).value,
Compile / compile := (Compile / compile).dependsOn((Compile / scalafix).toTask(" MyScalafixRuleRule")).value,
scriptedBufferLog := false,
scriptedLaunchOpts += ("-Dscalafix-rules.version=" + version.value),
Expand Down
2 changes: 1 addition & 1 deletion rules/src/main/scala/fix/SeparateEachFileRewrite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ class SeparateEachFileRewrite(config: SeparateEachFileConfig) extends SyntacticR
Patch.empty
}

private def isTopLevel(t: Tree): Boolean = t.parent.forall(_.is[Pkg])
private def isTopLevel(t: Tree): Boolean = t.parent.forall(_.is[Pkg.Body])
}
3 changes: 2 additions & 1 deletion rules/src/main/scala/fix/UnmooredDocComment.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import scala.collection.compat._
import scala.meta.Decl
import scala.meta.Defn
import scala.meta.Mod
import scala.meta.Pkg
import scala.meta.Stat
import scala.meta.Tree
import scala.meta.transversers._
Expand All @@ -17,7 +18,7 @@ import scalafix.v1.XtensionSeqPatch
object UnmooredDocComment {
private object Unmoored {
def unapply(t: Tree): Boolean = t match {
case _: Stat.WithTemplate | _: Defn | _: Mod | _: Decl =>
case _: Stat.WithTemplate | _: Defn | _: Mod | _: Decl | _: Pkg.Body =>
false
case _ =>
true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("scalafix.version"))
addSbtPlugin("com.github.xuwei-k" % "warning-diff-scalafix-plugin" % "0.4.4")
addSbtPlugin("com.github.xuwei-k" % "warning-diff-scalafix-plugin" % "0.5.0")
9 changes: 9 additions & 0 deletions sbt-test/UnmooredDocComment/test-1/build.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
ThisBuild / scalafixDependencies += "com.github.xuwei-k" %% "scalafix-rules" % sys.props("scalafix-rules.version")

TaskKey[Unit]("check") := {
if(!scala.util.Properties.isWin) {
val actual = "target/warnings/warnings.json"
val expect = "expect.json"
sys.process.Process(Seq("diff", actual, expect)).!
assert(IO.read(file(actual)) == IO.read(file(expect)))
}
}
2 changes: 1 addition & 1 deletion sbt-test/UnmooredDocComment/test-1/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("scalafix.version"))
addSbtPlugin("com.github.xuwei-k" % "warning-diff-scalafix-plugin" % "0.4.4")
addSbtPlugin("com.github.xuwei-k" % "warning-diff-scalafix-plugin" % "0.5.0")
2 changes: 1 addition & 1 deletion sbt-test/UnmooredDocComment/test-1/test
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
> warningsAll
$ must-mirror target/warnings/warnings.json expect.json
> check

0 comments on commit b41c8ef

Please sign in to comment.