Skip to content

Commit e663e6f

Browse files
committed
NIT convert some source JAR integration to unit tests
1 parent e5bf067 commit e663e6f

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

modules/build/src/test/scala/scala/build/tests/DirectiveTests.scala

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,39 @@ class DirectiveTests extends munit.FunSuite {
290290
}
291291
}
292292

293+
def testSourceJar(getDirectives: (String, String) => String): Unit = {
294+
val dummyJar = "Dummy.jar"
295+
val dummySourcesJar = "Dummy-sources.jar"
296+
TestInputs(
297+
os.rel / "Main.scala" ->
298+
s"""${getDirectives(dummyJar, dummySourcesJar)}
299+
|object Main extends App {
300+
| println("Hello")
301+
|}
302+
|""".stripMargin,
303+
os.rel / dummyJar -> "dummy",
304+
os.rel / dummySourcesJar -> "dummy-sources"
305+
).withBuild(baseOptions, buildThreads, bloopConfigOpt) {
306+
(root, _, maybeBuild) =>
307+
val build = maybeBuild.orThrow
308+
val Some(jar) = build.options.classPathOptions.extraClassPath.headOption
309+
expect(jar == root / dummyJar)
310+
val Some(sourceJar) = build.options.classPathOptions.extraSourceJars.headOption
311+
expect(sourceJar == root / dummySourcesJar)
312+
}
313+
}
314+
315+
test("source jar") {
316+
testSourceJar((dummyJar, dummySourcesJar) =>
317+
s"""//> using jar $dummyJar
318+
|//> using sourceJar $dummySourcesJar""".stripMargin
319+
)
320+
}
321+
322+
test("assumed source jar") {
323+
testSourceJar((dummyJar, dummySourcesJar) =>
324+
s"//> using jars $dummyJar $dummySourcesJar"
325+
)
326+
}
327+
293328
}

modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,28 +1460,12 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
14601460
testSourceJars(getBspOptions = sourceJarPath => List("--source-jar", sourceJarPath.toString))
14611461
}
14621462

1463-
test("source jars handled correctly from a using directive") {
1464-
testSourceJars(directives =
1465-
"""//> using jar Message.jar
1466-
|//> using sourceJar Message-sources.jar""".stripMargin
1467-
)
1468-
}
1469-
14701463
test(
14711464
"source jars handled correctly from the command line smartly assuming a *-sources.jar is a source jar"
14721465
) {
14731466
testSourceJars(getBspOptions = sourceJarPath => List("--extra-jar", sourceJarPath.toString))
14741467
}
14751468

1476-
test(
1477-
"source jars handled correctly from a using directive smartly assuming a *-sources.jar is a source jar"
1478-
) {
1479-
testSourceJars(directives =
1480-
"""//> using jar Message.jar
1481-
|//> using jar Message-sources.jar""".stripMargin
1482-
)
1483-
}
1484-
14851469
test("source jars handled correctly from a test scope using directive") {
14861470
testSourceJars(
14871471
directives = """//> using jar Message.jar

0 commit comments

Comments
 (0)