Skip to content

Commit

Permalink
Merge pull request #703 from adpi2/fix-628
Browse files Browse the repository at this point in the history
Fix #628: remove `indent` and `-rewrite` options when evaluating expression
  • Loading branch information
adpi2 committed May 1, 2024
2 parents ee577ab + d817f50 commit ecdad2c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Expand Up @@ -120,7 +120,7 @@ object DebugTools {
debuggee.managedEntries.flatMap(loadExpressionCompiler).toMap
}

private val optionsToRemove = Set("-Xfatal-warnings", "-Werror")
private val optionsToRemove = Set("-Xfatal-warnings", "-Werror", "-indent", "-rewrite")

private def prepareOptions(options: Seq[String], toAdd: Seq[String]) = {
val withoutRemoved = options.filter(o => !optionsToRemove.contains(o))
Expand Down
Expand Up @@ -229,8 +229,8 @@ trait DebugTest extends CommonUtils {
continueIfPaused()
// This is flaky, terminated can happen before exited
if (!GithubUtils.isCI()) {
client.exited()
client.terminated()
client.exited(timeout = 4.seconds)
client.terminated(timeout = 4.seconds)
}
}

Expand Down
Expand Up @@ -1451,7 +1451,11 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
|}
|""".stripMargin
implicit val debuggee: TestingDebuggee = TestingDebuggee.munitTestSuite(source, "example.MySuite", scalaVersion)
check(Breakpoint(6), Evaluation.success("1 + 1", 2))
check(
Breakpoint(6),
Evaluation.success("1 + 1", 2),
if (isScala2) Breakpoint(6) else NoStep()
)
}

test("evaluate lambdas") {
Expand Down Expand Up @@ -2692,4 +2696,27 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
implicit val debuggee: TestingDebuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)
check(Breakpoint(6), if (isScala2) Breakpoint(6) else NoStep(), Evaluation.success("msg", "hello"))
}

test("i628: rewrite indent options") {
assume(scalaVersion.isScala3)
val source =
"""|package example
|
|object Main:
| def main(args: Array[String]): Unit =
| last(List(1))
|
| def last[A](l: List[A]): A = l match
| case lst :: Nil => lst
| case _ :: tail => last(tail)
| case Nil => throw new NoSuchElementException("last of empty list")
|""".stripMargin
implicit val debuggee: TestingDebuggee =
TestingDebuggee.mainClass(source, "example.Main", scalaVersion, Seq("-rewrite", "-indent"))
check(
Breakpoint(8),
Evaluation.success("l.size", 1),
Breakpoint(8)
)
}
}

0 comments on commit ecdad2c

Please sign in to comment.