Skip to content

Commit 7343e23

Browse files
authored
Merge pull request #5949 from dotty-staging/update-community-build-command
Add updateCommunityBuild command
2 parents b885862 + ae54285 commit 7343e23

File tree

2 files changed

+63
-30
lines changed

2 files changed

+63
-30
lines changed

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

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import java.io.{PrintWriter, File}
55
import java.nio.charset.StandardCharsets.UTF_8
66
import org.junit.{Ignore, Test}
77
import org.junit.Assert.{assertEquals, fail}
8+
import org.junit.experimental.categories.Category
89

10+
@Category(Array(classOf[TestCategory]))
911
class CommunityBuildTest {
1012
lazy val communitybuildDir: Path = Paths.get(sys.props("user.dir") + "/community-build/")
1113

@@ -19,10 +21,11 @@ class CommunityBuildTest {
1921
* This test reads the compiler version from community-build/dotty-bootstrapped.version
2022
* and expects community-build/sbt-dotty-sbt to set the compiler plugin.
2123
*
22-
* @param project The project name, should be a git submodule in community-build/
23-
* @param command The sbt command used to build the project
24+
* @param project The project name, should be a git submodule in community-build/
25+
* @param command The sbt command used to test the project
26+
* @param updateCommand The sbt command used to update the project
2427
*/
25-
def test(project: String, command: String): Unit = {
28+
def test(project: String, testCommand: String, updateCommand: String): Unit = {
2629
def log(msg: String) = println(Console.GREEN + msg + Console.RESET)
2730

2831
log(s"Building $project with dotty-bootstrapped $compilerVersion...")
@@ -57,7 +60,7 @@ class CommunityBuildTest {
5760
val arguments = Seq(
5861
"-sbt-version", "1.2.7",
5962
s"--addPluginSbtFile=$pluginFilePath",
60-
s";clean ;set updateOptions in Global ~= (_.withLatestSnapshots(false)) ;++$compilerVersion! $command"
63+
s";clean ;set updateOptions in Global ~= (_.withLatestSnapshots(false)) ;++$compilerVersion! $testCommand"
6164
)
6265

6366
val exitCode = exec("sbt", arguments: _*)
@@ -80,69 +83,91 @@ class CommunityBuildTest {
8083
}
8184

8285
@Test def algebra = test(
83-
project = "algebra",
84-
command = "coreJVM/compile"
86+
project = "algebra",
87+
testCommand = "coreJVM/compile",
88+
updateCommand = "coreJVM/update"
8589
)
8690

8791
@Test def scalacheck = test(
88-
project = "scalacheck",
89-
command = "jvm/test:compile"
92+
project = "scalacheck",
93+
testCommand = "jvm/test:compile",
94+
updateCommand = "jvm/test:update"
9095
)
9196

9297
@Test def scalatest = test(
93-
project = "scalatest",
94-
command = "scalatest/compile"
98+
project = "scalatest",
99+
testCommand = "scalatest/compile",
100+
updateCommand = "scalatest/update"
95101
)
96102

97103
@Test def scopt = test(
98-
project = "scopt",
99-
command = "scoptJVM/compile"
104+
project = "scopt",
105+
testCommand = "scoptJVM/compile",
106+
updateCommand = "scoptJVM/update"
100107
)
101108

102109
@Test def scalap = test(
103-
project = "scalap",
104-
command = "scalap/compile"
110+
project = "scalap",
111+
testCommand = "scalap/compile",
112+
updateCommand = "scalap/update"
105113
)
106114

107115
@Test def squants = test(
108-
project = "squants",
109-
command = "squantsJVM/compile"
116+
project = "squants",
117+
testCommand = "squantsJVM/compile",
118+
updateCommand = "squantsJVM/update"
110119
)
111120

112121
@Test def betterfiles = test(
113-
project = "betterfiles",
114-
command = "dotty-community-build/compile"
122+
project = "betterfiles",
123+
testCommand = "dotty-community-build/compile",
124+
updateCommand = "dotty-community-build/update"
115125
)
116126

117127
@Test def ScalaPB = test(
118-
project = "ScalaPB",
119-
command = "dotty-community-build/compile"
128+
project = "ScalaPB",
129+
testCommand = "dotty-community-build/compile",
130+
updateCommand = "dotty-community-build/update"
120131
)
121132

122133
@Test def minitest = test(
123-
project = "minitest",
124-
command = "dotty-community-build/compile"
134+
project = "minitest",
135+
testCommand = "dotty-community-build/compile",
136+
updateCommand = "dotty-community-build/update"
125137
)
126138

127139
@Test def fastparse = test(
128-
project = "fastparse",
129-
command = "fastparseJVM/compile"
140+
project = "fastparse",
141+
testCommand = "fastparseJVM/compile",
142+
updateCommand = "fastparseJVM/update"
130143
)
131144

132145
// TODO: revert to sourcecodeJVM/test
133146
@Test def sourcecode = test(
134-
project = "sourcecode",
135-
command = "sourcecodeJVM/compile"
147+
project = "sourcecode",
148+
testCommand = "sourcecodeJVM/compile",
149+
updateCommand = "sourcecodeJVM/update"
136150
)
137151

138152
@Test def stdLib213 = test(
139-
project = "stdLib213",
140-
command = "library/compile"
153+
project = "stdLib213",
154+
testCommand = "library/compile",
155+
updateCommand = "library/update"
141156
)
142157

143158
// TODO @oderky? It got broken by #5458
144159
// @Test def pdbp = test(
145-
// project = "pdbp",
146-
// command = "compile"
160+
// project = "pdbp",
161+
// testCommand = "compile",
162+
// updateCommand = "update"
147163
// )
148164
}
165+
166+
class TestCategory
167+
class UpdateCategory
168+
169+
@Category(Array(classOf[UpdateCategory]))
170+
class CommunityBuildUpdate extends CommunityBuildTest {
171+
override def test(project: String, testCommand: String, updateCommand: String): Unit =
172+
super.test(project, updateCommand, null)
173+
}

project/Build.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,8 @@ object Build {
903903

904904
val prepareCommunityBuild = taskKey[Unit]("Publish local the compiler and the sbt plugin. Also store the versions of the published local artefacts in two files, community-build/{dotty-bootstrapped.version,sbt-dotty-sbt}.")
905905

906+
val updateCommunityBuild = taskKey[Unit]("Updates the community build.")
907+
906908
lazy val `community-build` = project.in(file("community-build")).
907909
settings(commonNonBootstrappedSettings).
908910
settings(
@@ -920,6 +922,12 @@ object Build {
920922
IO.write(baseDirectory.value / "sbt-dotty-sbt", pluginText)
921923
IO.write(baseDirectory.value / "dotty-bootstrapped.version", dottyVersion)
922924
},
925+
updateCommunityBuild := testOnly.in(Test).toTask(
926+
" dotty.communitybuild.CommunityBuildUpdate -- --include-categories=dotty.communitybuild.UpdateCategory").value,
927+
testOptions in Test += Tests.Argument(
928+
TestFrameworks.JUnit,
929+
"--include-categories=dotty.communitybuild.TestCategory",
930+
),
923931
(Test / testOnly) := ((Test / testOnly) dependsOn prepareCommunityBuild).evaluated,
924932
(Test / test ) := ((Test / test ) dependsOn prepareCommunityBuild).value
925933
)

0 commit comments

Comments
 (0)