Skip to content

Commit

Permalink
Merge pull request #545 from adpi2/fix-main-class-in-test
Browse files Browse the repository at this point in the history
[sbt plugin] Fix debug main class in test scope
  • Loading branch information
adpi2 committed Aug 2, 2023
2 parents 7e00298 + fbf740b commit da6456a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 6 deletions.
34 changes: 29 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
jvm: ['adoptium:1.8.0-372', 'adoptium:1.11.0.19', 'adoptium:1.17.0.7']
include:
- os: ubuntu-latest
jvm: 'adoptium:1.8.0-372'
- os: window-latest
jvm: 'adoptium:1.11.0.19'
- os: macOS-latest
jvm: 'adoptium:1.17.0.7'
- os: ubuntu-latest
jvm: 'adoptium:1.20.0.1'
name: Test on ${{ matrix.os }} -- ${{ matrix.jvm }}
name: Unit Tests on ${{ matrix.os }} -- ${{ matrix.jvm }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -44,7 +48,27 @@ jobs:
- name: Unit tests
run: sbt test
shell: bash
- name: Scripted sbt tests
scripted-test:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
jvm: 'adoptium:1.8.0-372'
- os: unbutu-latest
jvm: 'adoptium:1.11.0.19'
- os: macOS-latest
jvm: 'adoptium:1.17.0.7'
name: Scripted Tests on ${{ matrix.os }} -- ${{ matrix.jvm }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: coursier/setup-action@v1.3.3
with:
jvm: ${{ matrix.jvm }}
apps: sbt
- name: Scripted tests
run: sbt sbtPlugin/scripted
shell: bash
if: ${{ matrix.jvm != 'adoptium:1.20.0.1' && (matrix.jvm != 'adoptium:1.17.0.7' || matrix.os != 'windows-latest' ) }}
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ lazy val sbtPlugin = project
scriptedLaunchOpts += s"-Dplugin.version=${version.value}",
scriptedBufferLog := false,
scriptedDependencies := scriptedDependencies
.dependsOn(publishLocal, core212 / publishLocal, tests212 / publishLocal)
.dependsOn(publishLocal, core212 / publishLocal, tests212 / publishLocal, expressionCompiler212 / publishLocal)
.value
)
.dependsOn(core212)
Expand Down
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 da6456a

Please sign in to comment.