From 1595b2036b2c47122311ed9b2aa1291c252d4c01 Mon Sep 17 00:00:00 2001 From: Piotr Chabelski Date: Mon, 2 Dec 2024 14:57:25 +0100 Subject: [PATCH] NIT refactor using directives usage in unit tests: get rid of unnecessary commas and double quote escapes --- .../tests/ActionableDiagnosticTests.scala | 4 +- .../scala/scala/build/tests/BuildTests.scala | 28 ++++----- .../scala/build/tests/DirectiveTests.scala | 52 ++++++++-------- .../scala/build/tests/ExcludeTests.scala | 16 ++--- .../tests/PackagingUsingDirectiveTests.scala | 12 ++-- .../ScalaNativeUsingDirectiveTests.scala | 24 +++---- .../build/tests/ScalaPreprocessorTests.scala | 8 +-- .../build/tests/ScriptWrapperTests.scala | 16 ++--- .../build/tests/SourceGeneratorTests.scala | 24 +++---- .../scala/build/tests/SourcesTests.scala | 62 +++++++++---------- .../markdown/MarkdownCodeBlockTests.scala | 2 +- .../markdown/MarkdownCodeWrapperTests.scala | 4 +- 12 files changed, 126 insertions(+), 126 deletions(-) diff --git a/modules/build/src/test/scala/scala/build/tests/ActionableDiagnosticTests.scala b/modules/build/src/test/scala/scala/build/tests/ActionableDiagnosticTests.scala index f2cd0fa9be..d9b6fbdc42 100644 --- a/modules/build/src/test/scala/scala/build/tests/ActionableDiagnosticTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/ActionableDiagnosticTests.scala @@ -57,7 +57,7 @@ class ActionableDiagnosticTests extends TestUtil.ScalaCliBuildSuite { val testInputs = TestInputs( os.rel / "Foo.scala" -> s"""//> using dep $dependencyOsLib - |//> using dep "$dependencyPprintLib" + |//> using dep $dependencyPprintLib | |object Hello extends App { | println("Hello") @@ -79,7 +79,7 @@ class ActionableDiagnosticTests extends TestUtil.ScalaCliBuildSuite { actionableDiagnostics.find(_.suggestion.startsWith("com.lihaoyi::pprint")).get expect(osLib.positions == Seq(File(Right(root / "Foo.scala"), (0, 14), (0, 39)))) - expect(pprintLib.positions == Seq(File(Right(root / "Foo.scala"), (1, 15), (1, 40)))) + expect(pprintLib.positions == Seq(File(Right(root / "Foo.scala"), (1, 14), (1, 39)))) } } diff --git a/modules/build/src/test/scala/scala/build/tests/BuildTests.scala b/modules/build/src/test/scala/scala/build/tests/BuildTests.scala index d8044bf84a..afaaed083f 100644 --- a/modules/build/src/test/scala/scala/build/tests/BuildTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/BuildTests.scala @@ -330,7 +330,7 @@ abstract class BuildTests(server: Boolean) extends TestUtil.ScalaCliBuildSuite { |pprint.log(g) |""".stripMargin, os.rel / "simple2.sc" -> - """//> using dep com.lihaoyi::geny:0.6.5, "com.lihaoyi::pprint:0.6.6" + """//> using dep com.lihaoyi::geny:0.6.5 com.lihaoyi::pprint:0.6.6 |import geny.Generator |val g = Generator("Hel", "lo") |pprint.log(g) @@ -422,7 +422,7 @@ abstract class BuildTests(server: Boolean) extends TestUtil.ScalaCliBuildSuite { |} |""".stripMargin, os.rel / "Ignored.scala" -> - """//> using target.scala.== "2.12" + """//> using target.scala.== 2.12 |object Ignored { | def foo = 2 |} @@ -702,16 +702,16 @@ abstract class BuildTests(server: Boolean) extends TestUtil.ScalaCliBuildSuite { test("repeated Java options") { val inputs = TestInputs( os.rel / "foo.sc" -> - """//> using javaOpt --add-opens, "foo/bar" - |//> using javaOpt --add-opens, "other/thing" - |//> using javaOpt --add-exports, "foo/bar" - |//> using javaOpt --add-exports, "other/thing" - |//> using javaOpt --add-modules, "foo/bar" - |//> using javaOpt --add-modules, other/thing - |//> using javaOpt --add-reads, "foo/bar" - |//> using javaOpt --add-reads, "other/thing" - |//> using javaOpt "--patch-module", "foo/bar" - |//> using javaOpt "--patch-module", "other/thing" + """//> using javaOpt --add-opens foo/bar + |//> using javaOpt --add-opens other/thing + |//> using javaOpt --add-exports foo/bar + |//> using javaOpt --add-exports other/thing + |//> using javaOpt --add-modules foo/bar + |//> using javaOpt --add-modules other/thing + |//> using javaOpt --add-reads foo/bar + |//> using javaOpt --add-reads other/thing + |//> using javaOpt --patch-module foo/bar + |//> using javaOpt --patch-module other/thing | |def foo = "bar" |""".stripMargin @@ -743,7 +743,7 @@ abstract class BuildTests(server: Boolean) extends TestUtil.ScalaCliBuildSuite { test("-source:future not internally duplicating") { val inputs = TestInputs( os.rel / "foo.scala" -> - """//> using option "-source:future" + """//> using option -source:future |def foo = "bar" |""".stripMargin ) @@ -762,7 +762,7 @@ abstract class BuildTests(server: Boolean) extends TestUtil.ScalaCliBuildSuite { val inputs = TestInputs( os.rel / "foo.scala" -> """//> using scala 2.13 - |//> using options -deprecation, "-feature", "-Xmaxwarns", "1" + |//> using options -deprecation -feature -Xmaxwarns 1 |//> using option -Xdisable-assertions | |def foo = "bar" diff --git a/modules/build/src/test/scala/scala/build/tests/DirectiveTests.scala b/modules/build/src/test/scala/scala/build/tests/DirectiveTests.scala index cfa62c3c68..033fc41bee 100644 --- a/modules/build/src/test/scala/scala/build/tests/DirectiveTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/DirectiveTests.scala @@ -44,10 +44,10 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { ) ) - test("resolving position of lib directive") { + test("resolving position of dep directive") { val testInputs = TestInputs( os.rel / "simple.sc" -> - """//> using dep "com.lihaoyi::utest:0.7.10" + """//> using dep com.lihaoyi::utest:0.7.10 |""".stripMargin ) testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) { @@ -64,15 +64,15 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { case _ => sys.error("cannot happen") } - expect(startPos == (0, 15)) - expect(endPos == (0, 40)) + expect(startPos == (0, 14)) + expect(endPos == (0, 39)) } } test("should parse javac options") { val testInputs = TestInputs( os.rel / "simple.sc" -> - """//> using javacOpt "source", "1.8", "target", "1.8" + """//> using javacOpt source 1.8 target 1.8 |""".stripMargin ) testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) { @@ -90,7 +90,7 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { Seq("--no-fallback", "--enable-url-protocols=http,https") TestInputs( os.rel / "simple.sc" -> - s"""//> using packaging.graalvmArgs "$noFallback", "$enableUrl" + s"""//> using packaging.graalvmArgs $noFallback $enableUrl |""".stripMargin ).withBuild(baseOptions, buildThreads, bloopConfigOpt) { (_, _, maybeBuild) => @@ -155,8 +155,8 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { } test(s"resolve test scope dependencies correctly when building for ${scope.name} scope") { - withProjectFile(projectFileContent = """//> using dep "com.lihaoyi::os-lib:0.9.1" - |//> using test.dep "org.scalameta::munit::0.7.29" + withProjectFile(projectFileContent = """//> using dep com.lihaoyi::os-lib:0.9.1 + |//> using test.dep org.scalameta::munit::0.7.29 |""".stripMargin) { (build, isTestScope) => val deps = build.options.classPathOptions.extraDependencies.toSeq.map(_.value) expect(deps.nonEmpty) @@ -172,9 +172,9 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { } test(s"resolve test scope javacOpts correctly when building for ${scope.name} scope") { withProjectFile(projectFileContent = - """//> using javacOpt "source", "1.8" - |//> using test.javacOpt "target", "1.8" - |//> using test.dep "org.scalameta::munit::0.7.29" + """//> using javacOpt source 1.8 + |//> using test.javacOpt target 1.8 + |//> using test.dep org.scalameta::munit::0.7.29 |""".stripMargin ) { (build, isTestScope) => val javacOpts = build.options.javaOptions.javacOptions.map(_.value) @@ -185,9 +185,9 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { } test(s"resolve test scope scalac opts correctly when building for ${scope.name} scope") { withProjectFile(projectFileContent = - """//> using option "--explain" - |//> using test.option "-deprecation" - |//> using test.dep "org.scalameta::munit::0.7.29" + """//> using option --explain + |//> using test.option -deprecation + |//> using test.dep org.scalameta::munit::0.7.29 |""".stripMargin ) { (build, isTestScope) => val scalacOpts = build.options.scalaOptions.scalacOptions.toSeq.map(_.value.value) @@ -198,9 +198,9 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { } test(s"resolve test scope javaOpts correctly when building for ${scope.name} scope") { withProjectFile(projectFileContent = - """//> using javaOpt "-Xmx2g" - |//> using test.javaOpt "-Dsomething=a" - |//> using test.dep "org.scalameta::munit::0.7.29" + """//> using javaOpt -Xmx2g + |//> using test.javaOpt -Dsomething=a + |//> using test.dep org.scalameta::munit::0.7.29 |""".stripMargin ) { (build, isTestScope) => val javaOpts = build.options.javaOptions.javaOpts.toSeq.map(_.value.value) @@ -211,9 +211,9 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { } test(s"resolve test scope javaProps correctly when building for ${scope.name} scope") { withProjectFile(projectFileContent = - """//> using javaProp "foo=1" - |//> using test.javaProp "bar=2" - |//> using test.dep "org.scalameta::munit::0.7.29" + """//> using javaProp foo=1 + |//> using test.javaProp bar=2 + |//> using test.dep org.scalameta::munit::0.7.29 |""".stripMargin ) { (build, isTestScope) => val javaProps = build.options.javaOptions.javaOpts.toSeq.map(_.value.value) @@ -224,9 +224,9 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { } test(s"resolve test scope resourceDir correctly when building for ${scope.name} scope") { withProjectFile(projectFileContent = - """//> using resourceDir "./mainResources" - |//> using test.resourceDir "./testResources" - |//> using test.dep "org.scalameta::munit::0.7.29" + """//> using resourceDir ./mainResources + |//> using test.resourceDir ./testResources + |//> using test.dep org.scalameta::munit::0.7.29 |""".stripMargin ) { (build, isTestScope) => val resourcesDirs = build.options.classPathOptions.resourcesDir @@ -265,7 +265,7 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { val filePath = os.rel / "src" / "simple.scala" val testInputs = TestInputs( os.rel / filePath -> - """//> using options "-coverage-out:${.}"""" + """//> using options -coverage-out:${.}""" ) testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) { (root, _, maybeBuild) => @@ -284,7 +284,7 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { val filePath = os.rel / "src" / "simple.scala" val testInputs = TestInputs( os.rel / filePath -> - """//> using options "-coverage-out:$$${.}"""" + """//> using options -coverage-out:$$${.}""" ) testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) { (root, _, maybeBuild) => @@ -303,7 +303,7 @@ class DirectiveTests extends TestUtil.ScalaCliBuildSuite { val filePath = os.rel / "src" / "simple.scala" val testInputs = TestInputs( os.rel / filePath -> - """//> using options "-coverage-out:$${.}"""" + """//> using options -coverage-out:$${.}""" ) testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) { (_, _, maybeBuild) => diff --git a/modules/build/src/test/scala/scala/build/tests/ExcludeTests.scala b/modules/build/src/test/scala/scala/build/tests/ExcludeTests.scala index bdea746535..bdd68dce15 100644 --- a/modules/build/src/test/scala/scala/build/tests/ExcludeTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/ExcludeTests.scala @@ -33,10 +33,10 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite { test("throw error when exclude found in multiple files") { val testInputs = TestInputs( os.rel / "Hello.scala" -> - """//> using exclude "*.sc" + """//> using exclude *.sc |""".stripMargin, os.rel / "Main.scala" -> - """//> using exclude "*/test/*" + """//> using exclude */test/* |""".stripMargin ) testInputs.withInputs { (_, inputs) => @@ -57,10 +57,10 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite { test("throw error when exclude found in non top-level project.scala and file") { val testInputs = TestInputs( os.rel / "Main.scala" -> - """//> using exclude "*/test/*" + """//> using exclude */test/* |""".stripMargin, os.rel / "src" / "project.scala" -> - s"""//> using exclude "*.sc" """ + s"""//> using exclude *.sc""" ) testInputs.withInputs { (_, inputs) => val crossSources = @@ -84,7 +84,7 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite { """object Main { |}""".stripMargin, os.rel / "project.scala" -> - s"""//> using exclude "Main.scala" """ + s"""//> using exclude Main.scala""" ) testInputs.withInputs { (root, inputs) => val (crossSources, _) = @@ -118,7 +118,7 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite { """object Main { |}""".stripMargin, os.rel / "project.scala" -> - s"""//> using exclude "$${.}${File.separator}Main.scala" """ + s"""//> using exclude $${.}${File.separator}Main.scala""" ) testInputs.withInputs { (root, inputs) => val (crossSources, _) = @@ -152,7 +152,7 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite { """object Main { |}""".stripMargin, os.rel / "project.scala" -> - """//> using exclude "src/*.scala" """ + """//> using exclude src/*.scala""" ) testInputs.withInputs { (root, inputs) => val (crossSources, _) = @@ -186,7 +186,7 @@ class ExcludeTests extends TestUtil.ScalaCliBuildSuite { """object Main { |}""".stripMargin, os.rel / "project.scala" -> - """//> using exclude "src/*.scala" """ + """//> using exclude src/*.scala""" ) testInputs.withInputs { (root, inputs) => val (crossSources, _) = diff --git a/modules/build/src/test/scala/scala/build/tests/PackagingUsingDirectiveTests.scala b/modules/build/src/test/scala/scala/build/tests/PackagingUsingDirectiveTests.scala index be23adfcee..3072a1791e 100644 --- a/modules/build/src/test/scala/scala/build/tests/PackagingUsingDirectiveTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/PackagingUsingDirectiveTests.scala @@ -24,7 +24,7 @@ class PackagingUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("package type") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using packaging.packageType "graalvm" + """//> using packaging.packageType graalvm |def foo() = println("hello foo") |""".stripMargin ) @@ -38,7 +38,7 @@ class PackagingUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { val output = "foo" val inputs = TestInputs( os.rel / "Bar.scala" -> - s"""//> using packaging.output "$output" + s"""//> using packaging.output $output |def hello() = println("hello") |""".stripMargin ) @@ -54,10 +54,10 @@ class PackagingUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("docker options") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using packaging.dockerFrom "openjdk:11" - |//> using packaging.dockerImageTag "1.0.0" - |//> using packaging.dockerImageRegistry "virtuslab" - |//> using packaging.dockerImageRepository "scala-cli" + """//> using packaging.dockerFrom openjdk:11 + |//> using packaging.dockerImageTag 1.0.0 + |//> using packaging.dockerImageRegistry virtuslab + |//> using packaging.dockerImageRepository scala-cli | |def foo() = println("hello foo") |""".stripMargin diff --git a/modules/build/src/test/scala/scala/build/tests/ScalaNativeUsingDirectiveTests.scala b/modules/build/src/test/scala/scala/build/tests/ScalaNativeUsingDirectiveTests.scala index ca17f08c38..be5c7d76bf 100644 --- a/modules/build/src/test/scala/scala/build/tests/ScalaNativeUsingDirectiveTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/ScalaNativeUsingDirectiveTests.scala @@ -39,7 +39,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-gc with multiple values") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-gc` 78, 12 + """//> using native-gc 78 12 |def foo() = println("hello foo") |""".stripMargin ) @@ -54,7 +54,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-gc") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-gc` "78" + """//> using native-gc 78 |def foo() = println("hello foo") |""".stripMargin ) @@ -81,7 +81,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-mode with multiple values") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-mode` "debug", "release-full" + """//> using native-mode debug release-full |def foo() = println("hello foo") |""".stripMargin ) @@ -95,7 +95,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-mode") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-mode` "release-full" + """//> using native-mode release-full |def foo() = println("hello foo") |""".stripMargin ) @@ -107,7 +107,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-version with multiple values") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-version` "0.4.0", "0.3.3" + """//> using native-version 0.4.0 0.3.3 |def foo() = println("hello foo") |""".stripMargin ) @@ -122,7 +122,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-version") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-version` "0.4.0" + """//> using native-version 0.4.0 |def foo() = println("hello foo") |""".stripMargin ) @@ -135,7 +135,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-compile") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-compile` "compileOption1", "compileOption2" + """//> using native-compile compileOption1 compileOption2 |def foo() = println("hello foo") |""".stripMargin ) @@ -167,7 +167,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-linking") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-linking` "linkingOption1", "linkingOption2" + """//> using native-linking linkingOption1 linkingOption2 |def foo() = println("hello foo") |""".stripMargin ) @@ -184,7 +184,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-clang") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-clang` "clang/path" + """//> using native-clang clang/path |def foo() = println("hello foo") |""".stripMargin ) @@ -198,7 +198,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-clang and multiple values") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-clang` "path1", "path2" + """//> using native-clang path1 path2 |def foo() = println("hello foo") |""".stripMargin ) @@ -212,7 +212,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-clang-pp") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-clang-pp` "clangpp/path" + """//> using native-clang-pp clangpp/path |def foo() = println("hello foo") |""".stripMargin ) @@ -226,7 +226,7 @@ class ScalaNativeUsingDirectiveTests extends TestUtil.ScalaCliBuildSuite { test("ScalaNativeOptions for native-clang-pp and multiple values") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using `native-clang-pp` "path1", "path2" + """//> using native-clang-pp path1 path2 |def foo() = println("hello foo") |""".stripMargin ) diff --git a/modules/build/src/test/scala/scala/build/tests/ScalaPreprocessorTests.scala b/modules/build/src/test/scala/scala/build/tests/ScalaPreprocessorTests.scala index 75862693ff..67dd6bc6b6 100644 --- a/modules/build/src/test/scala/scala/build/tests/ScalaPreprocessorTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/ScalaPreprocessorTests.scala @@ -58,10 +58,10 @@ class ScalaPreprocessorTests extends TestUtil.ScalaCliBuildSuite { } val lastUsingLines = Seq( - "//> using dep \"com.lihaoyi::os-lib::0.8.1\" \"com.lihaoyi::os-lib::0.8.1\"" -> "string literal", - "//> using scala 2.13.7" -> "numerical string", - "//> using objectWrapper true" -> "boolean literal", - "//> using objectWrapper" -> "empty value literal" + "//> using dep com.lihaoyi::os-lib::0.8.1 com.lihaoyi::os-lib::0.8.1" -> "string literal", + "//> using scala 2.13.7" -> "numerical string", + "//> using objectWrapper true" -> "boolean literal", + "//> using objectWrapper" -> "empty value literal" ) for ((lastUsingLine, typeName) <- lastUsingLines) do diff --git a/modules/build/src/test/scala/scala/build/tests/ScriptWrapperTests.scala b/modules/build/src/test/scala/scala/build/tests/ScriptWrapperTests.scala index 161a33cd11..a4379a382e 100644 --- a/modules/build/src/test/scala/scala/build/tests/ScriptWrapperTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/ScriptWrapperTests.scala @@ -97,13 +97,13 @@ class ScriptWrapperTests extends TestUtil.ScalaCliBuildSuite { test(s"class wrapper for scala 3") { val inputs = TestInputs( os.rel / "script1.sc" -> - s"""//> using dep "com.lihaoyi::os-lib:0.9.1" + s"""//> using dep com.lihaoyi::os-lib:0.9.1 | |def main(args: String*): Unit = println("Hello") |main() |""".stripMargin, os.rel / "script2.sc" -> - """//> using dep "com.lihaoyi::os-lib:0.9.1" + """//> using dep com.lihaoyi::os-lib:0.9.1 | |println("Hello") |""".stripMargin @@ -136,14 +136,14 @@ class ScriptWrapperTests extends TestUtil.ScalaCliBuildSuite { } { val inputs = TestInputs( os.rel / "script1.sc" -> - s"""//> using dep "com.lihaoyi::os-lib:0.9.1" + s"""//> using dep com.lihaoyi::os-lib:0.9.1 |${if (useDirectives) directive else ""} | |def main(args: String*): Unit = println("Hello") |main() |""".stripMargin, os.rel / "script2.sc" -> - """//> using dep "com.lihaoyi::os-lib:0.9.1" + """//> using dep com.lihaoyi::os-lib:0.9.1 | |println("Hello") |""".stripMargin @@ -179,14 +179,14 @@ class ScriptWrapperTests extends TestUtil.ScalaCliBuildSuite { } { val inputs = TestInputs( os.rel / "script1.sc" -> - s"""//> using dep "com.lihaoyi::os-lib:0.9.1" + s"""//> using dep com.lihaoyi::os-lib:0.9.1 |${if (useDirectives) directive else ""} | |def main(args: String*): Unit = println("Hello") |main() |""".stripMargin, os.rel / "script2.sc" -> - """//> using dep "com.lihaoyi::os-lib:0.9.1" + """//> using dep com.lihaoyi::os-lib:0.9.1 | |println("Hello") |""".stripMargin @@ -222,7 +222,7 @@ class ScriptWrapperTests extends TestUtil.ScalaCliBuildSuite { } { val inputs = TestInputs( os.rel / "script1.sc" -> - s"""//> using dep "com.lihaoyi::os-lib:0.9.1" + s"""//> using dep com.lihaoyi::os-lib:0.9.1 |//> using $targetDirective |//> using objectWrapper | @@ -230,7 +230,7 @@ class ScriptWrapperTests extends TestUtil.ScalaCliBuildSuite { |main() |""".stripMargin, os.rel / "script2.sc" -> - s"""//> using dep "com.lihaoyi::os-lib:0.9.1" + s"""//> using dep com.lihaoyi::os-lib:0.9.1 |//> using $enablingDirective | |println("Hello") diff --git a/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala b/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala index 66c6c2688d..efaeaba869 100644 --- a/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala @@ -157,12 +157,12 @@ class SourceGeneratorTests extends TestUtil.ScalaCliBuildSuite { test("BuildInfo for native") { val inputs = TestInputs( os.rel / "main.scala" -> - s"""//> using dep "com.lihaoyi::os-lib:0.9.1" - |//> using option "-Xasync" - |//> using plugin "org.wartremover:::wartremover:3.0.9" + s"""//> using dep com.lihaoyi::os-lib:0.9.1 + |//> using option -Xasync + |//> using plugin org.wartremover:::wartremover:3.0.9 |//> using scala 3.2.2 |//> using jvm 11 - |//> using mainClass "Main" + |//> using mainClass Main |//> using resourceDir ./resources |//> using jar TEST1.jar TEST2.jar |//> using platform scala-native @@ -233,12 +233,12 @@ class SourceGeneratorTests extends TestUtil.ScalaCliBuildSuite { test("BuildInfo for js") { val inputs = TestInputs( os.rel / "main.scala" -> - s"""//> using dep "com.lihaoyi::os-lib:0.9.1" - |//> using option "-Xasync" - |//> using plugin "org.wartremover:::wartremover:3.0.9" + s"""//> using dep com.lihaoyi::os-lib:0.9.1 + |//> using option -Xasync + |//> using plugin org.wartremover:::wartremover:3.0.9 |//> using scala 3.2.2 |//> using jvm 11 - |//> using mainClass "Main" + |//> using mainClass Main |//> using resourceDir ./resources |//> using jar TEST1.jar TEST2.jar |//> using platform scala-js @@ -310,12 +310,12 @@ class SourceGeneratorTests extends TestUtil.ScalaCliBuildSuite { test("BuildInfo for Scala 2") { val inputs = TestInputs( os.rel / "main.scala" -> - s"""//> using dep "com.lihaoyi::os-lib:0.9.1" - |//> using option "-Xasync" - |//> using plugin "org.wartremover:::wartremover:3.0.9" + s"""//> using dep com.lihaoyi::os-lib:0.9.1 + |//> using option -Xasync + |//> using plugin org.wartremover:::wartremover:3.0.9 |//> using scala 2.13.6 |//> using jvm 11 - |//> using mainClass "Main" + |//> using mainClass Main |//> using resourceDir ./resources |//> using jar TEST1.jar TEST2.jar | diff --git a/modules/build/src/test/scala/scala/build/tests/SourcesTests.scala b/modules/build/src/test/scala/scala/build/tests/SourcesTests.scala index c50f3afc45..9b05bb2415 100644 --- a/modules/build/src/test/scala/scala/build/tests/SourcesTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/SourcesTests.scala @@ -40,8 +40,8 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test(s"dependencies in .scala - using aliases: $pluralAlias and $singularAlias") { val testInputs = TestInputs( os.rel / "something.scala" -> - s"""//> using $pluralAlias "org1:name1:1.1", "org2::name2:2.2" - |//> using $singularAlias "org3:::name3:3.3" + s"""//> using $pluralAlias org1:name1:1.1 org2::name2:2.2 + |//> using $singularAlias org3:::name3:3.3 |import scala.collection.mutable | |object Something { @@ -87,8 +87,8 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test("dependencies in .scala - using witin tests") { val testInputs = TestInputs( os.rel / "something.test.scala" -> - """//> using deps "org1:name1:1.1", "org2::name2:2.2" - |//> using dep "org3:::name3:3.3" + """//> using deps org1:name1:1.1 org2::name2:2.2 + |//> using dep org3:::name3:3.3 |import scala.collection.mutable | |object Something { @@ -127,8 +127,8 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test("dependencies in .test.scala - using") { val testInputs = TestInputs( os.rel / "something.test.scala" -> - """//> using deps "org1:name1:1.1", "org2::name2:2.2" - |//> using dep "org3:::name3:3.3" + """//> using deps org1:name1:1.1 org2::name2:2.2 + |//> using dep org3:::name3:3.3 |import scala.collection.mutable | |object Something { @@ -167,8 +167,8 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test("dependencies in test/name.scala") { val files = Seq( os.rel / "test" / "something.scala" -> - """//> using deps "org1:name1:1.1", "org2::name2:2.2" - |//> using dep "org3:::name3:3.3" + """//> using deps org1:name1:1.1 org2::name2:2.2 + |//> using dep org3:::name3:3.3 |import scala.collection.mutable | |object Something { @@ -205,9 +205,9 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test("dependencies in .scala - //> using") { val testInputs = TestInputs( os.rel / "something.scala" -> - """//> using dep "org1:name1:1.1" - |//> using dep "org2::name2:2.2" - |//> using dep "org3:::name3:3.3" + """//> using dep org1:name1:1.1 + |//> using dep org2::name2:2.2 + |//> using dep org3:::name3:3.3 |import scala.collection.mutable | |object Something { @@ -251,9 +251,9 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test("dependencies in .java - //> using") { val testInputs = TestInputs( os.rel / "Something.java" -> - """//> using dep "org1:name1:1.1" - |//> using dep "org2::name2:2.2" - |//> using dep "org3:::name3:3.3" + """//> using dep org1:name1:1.1 + |//> using dep org2::name2:2.2 + |//> using dep org3:::name3:3.3 | |public class Something { | public Int a = 1; @@ -383,7 +383,7 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test("dependencies in .sc - using") { val testInputs = TestInputs( os.rel / "something.sc" -> - """//> using deps "org1:name1:1.1", "org2::name2:2.2", "org3:::name3:3.3" + """//> using deps org1:name1:1.1 org2::name2:2.2 org3:::name3:3.3 |import scala.collection.mutable | |def a = 1 @@ -425,9 +425,9 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test("dependencies in .sc - //> using") { val testInputs = TestInputs( os.rel / "something.sc" -> - """//> using dep "org1:name1:1.1" - |//> using dep "org2::name2:2.2" - |//> using dep "org3:::name3:3.3" + """//> using dep org1:name1:1.1 + |//> using dep org2::name2:2.2 + |//> using dep org3:::name3:3.3 |import scala.collection.mutable | |def a = 1 @@ -469,8 +469,8 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test("java props in using directives") { val testInputs = TestInputs( os.rel / "something.sc" -> - """//> using javaProp "foo1" - |//> using javaProp "foo2=bar2" + """//> using javaProp foo1 + |//> using javaProp foo2=bar2 |""".stripMargin ) testInputs.withInputs { (root, inputs) => @@ -495,9 +495,9 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { expect( javaOpts(0).value.value == "-Dfoo1", - javaOpts(0).positions == Seq(Position.File(Right(root / "something.sc"), (0, 20), (0, 24))), + javaOpts(0).positions == Seq(Position.File(Right(root / "something.sc"), (0, 19), (0, 23))), javaOpts(1).value.value == "-Dfoo2=bar2", - javaOpts(1).positions == Seq(Position.File(Right(root / "something.sc"), (1, 20), (1, 29))) + javaOpts(1).positions == Seq(Position.File(Right(root / "something.sc"), (1, 19), (1, 28))) ) } } @@ -505,10 +505,10 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test("js options in using directives") { val testInputs = TestInputs( os.rel / "something.sc" -> - """//> using jsVersion "1.8.0" - |//> using jsMode "mode" + """//> using jsVersion 1.8.0 + |//> using jsMode mode |//> using jsNoOpt - |//> using jsModuleKind "commonjs" + |//> using jsModuleKind commonjs |//> using jsCheckIr true |//> using jsEmitSourceMaps true |//> using jsDom true @@ -516,8 +516,8 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { |//> using jsAllowBigIntsForLongs true |//> using jsAvoidClasses false |//> using jsAvoidLetsAndConsts false - |//> using jsModuleSplitStyleStr "smallestmodules" - |//> using jsEsVersionStr "es2017" + |//> using jsModuleSplitStyleStr smallestmodules + |//> using jsEsVersionStr es2017 |""".stripMargin ) testInputs.withInputs { (root, inputs) => @@ -567,7 +567,7 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test("js options in using directives failure - multiple values") { val testInputs = TestInputs( os.rel / "something.sc" -> - """//> using jsVersion "1.8.0","2.3.4" + """//> using jsVersion 1.8.0 2.3.4 |""".stripMargin ) testInputs.withInputs { (_, inputs) => @@ -588,7 +588,7 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { test("js options in using directives failure - not a boolean") { val testInputs = TestInputs( os.rel / "something.sc" -> - """//> using jsDom "fasle" + """//> using jsDom fasle |""".stripMargin ) testInputs.withInputs { (_, inputs) => @@ -611,8 +611,8 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite { Seq("project.scala", "Main.scala", "Abc.scala", "Message.scala") val testInputs = TestInputs( os.rel / project -> - """//> using dep "com.lihaoyi::os-lib::0.8.1" - |//> using file "Message.scala" + """//> using dep com.lihaoyi::os-lib::0.8.1 + |//> using file Message.scala |""".stripMargin, os.rel / main -> """object Main extends App { diff --git a/modules/build/src/test/scala/scala/build/tests/markdown/MarkdownCodeBlockTests.scala b/modules/build/src/test/scala/scala/build/tests/markdown/MarkdownCodeBlockTests.scala index 44c03e7795..ace923147f 100644 --- a/modules/build/src/test/scala/scala/build/tests/markdown/MarkdownCodeBlockTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/markdown/MarkdownCodeBlockTests.scala @@ -119,7 +119,7 @@ class MarkdownCodeBlockTests extends TestUtil.ScalaCliBuildSuite { test("a test Scala snippet is extracted correctly from markdown") { val code = - """//> using dep "org.scalameta::munit:0.7.29" + """//> using dep org.scalameta::munit:0.7.29 |class Test extends munit.FunSuite { | assert(true) |}""".stripMargin diff --git a/modules/build/src/test/scala/scala/build/tests/markdown/MarkdownCodeWrapperTests.scala b/modules/build/src/test/scala/scala/build/tests/markdown/MarkdownCodeWrapperTests.scala index 6ea556c9bb..608cb7a635 100644 --- a/modules/build/src/test/scala/scala/build/tests/markdown/MarkdownCodeWrapperTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/markdown/MarkdownCodeWrapperTests.scala @@ -143,7 +143,7 @@ class MarkdownCodeWrapperTests extends TestUtil.ScalaCliBuildSuite { test("a test Scala snippet is wrapped correctly") { val snippet = - """//> using dep "org.scalameta::munit:0.7.29" + """//> using dep org.scalameta::munit:0.7.29 |class Test extends munit.FunSuite { | assert(true) |}""".stripMargin @@ -163,7 +163,7 @@ class MarkdownCodeWrapperTests extends TestUtil.ScalaCliBuildSuite { test("multiple test Scala snippets are glued together correctly") { val snippet1 = - """//> using dep "org.scalameta::munit:0.7.29" + """//> using dep org.scalameta::munit:0.7.29 |class Test1 extends munit.FunSuite { | assert(true) |}""".stripMargin