blob: 783616255e5762459346a66e5748b03fd97847e3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
package mill.scalalib
import coursier.Cache
import coursier.maven.MavenRepository
import mill.api.Result.{Failure, Success}
import mill.eval.{PathRef, Result}
import mill.util.Loose.Agg
import utest._
object ResolveDepsTests extends TestSuite {
val repos = Seq(Cache.ivy2Local, MavenRepository("https://repo1.maven.org/maven2"))
def evalDeps(deps: Agg[Dep]): Result[Agg[PathRef]] = Lib.resolveDependencies(
repos,
Lib.depToDependency(_, "2.12.4", ""),
deps
)
val tests = Tests {
'resolveValidDeps - {
val deps = Agg(ivy"com.lihaoyi::pprint:0.5.3")
val Success(paths) = evalDeps(deps)
assert(paths.nonEmpty)
}
'resolveValidDepsWithClassifier - {
val deps = Agg(ivy"org.lwjgl:lwjgl:3.1.1;classifier=natives-macos")
val Success(paths) = evalDeps(deps)
assert(paths.nonEmpty)
assert(paths.items.next.path.toString.contains("natives-macos"))
}
'resolveTransitiveRuntimeDeps - {
val deps = Agg(ivy"org.mockito:mockito-core:2.7.22")
val Success(paths) = evalDeps(deps)
assert(paths.nonEmpty)
assert(paths.exists(_.path.toString.contains("objenesis")))
assert(paths.exists(_.path.toString.contains("byte-buddy")))
}
'excludeTransitiveDeps - {
val deps = Agg(ivy"com.lihaoyi::pprint:0.5.3".exclude("com.lihaoyi" -> "fansi_2.12"))
val Success(paths) = evalDeps(deps)
assert(!paths.exists(_.path.toString.contains("fansi_2.12")))
}
'excludeTransitiveDepsByOrg - {
val deps = Agg(ivy"com.lihaoyi::pprint:0.5.3".excludeOrg("com.lihaoyi"))
val Success(paths) = evalDeps(deps)
assert(!paths.exists(path => path.path.toString.contains("com/lihaoyi") && !path.path.toString.contains("pprint_2.12")))
}
'excludeTransitiveDepsByName - {
val deps = Agg(ivy"com.lihaoyi::pprint:0.5.3".excludeName("fansi_2.12"))
val Success(paths) = evalDeps(deps)
assert(!paths.exists(_.path.toString.contains("fansi_2.12")))
}
'errOnInvalidOrgDeps - {
val deps = Agg(ivy"xxx.yyy.invalid::pprint:0.5.3")
val Failure(errMsg, _) = evalDeps(deps)
assert(errMsg.contains("xxx.yyy.invalid"))
}
'errOnInvalidVersionDeps - {
val deps = Agg(ivy"com.lihaoyi::pprint:invalid.version.num")
val Failure(errMsg, _) = evalDeps(deps)
assert(errMsg.contains("invalid.version.num"))
}
'errOnPartialSuccess - {
val deps = Agg(ivy"com.lihaoyi::pprint:0.5.3", ivy"fake::fake:fake")
val Failure(errMsg, _) = evalDeps(deps)
assert(errMsg.contains("fake"))
}
}
}
|