Skip to content

Commit

Permalink
Fix trailing SBT args and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
keynmol committed Sep 25, 2023
1 parent 2044f6e commit e520f37
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ class SbtBuildTool(index: IndexCommand) extends BuildTool("sbt", index) {

private def unconditionallyGenerateScip(): Int =
Using.resource(sourcegraphSbtPluginFile()) { _ =>
val buildCommand =
if (index.buildCommand.isEmpty)
List("sourcegraphScip")
else
index.buildCommand

val sourcegraphScip = index
.process(List("sbt", "sourcegraphEnable", "sourcegraphScip"))
.process(List("sbt", "sourcegraphEnable") ++ buildCommand)
val inputDump = index
.workingDirectory
.resolve("target")
Expand Down
27 changes: 24 additions & 3 deletions tests/buildTools/src/test/scala/tests/SbtBuildToolSuite.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package tests

abstract class SbtBuildToolSuite(sbtVersion: String)
abstract class SbtBuildToolSuite(val sbtVersion: String)
extends BaseBuildToolSuite {
List("2.11.9", "2.12.18", "2.13.11", "3.3.0").foreach { scalaVersion =>
checkBuild(
Expand All @@ -9,7 +9,7 @@ abstract class SbtBuildToolSuite(sbtVersion: String)
|scalaVersion := "$scalaVersion"
|libraryDependencies += "junit" % "junit" % "4.13.2"
|/project/build.properties
|sbt.version=1.5.2
|sbt.version=$sbtVersion
|/src/main/java/example/ExampleJava.java
|package example;
|import org.junit.Assert;
Expand All @@ -29,8 +29,29 @@ abstract class SbtBuildToolSuite(sbtVersion: String)
targetRoot = Some("target")
)
}
}

class Sbt_1_BuildToolSuite extends SbtBuildToolSuite("1.5.2") {
checkBuild(
s"custom-sbt-command=$sbtVersion",
s"""|/build.sbt
|lazy val bla = project.in(file("bla"))
|lazy val blaJS = project.in(file("bla-js")).enablePlugins(ScalaJSPlugin)
|/project/plugins.sbt
|addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0")
|/project/build.properties
|sbt.version=$sbtVersion
|/bla/src/main/scala/example/ExampleScala.scala
|package example
|class ExampleScala()
|/bla-js/src/main/scala/example/ExampleScala.scala
|package example
|class ExampleScala!!!() // this file is intentionally broken
|""".stripMargin,
expectedSemanticdbFiles = 1,
extraArguments = List("--", "bla/compile"),
targetRoot = Some("bla/target")
)
}

class Sbt_1_BuildToolSuite extends SbtBuildToolSuite("1.5.2")
class Sbt_013_BuildToolSuite extends SbtBuildToolSuite("0.13.17")

0 comments on commit e520f37

Please sign in to comment.