Skip to content

Commit 88500ff

Browse files
Merge pull request #7522 from dotty-staging/utest-community
Add utest to the community build
2 parents 123716a + f85c510 commit 88500ff

File tree

4 files changed

+62
-44
lines changed

4 files changed

+62
-44
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@
5656
[submodule "community-build/community-projects/intent"]
5757
path = community-build/community-projects/intent
5858
url = https://github.com/dotty-staging/intent
59+
[submodule "community-build/community-projects/utest"]
60+
path = community-build/community-projects/utest
61+
url = https://github.com/dotty-staging/utest.git
Submodule utest added at 0fe508a

community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@ class CommunityBuildTest {
1616
new String(Files.readAllBytes(file), UTF_8)
1717
}
1818

19+
def testSbt(project: String, testCommand: String, updateCommand: String, extraSbtArgs: Seq[String] = Nil) = {
20+
// Workaround for https://github.com/sbt/sbt/issues/4395
21+
new File(sys.props("user.home") + "/.sbt/1.0/plugins").mkdirs()
22+
val pluginFilePath = communitybuildDir.resolve("sbt-dotty-sbt").toAbsolutePath().toString()
23+
24+
// Run the sbt command with the compiler version and sbt plugin set in the build
25+
val arguments = {
26+
val sbtProps = Option(System.getProperty("sbt.ivy.home")) match {
27+
case Some(ivyHome) =>
28+
Seq(s"-Dsbt.ivy.home=$ivyHome")
29+
case _ =>
30+
Seq()
31+
}
32+
extraSbtArgs ++ sbtProps ++ Seq(
33+
"-sbt-version", "1.2.7",
34+
s"--addPluginSbtFile=$pluginFilePath",
35+
s";clean ;set updateOptions in Global ~= (_.withLatestSnapshots(false)) ;++$compilerVersion! $testCommand"
36+
)
37+
}
38+
39+
test(project, "sbt", arguments)
40+
}
41+
42+
def testMill(project: String, testCommand: String, extraMillArgs: Seq[String] = Nil) =
43+
test(project, "./mill", extraMillArgs :+ testCommand)
44+
1945
/** Build the given project with the published local compiler and sbt plugin.
2046
*
2147
* This test reads the compiler version from community-build/dotty-bootstrapped.version
@@ -26,7 +52,7 @@ class CommunityBuildTest {
2652
* @param updateCommand The sbt command used to update the project
2753
* @param extraSbtArgs Extra arguments to pass to sbt
2854
*/
29-
def test(project: String, testCommand: String, updateCommand: String, extraSbtArgs: Seq[String] = Nil): Unit = {
55+
def test(project: String, command: String, arguments: Seq[String]): Unit = {
3056
def log(msg: String) = println(Console.GREEN + msg + Console.RESET)
3157

3258
log(s"Building $project with dotty-bootstrapped $compilerVersion...")
@@ -53,149 +79,136 @@ class CommunityBuildTest {
5379
exitCode
5480
}
5581

56-
// Workaround for https://github.com/sbt/sbt/issues/4395
57-
new File(sys.props("user.home") + "/.sbt/1.0/plugins").mkdirs()
58-
val pluginFilePath = communitybuildDir.resolve("sbt-dotty-sbt").toAbsolutePath().toString()
59-
60-
// Run the sbt command with the compiler version and sbt plugin set in the build
61-
val arguments = {
62-
val sbtProps = Option(System.getProperty("sbt.ivy.home")) match {
63-
case Some(ivyHome) =>
64-
Seq(s"-Dsbt.ivy.home=$ivyHome")
65-
case _ =>
66-
Seq()
67-
}
68-
extraSbtArgs ++ sbtProps ++ Seq(
69-
"-sbt-version", "1.2.7",
70-
s"--addPluginSbtFile=$pluginFilePath",
71-
s";clean ;set updateOptions in Global ~= (_.withLatestSnapshots(false)) ;++$compilerVersion! $testCommand"
72-
)
73-
}
74-
75-
val exitCode = exec("sbt", arguments: _*)
82+
val exitCode = exec(command, arguments: _*)
7683

7784
if (exitCode != 0) {
7885
fail(s"""
7986
|
80-
|sbt exited with an error code. To reproduce without JUnit, use:
87+
|$command exited with an error code. To reproduce without JUnit, use:
8188
|
8289
| sbt community-build/prepareCommunityBuild
8390
| cd community-build/community-projects/$project
84-
| sbt ${arguments.init.mkString(" ")} "${arguments.last}"
91+
| $command ${arguments.init.mkString(" ")} "${arguments.last}"
8592
|
86-
|For a faster feedback loop, one can try to extract a direct call to dotc
93+
|For a faster feedback loop on SBT projects, one can try to extract a direct call to dotc
8794
|using the sbt export command. For instance, for scalacheck, use
8895
| sbt export jvm/test:compileIncremental
8996
|
9097
|""".stripMargin)
9198
}
9299
}
93100

94-
@Test def intent = test(
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 intent = testSbt(
95108
project = "intent",
96109
testCommand = "test",
97110
updateCommand = "update"
98111
)
99112

100-
@Test def algebra = test(
113+
@Test def algebra = testSbt(
101114
project = "algebra",
102115
testCommand = "coreJVM/compile",
103116
updateCommand = "coreJVM/update"
104117
)
105118

106-
@Test def scalacheck = test(
119+
@Test def scalacheck = testSbt(
107120
project = "scalacheck",
108121
testCommand = "jvm/test:compile",
109122
updateCommand = "jvm/test:update"
110123
)
111124

112-
@Test def scalatest = test(
125+
@Test def scalatest = testSbt(
113126
project = "scalatest",
114127
testCommand = ";scalacticDotty/clean;scalacticTestDotty/test;scalatestTestDotty/test",
115128
updateCommand = "scalatest/update"
116129
)
117130

118-
@Test def scalaXml = test(
131+
@Test def scalaXml = testSbt(
119132
project = "scala-xml",
120133
testCommand = "xml/test",
121134
updateCommand = "xml/update"
122135
)
123136

124-
@Test def scopt = test(
137+
@Test def scopt = testSbt(
125138
project = "scopt",
126139
testCommand = "scoptJVM/compile",
127140
updateCommand = "scoptJVM/update"
128141
)
129142

130-
@Test def scalap = test(
143+
@Test def scalap = testSbt(
131144
project = "scalap",
132145
testCommand = "scalap/compile",
133146
updateCommand = "scalap/update"
134147
)
135148

136-
@Test def squants = test(
149+
@Test def squants = testSbt(
137150
project = "squants",
138151
testCommand = "squantsJVM/compile",
139152
updateCommand = "squantsJVM/update"
140153
)
141154

142-
@Test def betterfiles = test(
155+
@Test def betterfiles = testSbt(
143156
project = "betterfiles",
144157
testCommand = "dotty-community-build/compile",
145158
updateCommand = "dotty-community-build/update"
146159
)
147160

148-
@Test def ScalaPB = test(
161+
@Test def ScalaPB = testSbt(
149162
project = "ScalaPB",
150163
testCommand = "dotty-community-build/compile",
151164
updateCommand = "dotty-community-build/update"
152165
)
153166

154-
@Test def minitest = test(
167+
@Test def minitest = testSbt(
155168
project = "minitest",
156169
testCommand = "dotty-community-build/compile",
157170
updateCommand = "dotty-community-build/update"
158171
)
159172

160-
@Test def fastparse = test(
173+
@Test def fastparse = testSbt(
161174
project = "fastparse",
162175
testCommand = "dotty-community-build/compile;dotty-community-build/test:compile",
163176
updateCommand = "dotty-community-build/update"
164177
)
165178

166179
// TODO: revert to sourcecodeJVM/test
167-
@Test def sourcecode = test(
180+
@Test def sourcecode = testSbt(
168181
project = "sourcecode",
169182
testCommand = "sourcecode/compile;sourcecode/test:compile",
170183
updateCommand = "sourcecode/update"
171184
)
172185

173-
@Test def stdLib213 = test(
186+
@Test def stdLib213 = testSbt(
174187
project = "stdLib213",
175188
testCommand = "library/compile",
176189
updateCommand = "library/update",
177190
extraSbtArgs = Seq("-Dscala.build.compileWithDotty=true")
178191
)
179192

180-
@Test def shapeless = test(
193+
@Test def shapeless = testSbt(
181194
project = "shapeless",
182195
testCommand = "test",
183196
updateCommand = "update"
184197
)
185198

186-
@Test def xmlInterpolator = test(
199+
@Test def xmlInterpolator = testSbt(
187200
project = "xml-interpolator",
188201
testCommand = "test",
189202
updateCommand = "update"
190203
)
191204

192-
@Test def semanticdb = test(
205+
@Test def semanticdb = testSbt(
193206
project = "semanticdb",
194207
testCommand = "test:compile",
195208
updateCommand = "update"
196209
)
197210

198-
@Test def effpi = test(
211+
@Test def effpi = testSbt(
199212
project = "effpi",
200213
// We set `useEffpiPlugin := false` because we don't want to run their
201214
// compiler plugin since it relies on external binaries (from the model
@@ -225,6 +238,6 @@ class UpdateCategory
225238

226239
@Category(Array(classOf[UpdateCategory]))
227240
class CommunityBuildUpdate extends CommunityBuildTest {
228-
override def test(project: String, testCommand: String, updateCommand: String, extraSbtArgs: Seq[String]): Unit =
229-
super.test(project, updateCommand, null, extraSbtArgs)
241+
override def testSbt(project: String, testCommand: String, updateCommand: String, extraSbtArgs: Seq[String]): Unit =
242+
super.testSbt(project, updateCommand, null, extraSbtArgs)
230243
}

project/Build.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,7 @@ object Build {
11301130
(publishLocal in `dotty-compiler-bootstrapped`).value
11311131
(publishLocal in `sbt-dotty`).value
11321132
(publishLocal in `dotty-bootstrapped`).value
1133+
// (publishLocal in `dotty-staging`).value
11331134
val pluginText =
11341135
s"""updateOptions in Global ~= (_.withLatestSnapshots(false))
11351136
|addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "$sbtDottyVersion")""".stripMargin

0 commit comments

Comments
 (0)