Skip to content

Commit

Permalink
Fix debug main class in test scope
Browse files Browse the repository at this point in the history
  • Loading branch information
adpi2 committed Aug 2, 2023
1 parent d346a97 commit a0ca295
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ object DebugAdapterPlugin extends sbt.AutoPlugin {
* }}}
*/
def testSettings: Seq[Def.Setting[_]] = Seq(
startMainClassDebugSession := mainClassSessionTask.evaluated,
startTestSuitesDebugSession := testSuitesSessionTask(convertFromArrayToTestSuites).evaluated,
startTestSuitesSelectionDebugSession := testSuitesSessionTask(convertToTestSuites).evaluated,
startRemoteDebugSession := remoteSessionTask.evaluated,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import ch.epfl.scala.debugadapter.testfmk._

val checkDebugSession = inputKey[Unit]("Check the main class debug session")

scalaVersion := "2.12.14"
checkDebugSession := {
val uri = (Test / startMainClassDebugSession).evaluated
val source = (Test / sources).value.head.toPath
DebugTest.check(uri)(Breakpoint(source, 5))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
val pluginVersion = sys.props
.get("plugin.version")
.getOrElse {
sys.error(
"""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.
|""".stripMargin
)
}

addSbtPlugin("ch.epfl.scala" % "sbt-debug-adapter" % pluginVersion)
libraryDependencies += "ch.epfl.scala" %% "scala-debug-adapter-test" % pluginVersion
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// required for adopt@1.8
addSbtPlugin("org.scala-debugger" % "sbt-jdi-tools" % "1.1.1")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package example

object Main {
def main(args: Array[String]): Unit = {
println("Hello, World!")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> 'checkDebugSession {"class":"example.Main","arguments":[],"jvmOptions":[]}'
> stopDebugSession

0 comments on commit a0ca295

Please sign in to comment.