Skip to content

Commit 36c9a11

Browse files
authored
Fix trailing SBT args and add tests (#651)
Additionally: * Drop SBT 0.13 tests
1 parent 1f6c2f8 commit 36c9a11

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/SbtBuildTool.scala

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@ class SbtBuildTool(index: IndexCommand) extends BuildTool("sbt", index) {
4343

4444
private def unconditionallyGenerateScip(): Int =
4545
Using.resource(sourcegraphSbtPluginFile()) { _ =>
46+
val buildCommand = index.finalBuildCommand(List("sourcegraphScip"))
47+
4648
val sourcegraphScip = index
47-
.process(List("sbt", "sourcegraphEnable", "sourcegraphScip"))
49+
.process(List("sbt", "sourcegraphEnable") ++ buildCommand)
50+
4851
val inputDump = index
4952
.workingDirectory
5053
.resolve("target")
5154
.resolve("sbt-sourcegraph")
5255
.resolve("index.scip")
56+
5357
if (sourcegraphScip.exitCode == 0 && Files.isRegularFile(inputDump)) {
5458
val outputDump = index.workingDirectory.resolve(index.output)
5559
Files.copy(inputDump, outputDump, StandardCopyOption.REPLACE_EXISTING)

tests/buildTools/src/test/scala/tests/SbtBuildToolSuite.scala

+28-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package tests
22

3-
abstract class SbtBuildToolSuite(sbtVersion: String)
3+
abstract class SbtBuildToolSuite(val sbtVersion: String)
44
extends BaseBuildToolSuite {
5-
List("2.11.9", "2.12.18", "2.13.11", "3.3.0").foreach { scalaVersion =>
5+
val scala2Versions = List("2.11.9", "2.12.18", "2.13.11")
6+
val scala3Versions = List("3.3.1")
7+
8+
(scala2Versions ++ scala3Versions).foreach { scalaVersion =>
69
checkBuild(
710
s"basic-sbt=$sbtVersion-scala=$scalaVersion",
811
s"""|/build.sbt
912
|scalaVersion := "$scalaVersion"
1013
|libraryDependencies += "junit" % "junit" % "4.13.2"
1114
|/project/build.properties
12-
|sbt.version=1.5.2
15+
|sbt.version=$sbtVersion
1316
|/src/main/java/example/ExampleJava.java
1417
|package example;
1518
|import org.junit.Assert;
@@ -29,8 +32,27 @@ abstract class SbtBuildToolSuite(sbtVersion: String)
2932
targetRoot = Some("target")
3033
)
3134
}
32-
3335
}
3436

35-
class Sbt_1_BuildToolSuite extends SbtBuildToolSuite("1.5.2")
36-
class Sbt_013_BuildToolSuite extends SbtBuildToolSuite("0.13.17")
37+
class Sbt_1_BuildToolSuite extends SbtBuildToolSuite("1.5.2") {
38+
checkBuild(
39+
s"custom-sbt-command=$sbtVersion",
40+
s"""|/build.sbt
41+
|lazy val bla = project.in(file("bla"))
42+
|lazy val blaJS = project.in(file("bla-js")).enablePlugins(ScalaJSPlugin)
43+
|/project/plugins.sbt
44+
|addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0")
45+
|/project/build.properties
46+
|sbt.version=$sbtVersion
47+
|/bla/src/main/scala/example/ExampleScala.scala
48+
|package example
49+
|class ExampleScala()
50+
|/bla-js/src/main/scala/example/ExampleScala.scala
51+
|package example
52+
|class ExampleScala!!!() // this file is intentionally broken
53+
|""".stripMargin,
54+
expectedSemanticdbFiles = 1,
55+
extraArguments = List("--", "bla/compile"),
56+
targetRoot = Some("bla/target")
57+
)
58+
}

0 commit comments

Comments
 (0)