Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trailing SBT args and add tests #651

Merged
merged 4 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
)
}
Loading