@@ -17,15 +17,19 @@ abstract class PublishLocalTestDefinitions extends ScalaCliSuite with TestScalaV
17
17
private object PublishTestInputs {
18
18
def testOrg : String = " test-local-org.sth"
19
19
def testName : String = " my-proj"
20
- def projFile (message : String ): String =
20
+ def projFile (message : String , exclude : Boolean = false ): String =
21
21
s """ //> using scala $testedPublishedScalaVersion
22
- |//> using dep com.lihaoyi::os-lib:0.9.1
22
+ |//> using dep com.lihaoyi::os-lib:0.11.3 ${Some (" ,exclude=com.lihaoyi%%geny" ).filter(_ =>
23
+ exclude
24
+ ).getOrElse(" " )}
23
25
|
24
26
|object Project {
25
27
| def message = " $message"
26
28
|
27
- | def main(args: Array[String]): Unit =
29
+ | def main(args: Array[String]): Unit = {
30
+ | os.pwd
28
31
| println(message)
32
+ | }
29
33
|}
30
34
| """ .stripMargin
31
35
@@ -39,9 +43,13 @@ abstract class PublishLocalTestDefinitions extends ScalaCliSuite with TestScalaV
39
43
| """ .stripMargin
40
44
}
41
45
42
- def inputs (message : String = " Hello" , includePublishVersion : Boolean = true ): TestInputs =
46
+ def inputs (
47
+ message : String = " Hello" ,
48
+ includePublishVersion : Boolean = true ,
49
+ excludeGeny : Boolean = false
50
+ ): TestInputs =
43
51
TestInputs (
44
- os.rel / " project.scala" -> projFile(message),
52
+ os.rel / " project.scala" -> projFile(message, excludeGeny ),
45
53
os.rel / " publish-conf.scala" -> publishConfFile(includePublishVersion)
46
54
)
47
55
}
@@ -215,4 +223,39 @@ abstract class PublishLocalTestDefinitions extends ScalaCliSuite with TestScalaV
215
223
}
216
224
}
217
225
226
+ if (actualScalaVersion.startsWith(" 3" ))
227
+ test(" publish local excluding a transitive dependency" ) {
228
+ PublishTestInputs .inputs(excludeGeny = true ).fromRoot { root =>
229
+ val failPublishAsGenyIsntProvided =
230
+ os.proc(
231
+ TestUtil .cli,
232
+ " --power" ,
233
+ " publish" ,
234
+ " local" ,
235
+ " ." ,
236
+ extraOptions
237
+ )
238
+ .call(cwd = root, check = false )
239
+ expect(failPublishAsGenyIsntProvided.exitCode == 1 )
240
+ val genyDep = " com.lihaoyi::geny:1.1.1"
241
+ os.proc(
242
+ TestUtil .cli,
243
+ " --power" ,
244
+ " publish" ,
245
+ " local" ,
246
+ " ." ,
247
+ " --compile-dep" ,
248
+ genyDep,
249
+ extraOptions
250
+ )
251
+ .call(cwd = root)
252
+ val publishedDep =
253
+ s " ${PublishTestInputs .testOrg}: ${PublishTestInputs .testName}_ $testedPublishedScalaVersion: $testPublishVersion"
254
+ val failRunAsGenyIsntProvided = os.proc(TestUtil .cli, " run" , " --dep" , publishedDep)
255
+ .call(cwd = root, check = false )
256
+ expect(failRunAsGenyIsntProvided.exitCode == 1 )
257
+ os.proc(TestUtil .cli, " run" , " --dep" , publishedDep, " --dep" , genyDep).call(cwd = root)
258
+ }
259
+ }
260
+
218
261
}
0 commit comments