@@ -16,6 +16,29 @@ class CommunityBuildTest {
16
16
new String (Files .readAllBytes(file), UTF_8 )
17
17
}
18
18
19
+ def testSbt (project : String , testCommand : String , updateCommand : String , extraSbtArgs : Seq [String ] = Nil ) = test(project) {
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
+ (" sbt" , arguments)
40
+ }
41
+
19
42
/** Build the given project with the published local compiler and sbt plugin.
20
43
*
21
44
* This test reads the compiler version from community-build/dotty-bootstrapped.version
@@ -26,7 +49,7 @@ class CommunityBuildTest {
26
49
* @param updateCommand The sbt command used to update the project
27
50
* @param extraSbtArgs Extra arguments to pass to sbt
28
51
*/
29
- def test (project : String , testCommand : String , updateCommand : String , extraSbtArgs : Seq [String ] = Nil ): Unit = {
52
+ def test (project : String )( commandAndArgs : => ( String , Seq [String ]) ): Unit = {
30
53
def log (msg : String ) = println(Console .GREEN + msg + Console .RESET )
31
54
32
55
log(s " Building $project with dotty-bootstrapped $compilerVersion... " )
@@ -53,149 +76,131 @@ class CommunityBuildTest {
53
76
exitCode
54
77
}
55
78
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 : _* )
79
+ val (command, arguments) = commandAndArgs
80
+ val exitCode = exec(command, arguments : _* )
76
81
77
82
if (exitCode != 0 ) {
78
83
fail(s """
79
84
|
80
- |sbt exited with an error code. To reproduce without JUnit, use:
85
+ | $command exited with an error code. To reproduce without JUnit, use:
81
86
|
82
87
| sbt community-build/prepareCommunityBuild
83
88
| cd community-build/community-projects/ $project
84
- | sbt ${arguments.init.mkString(" " )} " ${arguments.last}"
89
+ | $command ${arguments.init.mkString(" " )} " ${arguments.last}"
85
90
|
86
- |For a faster feedback loop, one can try to extract a direct call to dotc
91
+ |For a faster feedback loop on SBT projects , one can try to extract a direct call to dotc
87
92
|using the sbt export command. For instance, for scalacheck, use
88
93
| sbt export jvm/test:compileIncremental
89
94
|
90
95
| """ .stripMargin)
91
96
}
92
97
}
93
98
94
- @ Test def intent = test (
99
+ @ Test def intent = testSbt (
95
100
project = " intent" ,
96
101
testCommand = " test" ,
97
102
updateCommand = " update"
98
103
)
99
104
100
- @ Test def algebra = test (
105
+ @ Test def algebra = testSbt (
101
106
project = " algebra" ,
102
107
testCommand = " coreJVM/compile" ,
103
108
updateCommand = " coreJVM/update"
104
109
)
105
110
106
- @ Test def scalacheck = test (
111
+ @ Test def scalacheck = testSbt (
107
112
project = " scalacheck" ,
108
113
testCommand = " jvm/test:compile" ,
109
114
updateCommand = " jvm/test:update"
110
115
)
111
116
112
- @ Test def scalatest = test (
117
+ @ Test def scalatest = testSbt (
113
118
project = " scalatest" ,
114
119
testCommand = " ;scalacticDotty/clean;scalacticTestDotty/test;scalatestTestDotty/test" ,
115
120
updateCommand = " scalatest/update"
116
121
)
117
122
118
- @ Test def scalaXml = test (
123
+ @ Test def scalaXml = testSbt (
119
124
project = " scala-xml" ,
120
125
testCommand = " xml/test" ,
121
126
updateCommand = " xml/update"
122
127
)
123
128
124
- @ Test def scopt = test (
129
+ @ Test def scopt = testSbt (
125
130
project = " scopt" ,
126
131
testCommand = " scoptJVM/compile" ,
127
132
updateCommand = " scoptJVM/update"
128
133
)
129
134
130
- @ Test def scalap = test (
135
+ @ Test def scalap = testSbt (
131
136
project = " scalap" ,
132
137
testCommand = " scalap/compile" ,
133
138
updateCommand = " scalap/update"
134
139
)
135
140
136
- @ Test def squants = test (
141
+ @ Test def squants = testSbt (
137
142
project = " squants" ,
138
143
testCommand = " squantsJVM/compile" ,
139
144
updateCommand = " squantsJVM/update"
140
145
)
141
146
142
- @ Test def betterfiles = test (
147
+ @ Test def betterfiles = testSbt (
143
148
project = " betterfiles" ,
144
149
testCommand = " dotty-community-build/compile" ,
145
150
updateCommand = " dotty-community-build/update"
146
151
)
147
152
148
- @ Test def ScalaPB = test (
153
+ @ Test def ScalaPB = testSbt (
149
154
project = " ScalaPB" ,
150
155
testCommand = " dotty-community-build/compile" ,
151
156
updateCommand = " dotty-community-build/update"
152
157
)
153
158
154
- @ Test def minitest = test (
159
+ @ Test def minitest = testSbt (
155
160
project = " minitest" ,
156
161
testCommand = " dotty-community-build/compile" ,
157
162
updateCommand = " dotty-community-build/update"
158
163
)
159
164
160
- @ Test def fastparse = test (
165
+ @ Test def fastparse = testSbt (
161
166
project = " fastparse" ,
162
167
testCommand = " dotty-community-build/compile;dotty-community-build/test:compile" ,
163
168
updateCommand = " dotty-community-build/update"
164
169
)
165
170
166
171
// TODO: revert to sourcecodeJVM/test
167
- @ Test def sourcecode = test (
172
+ @ Test def sourcecode = testSbt (
168
173
project = " sourcecode" ,
169
174
testCommand = " sourcecode/compile;sourcecode/test:compile" ,
170
175
updateCommand = " sourcecode/update"
171
176
)
172
177
173
- @ Test def stdLib213 = test (
178
+ @ Test def stdLib213 = testSbt (
174
179
project = " stdLib213" ,
175
180
testCommand = " library/compile" ,
176
181
updateCommand = " library/update" ,
177
182
extraSbtArgs = Seq (" -Dscala.build.compileWithDotty=true" )
178
183
)
179
184
180
- @ Test def shapeless = test (
185
+ @ Test def shapeless = testSbt (
181
186
project = " shapeless" ,
182
187
testCommand = " test" ,
183
188
updateCommand = " update"
184
189
)
185
190
186
- @ Test def xmlInterpolator = test (
191
+ @ Test def xmlInterpolator = testSbt (
187
192
project = " xml-interpolator" ,
188
193
testCommand = " test" ,
189
194
updateCommand = " update"
190
195
)
191
196
192
- @ Test def semanticdb = test (
197
+ @ Test def semanticdb = testSbt (
193
198
project = " semanticdb" ,
194
199
testCommand = " test:compile" ,
195
200
updateCommand = " update"
196
201
)
197
202
198
- @ Test def effpi = test (
203
+ @ Test def effpi = testSbt (
199
204
project = " effpi" ,
200
205
// We set `useEffpiPlugin := false` because we don't want to run their
201
206
// compiler plugin since it relies on external binaries (from the model
@@ -225,6 +230,6 @@ class UpdateCategory
225
230
226
231
@ Category (Array (classOf [UpdateCategory ]))
227
232
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)
233
+ override def testSbt (project : String , testCommand : String , updateCommand : String , extraSbtArgs : Seq [String ]): Unit =
234
+ super .testSbt (project, updateCommand, null , extraSbtArgs)
230
235
}
0 commit comments