Skip to content

Commit

Permalink
Fix trailing SBT args and add tests (#651)
Browse files Browse the repository at this point in the history
Additionally:
* Drop SBT 0.13 tests
  • Loading branch information
keynmol authored Sep 27, 2023
1 parent 1f6c2f8 commit 36c9a11
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ class SbtBuildTool(index: IndexCommand) extends BuildTool("sbt", index) {

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

val sourcegraphScip = index
.process(List("sbt", "sourcegraphEnable", "sourcegraphScip"))
.process(List("sbt", "sourcegraphEnable") ++ buildCommand)

val inputDump = index
.workingDirectory
.resolve("target")
.resolve("sbt-sourcegraph")
.resolve("index.scip")

if (sourcegraphScip.exitCode == 0 && Files.isRegularFile(inputDump)) {
val outputDump = index.workingDirectory.resolve(index.output)
Files.copy(inputDump, outputDump, StandardCopyOption.REPLACE_EXISTING)
Expand Down
34 changes: 28 additions & 6 deletions tests/buildTools/src/test/scala/tests/SbtBuildToolSuite.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
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 =>
val scala2Versions = List("2.11.9", "2.12.18", "2.13.11")
val scala3Versions = List("3.3.1")

(scala2Versions ++ scala3Versions).foreach { scalaVersion =>
checkBuild(
s"basic-sbt=$sbtVersion-scala=$scalaVersion",
s"""|/build.sbt
|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 +32,27 @@ abstract class SbtBuildToolSuite(sbtVersion: String)
targetRoot = Some("target")
)
}

}

class Sbt_1_BuildToolSuite extends SbtBuildToolSuite("1.5.2")
class Sbt_013_BuildToolSuite extends SbtBuildToolSuite("0.13.17")
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")
)
}

0 comments on commit 36c9a11

Please sign in to comment.