@@ -3,8 +3,50 @@ package mill.integration
33import mill .testkit .UtestIntegrationTestSuite
44
55import utest ._
6+ import scala .concurrent .Future
7+ import scala .concurrent .ExecutionContext
8+ import java .util .concurrent .atomic .AtomicReference
69
7- object MillPluginClasspathTest extends UtestIntegrationTestSuite {
10+ /** Trait that provides a `skip` method that can be used to skip a test, the test will pass.
11+ * Used to assert that a test still compiles, and is intended to be re-enabled later,
12+ * but is temporarily prevented from running for a suitable reason.
13+ * At the end of a suite, print a summary of the number of skipped tests, and their names.
14+ * @note I'd propose to make "skipping" a part core utest library, so that the summary includes the skipped tests
15+ */
16+ trait UTestIgnore (name : String ) extends utest.TestSuite {
17+
18+ val skipList = AtomicReference (List .empty[String ])
19+
20+ private final class SkipException (val name : String ) extends Exception with scala.util.control.NoStackTrace
21+
22+ def skip (op : => Any )(using path : utest.framework.TestPath ): Nothing = {
23+ throw new SkipException (name + " ." + path.value.mkString(" ." ))
24+ }
25+
26+ private def red (str : String ) = Console .RED + str + Console .RESET
27+
28+ override def utestWrap (path : Seq [String ], runBody : => Future [Any ])(implicit ec : ExecutionContext ): Future [Any ] = {
29+ super .utestWrap(path, runBody.recoverWith {
30+ case e : SkipException =>
31+ skipList.updateAndGet(e.name :: _)
32+ Future .successful(())
33+ })
34+ }
35+
36+ override def utestAfterAll (): Unit = {
37+ val skipped = skipList.getAndUpdate(_ => Nil ).reverse
38+ if (skipped.nonEmpty) {
39+ println(s " ${red(" !" )} Skipped tests in $name: " )
40+ skipped.foreach { s =>
41+ println(s " - $s" )
42+ }
43+ println(" Skipped: " + skipped.size)
44+ }
45+ }
46+ }
47+
48+ object MillPluginClasspathTest extends UtestIntegrationTestSuite
49+ with UTestIgnore (" mill.integration.MillPluginClasspathTest" ) {
850
951 val embeddedModules : Seq [(String , String )] = Seq (
1052 (" com.lihaoyi" , " mill-main-client" ),
@@ -30,44 +72,47 @@ object MillPluginClasspathTest extends UtestIntegrationTestSuite {
3072
3173 val tests : Tests = Tests {
3274
33- test(" exclusions" ) - integrationTest { tester =>
34- import tester ._
35- retry(3 ) {
36- val res1 = eval((" --meta-level" , " 1" , " resolveDepsExclusions" ))
37- assert(res1.isSuccess)
75+ test(" exclusions" ) - skip {
76+ integrationTest { tester =>
77+ import tester ._
78+ retry(3 ) {
79+ val res1 = eval((" --meta-level" , " 1" , " resolveDepsExclusions" ))
80+ assert(res1.isSuccess)
3881
39- val exclusions = out(" mill-build.resolveDepsExclusions" ).value[Seq [(String , String )]]
40- val expectedExclusions = embeddedModules
82+ val exclusions = out(" mill-build.resolveDepsExclusions" ).value[Seq [(String , String )]]
83+ val expectedExclusions = embeddedModules
4184
42- val diff = expectedExclusions.toSet.diff(exclusions.toSet)
43- assert(diff.isEmpty)
85+ val diff = expectedExclusions.toSet.diff(exclusions.toSet)
86+ assert(diff.isEmpty)
87+ }
4488 }
4589 }
46- test(" runClasspath" ) - integrationTest { tester =>
47- import tester ._
48- retry(3 ) {
49- // We expect Mill core transitive dependencies to be filtered out
50- val res1 = eval((" --meta-level" , " 1" , " runClasspath" ))
51- assert(res1.isSuccess)
90+ test(" runClasspath" ) - skip {
91+ integrationTest { tester =>
92+ import tester ._
93+ retry(3 ) {
94+ // We expect Mill core transitive dependencies to be filtered out
95+ val res1 = eval((" --meta-level" , " 1" , " runClasspath" ))
96+ assert(res1.isSuccess)
5297
53- val runClasspath = out(" mill-build.runClasspath" ).value[Seq [String ]]
98+ val runClasspath = out(" mill-build.runClasspath" ).value[Seq [String ]]
5499
55- val unexpectedArtifacts = embeddedModules.map {
56- case (o, n) => s " ${o.replaceAll(" [.]" , " /" )}/ ${n}"
57- }
100+ val unexpectedArtifacts = embeddedModules.map {
101+ case (o, n) => s " ${o.replaceAll(" [.]" , " /" )}/ ${n}"
102+ }
58103
59- val unexpected = unexpectedArtifacts.flatMap { a =>
60- runClasspath.find(p => p.toString.contains(a)).map((a, _))
61- }.toMap
62- assert(unexpected.isEmpty)
104+ val unexpected = unexpectedArtifacts.flatMap { a =>
105+ runClasspath.find(p => p.toString.contains(a)).map((a, _))
106+ }.toMap
107+ assert(unexpected.isEmpty)
63108
64- val expected =
65- Seq (" com/disneystreaming/smithy4s/smithy4s-mill-codegen-plugin_mill0.11_2.13" )
66- assert(expected.forall(a =>
67- runClasspath.exists(p => p.toString().replace('\\ ' , '/' ).contains(a))
68- ))
109+ val expected =
110+ Seq (" com/disneystreaming/smithy4s/smithy4s-mill-codegen-plugin_mill0.11_2.13" )
111+ assert(expected.forall(a =>
112+ runClasspath.exists(p => p.toString().replace('\\ ' , '/' ).contains(a))
113+ ))
114+ }
69115 }
70116 }
71-
72117 }
73118}
0 commit comments