Skip to content

Commit

Permalink
Update sbt-sourcegraph and re-enable SBT build tool tests (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
keynmol committed Aug 16, 2023
1 parent e75a04c commit 6f17cbe
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
14 changes: 11 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,10 @@ lazy val buildTools = project
Map(
"SCIP_JAVA_CLI" -> ((cli / pack).value / "bin" / "scip-java").toString
),
Test / fork := true
Test / fork := true,
// Our CI set up is a couple of measly vCPUs so parallelising tests there makes
// everything worse
Test / testForkedParallel := !sys.env.contains("CI")
)
.dependsOn(agent, unit)

Expand Down Expand Up @@ -564,11 +567,16 @@ lazy val javaOnlySettings = List[Def.Setting[_]](
crossPaths := false
)

lazy val testSettings = List(
val testSettings = List(
(publish / skip) := true,
autoScalaLibrary := true,
testFrameworks := List(TestFrameworks.MUnit),
testOptions ++= List(Tests.Argument(TestFrameworks.MUnit, "-b")),
testOptions ++= {
if (!(Test / testForkedParallel).value)
List(Tests.Argument(TestFrameworks.MUnit, "-b"))
else
Nil
},
libraryDependencies ++=
List(
"org.scalameta" %% "munit" % "0.7.29",
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.24")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.1")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6")
addSbtPlugin("com.sourcegraph" % "sbt-sourcegraph" % "0.4.0")
addSbtPlugin("com.sourcegraph" % "sbt-sourcegraph" % "0.4.2")
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.6.1")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0")
Expand Down
12 changes: 10 additions & 2 deletions tests/buildTools/src/test/scala/tests/BaseBuildToolSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import os.Shellable
object Java8Only extends munit.Tag("Java8Only")

abstract class BaseBuildToolSuite extends MopedSuite(ScipJava.app) {
self =>
override def environmentVariables: Map[String, String] = sys.env

def tags = List.empty[Tag]
Expand Down Expand Up @@ -49,8 +50,15 @@ abstract class BaseBuildToolSuite extends MopedSuite(ScipJava.app) {
// NOTE(olafur): workaround for https://github.com/scalameta/moped/issues/18
override val temporaryDirectory: DirectoryFixture =
new DirectoryFixture {
private val path = BuildInfo.temporaryDirectory.toPath
override def apply(): Path = path
private val path = BuildInfo
.temporaryDirectory
.toPath
.resolve(self.getClass().getSimpleName())

override def apply(): Path = {
Files.createDirectories(path)
path
}
override def beforeEach(context: BeforeEach): Unit = {
DeleteVisitor.deleteRecursively(path)
}
Expand Down
26 changes: 11 additions & 15 deletions tests/buildTools/src/test/scala/tests/SbtBuildToolSuite.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package tests

import munit.IgnoreSuite

// Ignored because the sbt-sourcegraph plugin adds the -build-tool:sbt flag, which
// is yet not supported by any stable release of scip-java. We can un-ignore this
// test suite after the next release.
@IgnoreSuite
class SbtBuildToolSuite extends BaseBuildToolSuite {
List("1.5.2", "0.13.17").foreach { version =>
abstract class SbtBuildToolSuite(sbtVersion: String)
extends BaseBuildToolSuite {
List("2.11.9", "2.12.18", "2.13.11", "3.3.0").foreach { scalaVersion =>
checkBuild(
s"basic-$version",
s"basic-sbt=$sbtVersion-scala=$scalaVersion",
s"""|/build.sbt
|scalaVersion := "2.11.9"
|scalaVersion := "$scalaVersion"
|libraryDependencies += "junit" % "junit" % "4.13.2"
|/project/build.properties
|sbt.version=1.5.2
Expand All @@ -25,16 +20,17 @@ class SbtBuildToolSuite extends BaseBuildToolSuite {
|class ExampleScala()
|/src/test/java/example/ExampleJavaSuite.java
|package example;
|public class ExampleSuite {}
|/src/test/scala/example/ExampleScalaSuite.java
|public class ExampleJavaSuite {}
|/src/test/scala/example/ExampleaSuite.scala
|package example
|class ExampleSuite() {}
|""".stripMargin,
expectedSemanticdbFiles = 4,
expectedPackages =
"""|maven:junit:junit:4.13.1
|""".stripMargin
targetRoot = Some("target")
)
}

}

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

0 comments on commit 6f17cbe

Please sign in to comment.