@@ -6,6 +6,7 @@ import org.scalasteward.core.buildtool.BuildRoot
6
6
import org .scalasteward .core .buildtool .sbt .command ._
7
7
import org .scalasteward .core .data .{GroupId , Repo , Version }
8
8
import org .scalasteward .core .edit .scalafix .ScalafixMigration
9
+ import org .scalasteward .core .edit .scalafix .ScalafixCli ._
9
10
import org .scalasteward .core .mock .MockContext .context ._
10
11
import org .scalasteward .core .mock .MockState
11
12
import org .scalasteward .core .mock .MockState .TraceEntry .Cmd
@@ -138,13 +139,23 @@ class SbtAlgTest extends FunSuite {
138
139
)
139
140
val initialState = MockState .empty
140
141
.addFiles(
142
+ repoDir / " build.sbt" -> " " ,
141
143
workspace / s " store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json " -> sbtScalafixVersionJson
142
144
)
143
145
.unsafeRunSync()
144
146
val state = sbtAlg.runMigration(buildRoot, migration).runS(initialState).unsafeRunSync()
145
147
val expected = initialState.copy(
146
148
trace = Vector (
147
149
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
+ ),
148
159
Cmd (
149
160
" read" ,
150
161
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 {
178
189
)
179
190
val initialState = MockState .empty
180
191
.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" ,
182
195
workspace / s " store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json " -> sbtScalafixVersionJson
183
196
)
184
197
.unsafeRunSync()
@@ -187,6 +200,17 @@ class SbtAlgTest extends FunSuite {
187
200
trace = Vector (
188
201
Cmd (" test" , " -d" , s " $repoDir/project " ),
189
202
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
+ ),
190
214
Cmd (
191
215
" read" ,
192
216
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 {
210
234
assertEquals(state, expected)
211
235
}
212
236
237
+
213
238
test(" runMigrations: build migration with scalacOptions" ) {
214
239
val repo = Repo (" sbt-alg" , " test-build-migration-3" )
215
240
val buildRoot = BuildRoot (repo, " ." )
@@ -224,13 +249,23 @@ class SbtAlgTest extends FunSuite {
224
249
)
225
250
val initialState = MockState .empty
226
251
.addFiles(
252
+ repoDir / " build.sbt" -> " " ,
227
253
workspace / s " store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json " -> sbtScalafixVersionJson
228
254
)
229
255
.unsafeRunSync()
230
256
val state = sbtAlg.runMigration(buildRoot, migration).runS(initialState).unsafeRunSync()
231
257
val expected = initialState.copy(
232
258
trace = Vector (
233
259
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
+ ),
234
269
Cmd (
235
270
" read" ,
236
271
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 {
267
302
)
268
303
val initialState = MockState .empty
269
304
.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" ,
271
308
workspace / s " store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json " -> sbtScalafixVersionJson
272
309
)
273
310
.unsafeRunSync()
@@ -276,6 +313,17 @@ class SbtAlgTest extends FunSuite {
276
313
trace = Vector (
277
314
Cmd (" test" , " -d" , s " $repoDir/project " ),
278
315
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
+ ),
279
327
Cmd (
280
328
" read" ,
281
329
s " $workspace/store/versions/v2/https/repo1.maven.org/maven2/ch/epfl/scala/sbt-scalafix_2.12_1.0/versions.json "
0 commit comments