@@ -8,14 +8,26 @@ import org.junit.Assert.{assertEquals, fail}
88import org .junit .experimental .categories .Category
99
1010@ Category (Array (classOf [TestCategory ]))
11- class CommunityBuildTest {
11+ class CommunityBuildTest { suite =>
1212 lazy val communitybuildDir : Path = Paths .get(sys.props(" user.dir" ))
1313
1414 lazy val compilerVersion : String = {
1515 val file = communitybuildDir.resolve(" dotty-bootstrapped.version" )
1616 new String (Files .readAllBytes(file), UTF_8 )
1717 }
1818
19+ def log (msg : String ) = println(Console .GREEN + msg + Console .RESET )
20+
21+ /** Executes shell command, returns false in case of error. */
22+ def exec (projectDir : Path , binary : String , arguments : String * ): Int = {
23+ val command = binary +: arguments
24+ log(command.mkString(" " ))
25+ val builder = new ProcessBuilder (command : _* ).directory(projectDir.toFile).inheritIO()
26+ val process = builder.start()
27+ val exitCode = process.waitFor()
28+ exitCode
29+ }
30+
1931 def testSbt (project : String , testCommand : String , updateCommand : String , extraSbtArgs : Seq [String ] = Nil ) = {
2032 // Workaround for https://github.com/sbt/sbt/issues/4395
2133 new File (sys.props(" user.home" ) + " /.sbt/1.0/plugins" ).mkdirs()
@@ -39,9 +51,6 @@ class CommunityBuildTest {
3951 test(project, " sbt" , arguments)
4052 }
4153
42- def testMill (project : String , testCommand : String , extraMillArgs : Seq [String ] = Nil ) =
43- test(project, " ./mill" , extraMillArgs :+ testCommand)
44-
4554 /** Build the given project with the published local compiler and sbt plugin.
4655 *
4756 * This test reads the compiler version from community-build/dotty-bootstrapped.version
@@ -53,8 +62,6 @@ class CommunityBuildTest {
5362 * @param extraSbtArgs Extra arguments to pass to sbt
5463 */
5564 def test (project : String , command : String , arguments : Seq [String ]): Unit = {
56- def log (msg : String ) = println(Console .GREEN + msg + Console .RESET )
57-
5865 log(s " Building $project with dotty-bootstrapped $compilerVersion... " )
5966
6067 val projectDir = communitybuildDir.resolve(" community-projects" ).resolve(project)
@@ -69,17 +76,7 @@ class CommunityBuildTest {
6976 | """ .stripMargin)
7077 }
7178
72- /** Executes shell command, returns false in case of error. */
73- def exec (binary : String , arguments : String * ): Int = {
74- val command = binary +: arguments
75- log(command.mkString(" " ))
76- val builder = new ProcessBuilder (command : _* ).directory(projectDir.toFile).inheritIO()
77- val process = builder.start()
78- val exitCode = process.waitFor()
79- exitCode
80- }
81-
82- val exitCode = exec(command, arguments : _* )
79+ val exitCode = exec(projectDir, command, arguments : _* )
8380
8481 if (exitCode != 0 ) {
8582 fail(s """
@@ -98,23 +95,49 @@ class CommunityBuildTest {
9895 }
9996 }
10097
101- @ Test def utest = testMill(
102- project = " utest" ,
103- testCommand = s " utest.jvm[ $compilerVersion].test " ,
104- extraMillArgs = List (" -i" , " -D" , s " dottyVersion= $compilerVersion" )
105- )
106-
107- @ Test def oslib = testMill(
108- project = " os-lib" ,
109- testCommand = s " os[ $compilerVersion].test " ,
110- extraMillArgs = List (" -i" , " -D" , s " dottyVersion= $compilerVersion" )
111- )
112-
113- @ Test def oslibWatch = testMill(
114- project = " os-lib" ,
115- testCommand = s " os.watch[ $compilerVersion].test " ,
116- extraMillArgs = List (" -i" , " -D" , s " dottyVersion= $compilerVersion" )
117- )
98+ case class MillCommunityProject (project : String , testCommand : String ,
99+ publishCommand : String = " " , extraArgs : List [String ] = Nil ,
100+ dependencies : List [MillCommunityProject ] = Nil )
101+ final def test () =
102+ dependencies.foreach(_.publish())
103+ suite.test(project, " ./mill" , extraArgs :+ testCommand)
104+
105+ final def publish () =
106+ log(s " Publishing $project" )
107+ val projectDir = communitybuildDir.resolve(" community-projects" ).resolve(project)
108+ if publishCommand.isEmpty
109+ throw RuntimeException (s " Missing publish command for project $this" )
110+ exec(projectDir, " ./mill" , (extraArgs :+ publishCommand): _* )
111+
112+ object projects {
113+ val utest = MillCommunityProject (
114+ project = " utest" ,
115+ testCommand = s " utest.jvm[ $compilerVersion].test " ,
116+ publishCommand = s " utest.jvm[ $compilerVersion].publishLocal " ,
117+ extraArgs = List (" -i" , " -D" , s " dottyVersion= $compilerVersion" )
118+ )
119+
120+ val sourcecode = MillCommunityProject (
121+ project = " sourcecode" ,
122+ testCommand = s " sourcecode.jvm[ $compilerVersion].test " ,
123+ publishCommand = s " sourcecode.jvm[ $compilerVersion].publishLocal " ,
124+ extraArgs = List (" -i" , " -D" , s " dottyVersion= $compilerVersion" ),
125+ )
126+
127+ val oslib = MillCommunityProject (
128+ project = " os-lib" ,
129+ testCommand = s " os[ $compilerVersion].test " ,
130+ extraArgs = List (" -i" , " -D" , s " dottyVersion= $compilerVersion" ),
131+ dependencies = List (utest, sourcecode)
132+ )
133+
134+ val oslibWatch = MillCommunityProject (
135+ project = " os-lib" ,
136+ testCommand = s " os.watch[ $compilerVersion].test " ,
137+ extraArgs = List (" -i" , " -D" , s " dottyVersion= $compilerVersion" ),
138+ dependencies = List (utest, sourcecode)
139+ )
140+ }
118141
119142 @ Test def intent = testSbt(
120143 project = " intent" ,
@@ -188,11 +211,13 @@ class CommunityBuildTest {
188211 updateCommand = " dotty-community-build/update"
189212 )
190213
191- @ Test def sourcecode = testMill(
192- project = " sourcecode" ,
193- testCommand = s " sourcecode.jvm[ $compilerVersion].test " ,
194- extraMillArgs = List (" -i" , " -D" , s " dottyVersion= $compilerVersion" )
195- )
214+ @ Test def utest = projects.utest.test()
215+
216+ @ Test def sourcecode = projects.sourcecode.test()
217+
218+ @ Test def oslib = projects.oslib.test()
219+
220+ @ Test def oslibWatch = projects.oslibWatch.test()
196221
197222 @ Test def stdLib213 = testSbt(
198223 project = " stdLib213" ,
0 commit comments