@@ -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 "
@@ -224,13 +248,23 @@ class SbtAlgTest extends FunSuite {
224248 )
225249 val initialState = MockState .empty
226250 .addFiles(
251+ repoDir / " build.sbt" -> " " ,
227252 workspace / s " store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json " -> sbtScalafixVersionJson
228253 )
229254 .unsafeRunSync()
230255 val state = sbtAlg.runMigration(buildRoot, migration).runS(initialState).unsafeRunSync()
231256 val expected = initialState.copy(
232257 trace = Vector (
233258 Cmd (" test" , " -d" , s " $repoDir/project " ),
259+ Cmd (
260+ " VAR1=val1" ,
261+ " VAR2=val2" ,
262+ repoDir.pathAsString,
263+ scalafixBinary,
264+ " --syntactic" ,
265+ " --rules=github:typelevel/sbt-tpolecat/v0_5?sha=v0.5.0" ,
266+ s " $repoDir/build.sbt "
267+ ),
234268 Cmd (
235269 " read" ,
236270 s " $workspace/store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json "
@@ -267,7 +301,9 @@ class SbtAlgTest extends FunSuite {
267301 )
268302 val initialState = MockState .empty
269303 .addFiles(
270- repoDir / " project" / " Dependencies.scala" -> " object Dependencies" , // put anything at all into the meta-build
304+ repoDir / " build.sbt" -> " " ,
305+ repoDir / " project" / " plugins.sbt" -> " " ,
306+ repoDir / " project" / " Dependencies.scala" -> " object Dependencies" ,
271307 workspace / s " store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json " -> sbtScalafixVersionJson
272308 )
273309 .unsafeRunSync()
@@ -276,6 +312,17 @@ class SbtAlgTest extends FunSuite {
276312 trace = Vector (
277313 Cmd (" test" , " -d" , s " $repoDir/project " ),
278314 Cmd (" test" , " -d" , s " $repoDir/project/project " ),
315+ Cmd (
316+ " VAR1=val1" ,
317+ " VAR2=val2" ,
318+ repoDir.pathAsString,
319+ scalafixBinary,
320+ " --syntactic" ,
321+ " --rules=github:typelevel/sbt-tpolecat/v0_5?sha=v0.5.0" ,
322+ s " $repoDir/build.sbt " ,
323+ s " $repoDir/project/Dependencies.scala " ,
324+ s " $repoDir/project/plugins.sbt "
325+ ),
279326 Cmd (
280327 " read" ,
281328 s " $workspace/store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json "
0 commit comments