Skip to content

Commit 6fefa30

Browse files
committed
Test custom local repositories passed through launcher params with Scala 3.5.0-RC1-fakeversion-bin-SNAPSHOT
1 parent 04992d3 commit 6fefa30

File tree

3 files changed

+133
-86
lines changed

3 files changed

+133
-86
lines changed

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

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,72 +2107,6 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
21072107
}
21082108
}
21092109

2110-
test("BSP respects --cli-default-scala-version & --predefined-repository launcher options") {
2111-
val sv = "3.5.0-RC1"
2112-
val inputs = TestInputs(
2113-
os.rel / "simple.sc" -> s"""assert(dotty.tools.dotc.config.Properties.simpleVersionString == "$sv")"""
2114-
)
2115-
inputs.fromRoot { root =>
2116-
os.proc(TestUtil.cli, "bloop", "exit", "--power").call(cwd = root)
2117-
val localRepoPath = root / "local-repo"
2118-
val artifactNames = Seq(
2119-
"scala3-compiler_3",
2120-
"scala3-staging_3",
2121-
"scala3-tasty-inspector_3",
2122-
"scala3-sbt-bridge"
2123-
)
2124-
for { artifactName <- artifactNames } {
2125-
val csRes = os.proc(
2126-
TestUtil.cs,
2127-
"fetch",
2128-
"--cache",
2129-
localRepoPath,
2130-
s"org.scala-lang:$artifactName:$sv"
2131-
)
2132-
.call(cwd = root)
2133-
expect(csRes.exitCode == 0)
2134-
}
2135-
os.proc(
2136-
TestUtil.cli,
2137-
"--cli-default-scala-version",
2138-
sv,
2139-
"--predefined-repository",
2140-
(localRepoPath / "https" / "repo1.maven.org" / "maven2").toNIO.toUri.toASCIIString,
2141-
"setup-ide",
2142-
"simple.sc",
2143-
"--with-compiler",
2144-
"--offline",
2145-
"--power"
2146-
)
2147-
.call(cwd = root)
2148-
val ideOptionsPath = root / Constants.workspaceDirName / "ide-options-v2.json"
2149-
expect(ideOptionsPath.toNIO.toFile.exists())
2150-
val ideEnvsPath = root / Constants.workspaceDirName / "ide-envs.json"
2151-
expect(ideEnvsPath.toNIO.toFile.exists())
2152-
val ideLauncherOptionsPath = root / Constants.workspaceDirName / "ide-launcher-options.json"
2153-
expect(ideLauncherOptionsPath.toNIO.toFile.exists())
2154-
val jsonOptions = List("--json-options", ideOptionsPath.toString)
2155-
val launcherOptions = List("--json-launcher-options", ideLauncherOptionsPath.toString)
2156-
val envOptions = List("--envs-file", ideEnvsPath.toString)
2157-
val bspOptions = jsonOptions ++ launcherOptions ++ envOptions
2158-
withBsp(inputs, Seq("."), bspOptions = bspOptions, reuseRoot = Some(root)) {
2159-
(_, _, remoteServer) =>
2160-
async {
2161-
val targets = await(remoteServer.workspaceBuildTargets().asScala)
2162-
.getTargets.asScala
2163-
.filter(!_.getId.getUri.contains("-test"))
2164-
.map(_.getId())
2165-
val compileResult =
2166-
await(remoteServer.buildTargetCompile(new b.CompileParams(targets.asJava)).asScala)
2167-
expect(compileResult.getStatusCode == b.StatusCode.OK)
2168-
val runResult =
2169-
await(remoteServer.buildTargetRun(new b.RunParams(targets.head)).asScala)
2170-
expect(runResult.getStatusCode == b.StatusCode.OK)
2171-
}
2172-
}
2173-
}
2174-
}
2175-
21762110
private def checkIfBloopProjectIsInitialised(
21772111
root: os.Path,
21782112
buildTargetsResp: b.WorkspaceBuildTargetsResult
Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,95 @@
11
package scala.cli.integration
22

3-
class BspTests3NextRc extends BspTestDefinitions with BspTests3Definitions with Test3NextRc
3+
import ch.epfl.scala.bsp4j as b
4+
import com.eed3si9n.expecty.Expecty.expect
5+
6+
import scala.async.Async.{async, await}
7+
import scala.concurrent.ExecutionContext.Implicits.global
8+
import scala.jdk.CollectionConverters.*
9+
import scala.util.Properties
10+
11+
class BspTests3NextRc extends BspTestDefinitions with BspTests3Definitions with Test3NextRc {
12+
test("BSP respects --cli-default-scala-version & --predefined-repository launcher options") {
13+
// 3.5.0-RC1-fakeversion-bin-SNAPSHOT has too long filenames for Windows.
14+
// Yes, seriously. Which is why we can't use it there.
15+
val sv = if (Properties.isWin) Constants.scala3NextRc else "3.5.0-RC1-fakeversion-bin-SNAPSHOT"
16+
val inputs = TestInputs(
17+
os.rel / "simple.sc" -> s"""assert(dotty.tools.dotc.config.Properties.versionNumberString == "$sv")"""
18+
)
19+
inputs.fromRoot { root =>
20+
os.proc(TestUtil.cli, "bloop", "exit", "--power").call(cwd = root)
21+
val localRepoPath = root / "local-repo"
22+
if (Properties.isWin) {
23+
val artifactNames = Seq(
24+
"scala3-compiler_3",
25+
"scala3-staging_3",
26+
"scala3-tasty-inspector_3",
27+
"scala3-sbt-bridge"
28+
)
29+
for { artifactName <- artifactNames } {
30+
val csRes = os.proc(
31+
TestUtil.cs,
32+
"fetch",
33+
"--cache",
34+
localRepoPath,
35+
s"org.scala-lang:$artifactName:$sv"
36+
)
37+
.call(cwd = root)
38+
expect(csRes.exitCode == 0)
39+
}
40+
}
41+
else {
42+
TestUtil.initializeGit(root)
43+
os.proc(
44+
"git",
45+
"clone",
46+
"https://github.com/dotty-staging/maven-test-repo.git",
47+
localRepoPath.toString
48+
).call(cwd = root)
49+
}
50+
val predefinedRepository =
51+
if (Properties.isWin)
52+
(localRepoPath / "https" / "repo1.maven.org" / "maven2").toNIO.toUri.toASCIIString
53+
else
54+
(localRepoPath / "thecache" / "https" / "repo1.maven.org" / "maven2").toNIO.toUri.toASCIIString
55+
os.proc(
56+
TestUtil.cli,
57+
"--cli-default-scala-version",
58+
sv,
59+
"--predefined-repository",
60+
predefinedRepository,
61+
"setup-ide",
62+
"simple.sc",
63+
"--with-compiler",
64+
"--offline",
65+
"--power"
66+
)
67+
.call(cwd = root)
68+
val ideOptionsPath = root / Constants.workspaceDirName / "ide-options-v2.json"
69+
expect(ideOptionsPath.toNIO.toFile.exists())
70+
val ideEnvsPath = root / Constants.workspaceDirName / "ide-envs.json"
71+
expect(ideEnvsPath.toNIO.toFile.exists())
72+
val ideLauncherOptionsPath = root / Constants.workspaceDirName / "ide-launcher-options.json"
73+
expect(ideLauncherOptionsPath.toNIO.toFile.exists())
74+
val jsonOptions = List("--json-options", ideOptionsPath.toString)
75+
val launcherOptions = List("--json-launcher-options", ideLauncherOptionsPath.toString)
76+
val envOptions = List("--envs-file", ideEnvsPath.toString)
77+
val bspOptions = jsonOptions ++ launcherOptions ++ envOptions
78+
withBsp(inputs, Seq("."), bspOptions = bspOptions, reuseRoot = Some(root)) {
79+
(_, _, remoteServer) =>
80+
async {
81+
val targets = await(remoteServer.workspaceBuildTargets().asScala)
82+
.getTargets.asScala
83+
.filter(!_.getId.getUri.contains("-test"))
84+
.map(_.getId())
85+
val compileResult =
86+
await(remoteServer.buildTargetCompile(new b.CompileParams(targets.asJava)).asScala)
87+
expect(compileResult.getStatusCode == b.StatusCode.OK)
88+
val runResult =
89+
await(remoteServer.buildTargetRun(new b.RunParams(targets.head)).asScala)
90+
expect(runResult.getStatusCode == b.StatusCode.OK)
91+
}
92+
}
93+
}
94+
}
95+
}

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

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -597,38 +597,59 @@ class SipScalaTests extends ScalaCliSuite with SbtTestHelper with MillTestHelper
597597
for {
598598
withBloop <- Seq(true, false)
599599
withBloopString = if (withBloop) "with Bloop" else "with --server=false"
600+
sv3 = if (Properties.isWin) "3.5.0-RC1" else "3.5.0-RC1-fakeversion-bin-SNAPSHOT"
601+
sv2 = "2.13.15-bin-ccdcde3"
600602
} {
601603
test(
602-
s"default Scala version (3.4.1-RC1) coming straight from a predefined local repository $withBloopString"
604+
s"default Scala version ($sv3) coming straight from a predefined local repository $withBloopString"
603605
) {
604606
TestInputs(
605-
os.rel / "simple.sc" -> "println(dotty.tools.dotc.config.Properties.simpleVersionString)"
607+
os.rel / "simple.sc" -> "println(dotty.tools.dotc.config.Properties.versionNumberString)"
606608
)
607609
.fromRoot { root =>
608610
val localRepoPath = root / "local-repo"
609-
val sv = "3.4.1-RC1"
610-
val artifactNames =
611-
Seq("scala3-compiler_3", "scala3-staging_3", "scala3-tasty-inspector_3") ++
612-
(if (withBloop) Seq("scala3-sbt-bridge") else Nil)
613-
for { artifactName <- artifactNames } {
614-
val csRes = os.proc(
615-
TestUtil.cs,
616-
"fetch",
617-
"--cache",
618-
localRepoPath,
619-
s"org.scala-lang:$artifactName:$sv"
620-
)
621-
.call(cwd = root)
622-
expect(csRes.exitCode == 0)
611+
val sv = sv3
612+
if (Properties.isWin) {
613+
// 3.5.0-RC1-fakeversion-bin-SNAPSHOT has too long filenames for Windows.
614+
// Yes, seriously. Which is why we can't use it there.
615+
val artifactNames =
616+
Seq("scala3-compiler_3", "scala3-staging_3", "scala3-tasty-inspector_3") ++
617+
(if (withBloop) Seq("scala3-sbt-bridge") else Nil)
618+
for { artifactName <- artifactNames } {
619+
val csRes = os.proc(
620+
TestUtil.cs,
621+
"fetch",
622+
"--cache",
623+
localRepoPath,
624+
s"org.scala-lang:$artifactName:$sv"
625+
)
626+
.call(cwd = root)
627+
expect(csRes.exitCode == 0)
628+
}
629+
}
630+
else {
631+
TestUtil.initializeGit(root)
632+
os.proc(
633+
"git",
634+
"clone",
635+
"https://github.com/dotty-staging/maven-test-repo.git",
636+
localRepoPath.toString
637+
).call(cwd = root)
623638
}
624639
val buildServerOptions =
625640
if (withBloop) Nil else Seq("--server=false")
641+
642+
val predefinedRepository =
643+
if (Properties.isWin)
644+
(localRepoPath / "https" / "repo1.maven.org" / "maven2").toNIO.toUri.toASCIIString
645+
else
646+
(localRepoPath / "thecache" / "https" / "repo1.maven.org" / "maven2").toNIO.toUri.toASCIIString
626647
val r = os.proc(
627648
TestUtil.cli,
628649
"--cli-default-scala-version",
629650
sv,
630651
"--predefined-repository",
631-
(localRepoPath / "https" / "repo1.maven.org" / "maven2").toNIO.toUri.toASCIIString,
652+
predefinedRepository,
632653
"run",
633654
"simple.sc",
634655
"--with-compiler",
@@ -642,14 +663,14 @@ class SipScalaTests extends ScalaCliSuite with SbtTestHelper with MillTestHelper
642663
}
643664

644665
test(
645-
s"default Scala version (2.13.15-bin-ccdcde3) coming straight from a predefined local repository $withBloopString"
666+
s"default Scala version ($sv2) coming straight from a predefined local repository $withBloopString"
646667
) {
647668
TestInputs(
648669
os.rel / "simple.sc" -> "println(scala.util.Properties.versionNumberString)"
649670
)
650671
.fromRoot { root =>
651672
val localRepoPath = root / "local-repo"
652-
val sv = "2.13.15-bin-ccdcde3"
673+
val sv = sv2
653674
val artifactNames =
654675
Seq("scala-compiler") ++ (if (withBloop) Seq("scala2-sbt-bridge") else Nil)
655676
for { artifactName <- artifactNames } {

0 commit comments

Comments
 (0)