@@ -4,7 +4,7 @@ import com.eed3si9n.expecty.Expecty.expect
44
55import java .io .IOException
66import scala .build .{BuildThreads , Directories , LocalRepo , Position , Positioned }
7- import scala .build .options .{BuildOptions , InternalOptions , MaybeScalaVersion }
7+ import scala .build .options .{BuildOptions , InternalOptions , MaybeScalaVersion , ScalacOpt }
88import scala .build .tests .util .BloopServer
99import build .Ops .EitherThrowOps
1010import scala .build .Position
@@ -107,4 +107,60 @@ class DirectiveTests extends munit.FunSuite {
107107 }
108108 }
109109
110+ test(" handling special syntax for path" ) {
111+ val filePath = os.rel / " src" / " simple.scala"
112+ val testInputs = TestInputs (
113+ os.rel / filePath ->
114+ """ //> using options "-coverage-out:${.}""""
115+ )
116+ testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) {
117+ (root, _, maybeBuild) =>
118+ val build = maybeBuild.orThrow
119+ val scalacOptions : Option [Positioned [ScalacOpt ]] =
120+ build.options.scalaOptions.scalacOptions.toSeq.headOption
121+ assert(scalacOptions.nonEmpty)
122+
123+ val scalacOpt = scalacOptions.get.value.value
124+ val expectedCoveragePath = (root / filePath / os.up).toString
125+ expect(scalacOpt == s " -coverage-out: $expectedCoveragePath" )
126+ }
127+ }
128+
129+ test(" handling special syntax for path with more dollars before" ) {
130+ val filePath = os.rel / " src" / " simple.scala"
131+ val testInputs = TestInputs (
132+ os.rel / filePath ->
133+ """ //> using options "-coverage-out:$$${.}""""
134+ )
135+ testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) {
136+ (root, _, maybeBuild) =>
137+ val build = maybeBuild.orThrow
138+ val scalacOptions : Option [Positioned [ScalacOpt ]] =
139+ build.options.scalaOptions.scalacOptions.toSeq.headOption
140+ assert(scalacOptions.nonEmpty)
141+
142+ val scalacOpt = scalacOptions.get.value.value
143+ val expectedCoveragePath = (root / filePath / os.up).toString
144+ expect(scalacOpt == s " -coverage-out: $$ $expectedCoveragePath" )
145+ }
146+ }
147+
148+ test(" skip handling special syntax for path when double dollar" ) {
149+ val filePath = os.rel / " src" / " simple.scala"
150+ val testInputs = TestInputs (
151+ os.rel / filePath ->
152+ """ //> using options "-coverage-out:$${.}""""
153+ )
154+ testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) {
155+ (_, _, maybeBuild) =>
156+ val build = maybeBuild.orThrow
157+ val scalacOptions : Option [Positioned [ScalacOpt ]] =
158+ build.options.scalaOptions.scalacOptions.toSeq.headOption
159+ assert(scalacOptions.nonEmpty)
160+
161+ val scalacOpt = scalacOptions.get.value.value
162+ expect(scalacOpt == """ -coverage-out:${.}""" )
163+ }
164+ }
165+
110166}
0 commit comments