Skip to content

Commit 21ff792

Browse files
committed
NIT refactor using directives usage in unit tests: get rid of unnecessary commas and double quote escapes
1 parent cdd3f52 commit 21ff792

12 files changed

+126
-126
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ActionableDiagnosticTests extends TestUtil.ScalaCliBuildSuite {
5757
val testInputs = TestInputs(
5858
os.rel / "Foo.scala" ->
5959
s"""//> using dep $dependencyOsLib
60-
|//> using dep "$dependencyPprintLib"
60+
|//> using dep $dependencyPprintLib
6161
|
6262
|object Hello extends App {
6363
| println("Hello")
@@ -79,7 +79,7 @@ class ActionableDiagnosticTests extends TestUtil.ScalaCliBuildSuite {
7979
actionableDiagnostics.find(_.suggestion.startsWith("com.lihaoyi::pprint")).get
8080

8181
expect(osLib.positions == Seq(File(Right(root / "Foo.scala"), (0, 14), (0, 39))))
82-
expect(pprintLib.positions == Seq(File(Right(root / "Foo.scala"), (1, 15), (1, 40))))
82+
expect(pprintLib.positions == Seq(File(Right(root / "Foo.scala"), (1, 14), (1, 39))))
8383
}
8484
}
8585

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ abstract class BuildTests(server: Boolean) extends TestUtil.ScalaCliBuildSuite {
330330
|pprint.log(g)
331331
|""".stripMargin,
332332
os.rel / "simple2.sc" ->
333-
"""//> using dep com.lihaoyi::geny:0.6.5, "com.lihaoyi::pprint:0.6.6"
333+
"""//> using dep com.lihaoyi::geny:0.6.5 com.lihaoyi::pprint:0.6.6
334334
|import geny.Generator
335335
|val g = Generator("Hel", "lo")
336336
|pprint.log(g)
@@ -422,7 +422,7 @@ abstract class BuildTests(server: Boolean) extends TestUtil.ScalaCliBuildSuite {
422422
|}
423423
|""".stripMargin,
424424
os.rel / "Ignored.scala" ->
425-
"""//> using target.scala.== "2.12"
425+
"""//> using target.scala.== 2.12
426426
|object Ignored {
427427
| def foo = 2
428428
|}
@@ -702,16 +702,16 @@ abstract class BuildTests(server: Boolean) extends TestUtil.ScalaCliBuildSuite {
702702
test("repeated Java options") {
703703
val inputs = TestInputs(
704704
os.rel / "foo.sc" ->
705-
"""//> using javaOpt --add-opens, "foo/bar"
706-
|//> using javaOpt --add-opens, "other/thing"
707-
|//> using javaOpt --add-exports, "foo/bar"
708-
|//> using javaOpt --add-exports, "other/thing"
709-
|//> using javaOpt --add-modules, "foo/bar"
710-
|//> using javaOpt --add-modules, other/thing
711-
|//> using javaOpt --add-reads, "foo/bar"
712-
|//> using javaOpt --add-reads, "other/thing"
713-
|//> using javaOpt "--patch-module", "foo/bar"
714-
|//> using javaOpt "--patch-module", "other/thing"
705+
"""//> using javaOpt --add-opens foo/bar
706+
|//> using javaOpt --add-opens other/thing
707+
|//> using javaOpt --add-exports foo/bar
708+
|//> using javaOpt --add-exports other/thing
709+
|//> using javaOpt --add-modules foo/bar
710+
|//> using javaOpt --add-modules other/thing
711+
|//> using javaOpt --add-reads foo/bar
712+
|//> using javaOpt --add-reads other/thing
713+
|//> using javaOpt --patch-module foo/bar
714+
|//> using javaOpt --patch-module other/thing
715715
|
716716
|def foo = "bar"
717717
|""".stripMargin
@@ -743,7 +743,7 @@ abstract class BuildTests(server: Boolean) extends TestUtil.ScalaCliBuildSuite {
743743
test("-source:future not internally duplicating") {
744744
val inputs = TestInputs(
745745
os.rel / "foo.scala" ->
746-
"""//> using option "-source:future"
746+
"""//> using option -source:future
747747
|def foo = "bar"
748748
|""".stripMargin
749749
)
@@ -762,7 +762,7 @@ abstract class BuildTests(server: Boolean) extends TestUtil.ScalaCliBuildSuite {
762762
val inputs = TestInputs(
763763
os.rel / "foo.scala" ->
764764
"""//> using scala 2.13
765-
|//> using options -deprecation, "-feature", "-Xmaxwarns", "1"
765+
|//> using options -deprecation -feature -Xmaxwarns 1
766766
|//> using option -Xdisable-assertions
767767
|
768768
|def foo = "bar"

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
4444
)
4545
)
4646

47-
test("resolving position of lib directive") {
47+
test("resolving position of dep directive") {
4848
val testInputs = TestInputs(
4949
os.rel / "simple.sc" ->
50-
"""//> using dep "com.lihaoyi::utest:0.7.10"
50+
"""//> using dep com.lihaoyi::utest:0.7.10
5151
|""".stripMargin
5252
)
5353
testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) {
@@ -64,15 +64,15 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
6464
case _ => sys.error("cannot happen")
6565
}
6666

67-
expect(startPos == (0, 15))
68-
expect(endPos == (0, 40))
67+
expect(startPos == (0, 14))
68+
expect(endPos == (0, 39))
6969
}
7070
}
7171

7272
test("should parse javac options") {
7373
val testInputs = TestInputs(
7474
os.rel / "simple.sc" ->
75-
"""//> using javacOpt "source", "1.8", "target", "1.8"
75+
"""//> using javacOpt source 1.8 target 1.8
7676
|""".stripMargin
7777
)
7878
testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) {
@@ -90,7 +90,7 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
9090
Seq("--no-fallback", "--enable-url-protocols=http,https")
9191
TestInputs(
9292
os.rel / "simple.sc" ->
93-
s"""//> using packaging.graalvmArgs "$noFallback", "$enableUrl"
93+
s"""//> using packaging.graalvmArgs $noFallback $enableUrl
9494
|""".stripMargin
9595
).withBuild(baseOptions, buildThreads, bloopConfigOpt) {
9696
(_, _, maybeBuild) =>
@@ -155,8 +155,8 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
155155
}
156156

157157
test(s"resolve test scope dependencies correctly when building for ${scope.name} scope") {
158-
withProjectFile(projectFileContent = """//> using dep "com.lihaoyi::os-lib:0.9.1"
159-
|//> using test.dep "org.scalameta::munit::0.7.29"
158+
withProjectFile(projectFileContent = """//> using dep com.lihaoyi::os-lib:0.9.1
159+
|//> using test.dep org.scalameta::munit::0.7.29
160160
|""".stripMargin) { (build, isTestScope) =>
161161
val deps = build.options.classPathOptions.extraDependencies.toSeq.map(_.value)
162162
expect(deps.nonEmpty)
@@ -172,9 +172,9 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
172172
}
173173
test(s"resolve test scope javacOpts correctly when building for ${scope.name} scope") {
174174
withProjectFile(projectFileContent =
175-
"""//> using javacOpt "source", "1.8"
176-
|//> using test.javacOpt "target", "1.8"
177-
|//> using test.dep "org.scalameta::munit::0.7.29"
175+
"""//> using javacOpt source 1.8
176+
|//> using test.javacOpt target 1.8
177+
|//> using test.dep org.scalameta::munit::0.7.29
178178
|""".stripMargin
179179
) { (build, isTestScope) =>
180180
val javacOpts = build.options.javaOptions.javacOptions.map(_.value)
@@ -185,9 +185,9 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
185185
}
186186
test(s"resolve test scope scalac opts correctly when building for ${scope.name} scope") {
187187
withProjectFile(projectFileContent =
188-
"""//> using option "--explain"
189-
|//> using test.option "-deprecation"
190-
|//> using test.dep "org.scalameta::munit::0.7.29"
188+
"""//> using option --explain
189+
|//> using test.option -deprecation
190+
|//> using test.dep org.scalameta::munit::0.7.29
191191
|""".stripMargin
192192
) { (build, isTestScope) =>
193193
val scalacOpts = build.options.scalaOptions.scalacOptions.toSeq.map(_.value.value)
@@ -198,9 +198,9 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
198198
}
199199
test(s"resolve test scope javaOpts correctly when building for ${scope.name} scope") {
200200
withProjectFile(projectFileContent =
201-
"""//> using javaOpt "-Xmx2g"
202-
|//> using test.javaOpt "-Dsomething=a"
203-
|//> using test.dep "org.scalameta::munit::0.7.29"
201+
"""//> using javaOpt -Xmx2g
202+
|//> using test.javaOpt -Dsomething=a
203+
|//> using test.dep org.scalameta::munit::0.7.29
204204
|""".stripMargin
205205
) { (build, isTestScope) =>
206206
val javaOpts = build.options.javaOptions.javaOpts.toSeq.map(_.value.value)
@@ -211,9 +211,9 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
211211
}
212212
test(s"resolve test scope javaProps correctly when building for ${scope.name} scope") {
213213
withProjectFile(projectFileContent =
214-
"""//> using javaProp "foo=1"
215-
|//> using test.javaProp "bar=2"
216-
|//> using test.dep "org.scalameta::munit::0.7.29"
214+
"""//> using javaProp foo=1
215+
|//> using test.javaProp bar=2
216+
|//> using test.dep org.scalameta::munit::0.7.29
217217
|""".stripMargin
218218
) { (build, isTestScope) =>
219219
val javaProps = build.options.javaOptions.javaOpts.toSeq.map(_.value.value)
@@ -224,9 +224,9 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
224224
}
225225
test(s"resolve test scope resourceDir correctly when building for ${scope.name} scope") {
226226
withProjectFile(projectFileContent =
227-
"""//> using resourceDir "./mainResources"
228-
|//> using test.resourceDir "./testResources"
229-
|//> using test.dep "org.scalameta::munit::0.7.29"
227+
"""//> using resourceDir ./mainResources
228+
|//> using test.resourceDir ./testResources
229+
|//> using test.dep org.scalameta::munit::0.7.29
230230
|""".stripMargin
231231
) { (build, isTestScope) =>
232232
val resourcesDirs = build.options.classPathOptions.resourcesDir
@@ -265,7 +265,7 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
265265
val filePath = os.rel / "src" / "simple.scala"
266266
val testInputs = TestInputs(
267267
os.rel / filePath ->
268-
"""//> using options "-coverage-out:${.}""""
268+
"""//> using options -coverage-out:${.}"""
269269
)
270270
testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) {
271271
(root, _, maybeBuild) =>
@@ -284,7 +284,7 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
284284
val filePath = os.rel / "src" / "simple.scala"
285285
val testInputs = TestInputs(
286286
os.rel / filePath ->
287-
"""//> using options "-coverage-out:$$${.}""""
287+
"""//> using options -coverage-out:$$${.}"""
288288
)
289289
testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) {
290290
(root, _, maybeBuild) =>
@@ -303,7 +303,7 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite {
303303
val filePath = os.rel / "src" / "simple.scala"
304304
val testInputs = TestInputs(
305305
os.rel / filePath ->
306-
"""//> using options "-coverage-out:$${.}""""
306+
"""//> using options -coverage-out:$${.}"""
307307
)
308308
testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) {
309309
(_, _, maybeBuild) =>

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite {
3333
test("throw error when exclude found in multiple files") {
3434
val testInputs = TestInputs(
3535
os.rel / "Hello.scala" ->
36-
"""//> using exclude "*.sc"
36+
"""//> using exclude *.sc
3737
|""".stripMargin,
3838
os.rel / "Main.scala" ->
39-
"""//> using exclude "*/test/*"
39+
"""//> using exclude */test/*
4040
|""".stripMargin
4141
)
4242
testInputs.withInputs { (_, inputs) =>
@@ -57,10 +57,10 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite {
5757
test("throw error when exclude found in non top-level project.scala and file") {
5858
val testInputs = TestInputs(
5959
os.rel / "Main.scala" ->
60-
"""//> using exclude "*/test/*"
60+
"""//> using exclude */test/*
6161
|""".stripMargin,
6262
os.rel / "src" / "project.scala" ->
63-
s"""//> using exclude "*.sc" """
63+
s"""//> using exclude *.sc"""
6464
)
6565
testInputs.withInputs { (_, inputs) =>
6666
val crossSources =
@@ -84,7 +84,7 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite {
8484
"""object Main {
8585
|}""".stripMargin,
8686
os.rel / "project.scala" ->
87-
s"""//> using exclude "Main.scala" """
87+
s"""//> using exclude Main.scala"""
8888
)
8989
testInputs.withInputs { (root, inputs) =>
9090
val (crossSources, _) =
@@ -118,7 +118,7 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite {
118118
"""object Main {
119119
|}""".stripMargin,
120120
os.rel / "project.scala" ->
121-
s"""//> using exclude "$${.}${File.separator}Main.scala" """
121+
s"""//> using exclude $${.}${File.separator}Main.scala"""
122122
)
123123
testInputs.withInputs { (root, inputs) =>
124124
val (crossSources, _) =
@@ -152,7 +152,7 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite {
152152
"""object Main {
153153
|}""".stripMargin,
154154
os.rel / "project.scala" ->
155-
"""//> using exclude "src/*.scala" """
155+
"""//> using exclude src/*.scala"""
156156
)
157157
testInputs.withInputs { (root, inputs) =>
158158
val (crossSources, _) =
@@ -186,7 +186,7 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite {
186186
"""object Main {
187187
|}""".stripMargin,
188188
os.rel / "project.scala" ->
189-
"""//> using exclude "src/*.scala" """
189+
"""//> using exclude src/*.scala"""
190190
)
191191
testInputs.withInputs { (root, inputs) =>
192192
val (crossSources, _) =

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class PackagingUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite {
2424
test("package type") {
2525
val inputs = TestInputs(
2626
os.rel / "p.sc" ->
27-
"""//> using packaging.packageType "graalvm"
27+
"""//> using packaging.packageType graalvm
2828
|def foo() = println("hello foo")
2929
|""".stripMargin
3030
)
@@ -38,7 +38,7 @@ class PackagingUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite {
3838
val output = "foo"
3939
val inputs = TestInputs(
4040
os.rel / "Bar.scala" ->
41-
s"""//> using packaging.output "$output"
41+
s"""//> using packaging.output $output
4242
|def hello() = println("hello")
4343
|""".stripMargin
4444
)
@@ -54,10 +54,10 @@ class PackagingUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite {
5454
test("docker options") {
5555
val inputs = TestInputs(
5656
os.rel / "p.sc" ->
57-
"""//> using packaging.dockerFrom "openjdk:11"
58-
|//> using packaging.dockerImageTag "1.0.0"
59-
|//> using packaging.dockerImageRegistry "virtuslab"
60-
|//> using packaging.dockerImageRepository "scala-cli"
57+
"""//> using packaging.dockerFrom openjdk:11
58+
|//> using packaging.dockerImageTag 1.0.0
59+
|//> using packaging.dockerImageRegistry virtuslab
60+
|//> using packaging.dockerImageRepository scala-cli
6161
|
6262
|def foo() = println("hello foo")
6363
|""".stripMargin

0 commit comments

Comments
 (0)