Skip to content

Commit 34ab671

Browse files
authored
Merge pull request #1225 from Gedochao/simplify-test-inputs
NIT Tweak integration tests
2 parents cad549f + cc725b2 commit 34ab671

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1509
-1859
lines changed

modules/integration/docker/src/test/scala/scala/cli/integration/RunDockerTests.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ class RunDockerTests extends munit.FunSuite {
1515
val fileName = "simple.sc"
1616
val message = "Hello"
1717
val inputs = TestInputs(
18-
Seq(
19-
os.rel / fileName ->
20-
s"""val msg = "$message"
21-
|println(msg)
22-
|""".stripMargin
23-
)
18+
os.rel / fileName ->
19+
s"""val msg = "$message"
20+
|println(msg)
21+
|""".stripMargin
2422
)
2523
inputs.fromRoot { root =>
2624
val termOpt = if (System.console() == null) Nil else Seq("-t")

modules/integration/src/main/scala/scala/cli/integration/TestInputs.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import java.util.zip.{ZipEntry, ZipOutputStream}
99
import scala.cli.integration.TestInputs.compress
1010
import scala.util.control.NonFatal
1111

12-
final case class TestInputs(
13-
files: Seq[(os.RelPath, String)]
14-
) {
15-
def add(extraFiles: (os.RelPath, String)*): TestInputs =
16-
copy(files = files ++ extraFiles)
12+
final case class TestInputs(files: (os.RelPath, String)*) {
13+
def add(extraFiles: (os.RelPath, String)*): TestInputs = TestInputs((files ++ extraFiles)*)
14+
1715
private def writeIn(dir: os.Path): Unit =
1816
for ((relPath, content) <- files) {
1917
val path = dir / relPath
@@ -38,6 +36,7 @@ final case class TestInputs(
3836
}
3937

4038
object TestInputs {
39+
def empty: TestInputs = TestInputs()
4140

4241
def compress(zipFilepath: os.Path, files: Seq[(os.RelPath, String)]) = {
4342
val zip = new ZipOutputStream(new FileOutputStream(zipFilepath.toString()))

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

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
package scala.cli.integration
22

33
import com.eed3si9n.expecty.Expecty.expect
4+
import os.proc
45

56
import scala.cli.integration.util.BloopUtil
67

78
class BloopTests extends ScalaCliSuite {
89

9-
def runScalaCli(args: String*) = os.proc(TestUtil.cli, args)
10+
def runScalaCli(args: String*): proc = os.proc(TestUtil.cli, args)
1011

1112
private lazy val bloopDaemonDir =
1213
BloopUtil.bloopDaemonDir(runScalaCli("directories").call().out.text())
1314

14-
val dummyInputs = TestInputs(
15-
Seq(
16-
os.rel / "Test.scala" ->
17-
"""//> using scala "2.13"
18-
|object Test {
19-
| def main(args: Array[String]): Unit =
20-
| println("Hello " + "from test")
21-
|}
22-
|""".stripMargin
23-
)
15+
val dummyInputs: TestInputs = TestInputs(
16+
os.rel / "Test.scala" ->
17+
"""//> using scala "2.13"
18+
|object Test {
19+
| def main(args: Array[String]): Unit =
20+
| println("Hello " + "from test")
21+
|}
22+
|""".stripMargin
2423
)
2524

2625
def testScalaTermination(
@@ -57,7 +56,7 @@ class BloopTests extends ScalaCliSuite {
5756
}
5857

5958
test("invalid bloop options passed via cli cause bloop start failure") {
60-
TestInputs(Seq()).fromRoot { root =>
59+
TestInputs.empty.fromRoot { root =>
6160
runScalaCli("bloop", "exit").call(cwd = root)
6261
val res = runScalaCli("bloop", "start", "--bloop-java-opt", "-zzefhjzl").call(
6362
cwd = root,
@@ -72,12 +71,10 @@ class BloopTests extends ScalaCliSuite {
7271

7372
test("invalid bloop options passed via global bloop config json file cause bloop start failure") {
7473
val inputs = TestInputs(
75-
Seq(
76-
os.rel / "bloop.json" ->
77-
"""|{
78-
| "javaOptions" : ["-Xmx1k"]
79-
| }""".stripMargin
80-
)
74+
os.rel / "bloop.json" ->
75+
"""|{
76+
| "javaOptions" : ["-Xmx1k"]
77+
| }""".stripMargin
8178
)
8279

8380
inputs.fromRoot { root =>
@@ -101,7 +98,7 @@ class BloopTests extends ScalaCliSuite {
10198
javaProcesses.contains("bloop.Bloop")
10299
}
103100

104-
val inputs = TestInputs(Seq.empty)
101+
val inputs = TestInputs.empty
105102
inputs.fromRoot { _ =>
106103
BloopUtil.killBloop()
107104
TestUtil.retry()(assert(!bloopRunning()))
@@ -118,14 +115,12 @@ class BloopTests extends ScalaCliSuite {
118115

119116
test("bloop projects and bloop compile works") {
120117
val inputs = TestInputs(
121-
Seq(
122-
os.rel / "Hello.scala" ->
123-
"""object Hello {
124-
| def main(args: Array[String]): Unit =
125-
| println("Hello")
126-
|}
127-
|""".stripMargin
128-
)
118+
os.rel / "Hello.scala" ->
119+
"""object Hello {
120+
| def main(args: Array[String]): Unit =
121+
| println("Hello")
122+
|}
123+
|""".stripMargin
129124
)
130125
inputs.fromRoot { root =>
131126

0 commit comments

Comments
 (0)