@@ -6,6 +6,7 @@ import org.scalasteward.core.buildtool.BuildRoot
66import org .scalasteward .core .buildtool .sbt .command ._
77import org .scalasteward .core .data .{GroupId , Repo , Version }
88import org .scalasteward .core .edit .scalafix .ScalafixMigration
9+ import org .scalasteward .core .edit .scalafix .ScalafixCli ._
910import org .scalasteward .core .mock .MockContext .context ._
1011import org .scalasteward .core .mock .MockState
1112import org .scalasteward .core .mock .MockState .TraceEntry .Cmd
@@ -138,13 +139,23 @@ class SbtAlgTest extends FunSuite {
138139 )
139140 val initialState = MockState .empty
140141 .addFiles(
142+ repoDir / " build.sbt" -> " " ,
141143 workspace / s " store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json " -> sbtScalafixVersionJson
142144 )
143145 .unsafeRunSync()
144146 val state = sbtAlg.runMigration(buildRoot, migration).runS(initialState).unsafeRunSync()
145147 val expected = initialState.copy(
146148 trace = Vector (
147149 Cmd (" test" , " -d" , s " $repoDir/project " ),
150+ Cmd (
151+ " VAR1=val1" ,
152+ " VAR2=val2" ,
153+ repoDir.pathAsString,
154+ scalafixBinary,
155+ " --syntactic" ,
156+ " --rules=github:typelevel/sbt-tpolecat/v0_5?sha=v0.5.0" ,
157+ s " $repoDir/build.sbt "
158+ ),
148159 Cmd (
149160 " read" ,
150161 s " $workspace/store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json "
@@ -178,7 +189,9 @@ class SbtAlgTest extends FunSuite {
178189 )
179190 val initialState = MockState .empty
180191 .addFiles(
181- repoDir / " project" / " Dependencies.scala" -> " object Dependencies" , // put anything at all into the meta-build
192+ repoDir / " build.sbt" -> " " ,
193+ repoDir / " project" / " plugins.sbt" -> " " ,
194+ repoDir / " project" / " Dependencies.scala" -> " object Dependencies" ,
182195 workspace / s " store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json " -> sbtScalafixVersionJson
183196 )
184197 .unsafeRunSync()
@@ -187,6 +200,17 @@ class SbtAlgTest extends FunSuite {
187200 trace = Vector (
188201 Cmd (" test" , " -d" , s " $repoDir/project " ),
189202 Cmd (" test" , " -d" , s " $repoDir/project/project " ),
203+ Cmd (
204+ " VAR1=val1" ,
205+ " VAR2=val2" ,
206+ repoDir.pathAsString,
207+ scalafixBinary,
208+ " --syntactic" ,
209+ " --rules=github:typelevel/sbt-tpolecat/v0_5?sha=v0.5.0" ,
210+ s " $repoDir/build.sbt " ,
211+ s " $repoDir/project/Dependencies.scala " ,
212+ s " $repoDir/project/plugins.sbt "
213+ ),
190214 Cmd (
191215 " read" ,
192216 s " $workspace/store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json "
@@ -210,6 +234,7 @@ class SbtAlgTest extends FunSuite {
210234 assertEquals(state, expected)
211235 }
212236
237+
213238 test(" runMigrations: build migration with scalacOptions" ) {
214239 val repo = Repo (" sbt-alg" , " test-build-migration-3" )
215240 val buildRoot = BuildRoot (repo, " ." )
@@ -224,13 +249,23 @@ class SbtAlgTest extends FunSuite {
224249 )
225250 val initialState = MockState .empty
226251 .addFiles(
252+ repoDir / " build.sbt" -> " " ,
227253 workspace / s " store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json " -> sbtScalafixVersionJson
228254 )
229255 .unsafeRunSync()
230256 val state = sbtAlg.runMigration(buildRoot, migration).runS(initialState).unsafeRunSync()
231257 val expected = initialState.copy(
232258 trace = Vector (
233259 Cmd (" test" , " -d" , s " $repoDir/project " ),
260+ Cmd (
261+ " VAR1=val1" ,
262+ " VAR2=val2" ,
263+ repoDir.pathAsString,
264+ scalafixBinary,
265+ " --syntactic" ,
266+ " --rules=github:typelevel/sbt-tpolecat/v0_5?sha=v0.5.0" ,
267+ s " $repoDir/build.sbt "
268+ ),
234269 Cmd (
235270 " read" ,
236271 s " $workspace/store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json "
@@ -267,7 +302,9 @@ class SbtAlgTest extends FunSuite {
267302 )
268303 val initialState = MockState .empty
269304 .addFiles(
270- repoDir / " project" / " Dependencies.scala" -> " object Dependencies" , // put anything at all into the meta-build
305+ repoDir / " build.sbt" -> " " ,
306+ repoDir / " project" / " plugins.sbt" -> " " ,
307+ repoDir / " project" / " Dependencies.scala" -> " object Dependencies" ,
271308 workspace / s " store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json " -> sbtScalafixVersionJson
272309 )
273310 .unsafeRunSync()
@@ -276,6 +313,17 @@ class SbtAlgTest extends FunSuite {
276313 trace = Vector (
277314 Cmd (" test" , " -d" , s " $repoDir/project " ),
278315 Cmd (" test" , " -d" , s " $repoDir/project/project " ),
316+ Cmd (
317+ " VAR1=val1" ,
318+ " VAR2=val2" ,
319+ repoDir.pathAsString,
320+ scalafixBinary,
321+ " --syntactic" ,
322+ " --rules=github:typelevel/sbt-tpolecat/v0_5?sha=v0.5.0" ,
323+ s " $repoDir/build.sbt " ,
324+ s " $repoDir/project/Dependencies.scala " ,
325+ s " $repoDir/project/plugins.sbt "
326+ ),
279327 Cmd (
280328 " read" ,
281329 s " $workspace/store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json "
0 commit comments