@@ -7,7 +7,8 @@ import java.io.File
7
7
import scala .jdk .CollectionConverters .*
8
8
import scala .util .Properties
9
9
10
- trait RunScalacCompatTestDefinitions { _ : RunTestDefinitions =>
10
+ trait RunScalacCompatTestDefinitions {
11
+ _ : RunTestDefinitions =>
11
12
def commandLineScalacXOption (): Unit = {
12
13
val inputs = TestInputs (
13
14
os.rel / " Test.scala" ->
@@ -143,26 +144,30 @@ trait RunScalacCompatTestDefinitions { _: RunTestDefinitions =>
143
144
}
144
145
}
145
146
146
- test(" scalac print options" ) {
147
+ for {
148
+ printOption <- {
149
+ val printOptionsForAllVersions = Seq (" -X" , " -Xshow-phases" , " -Xplugin-list" , " -Y" )
150
+ val printOptionsScala213OrHigher = Seq (" -V" , " -Vphases" , " -W" )
151
+ val printOptionsScala2 = Seq (" -Xlint:help" )
152
+ actualScalaVersion match {
153
+ case v if v.startsWith(" 3" ) => printOptionsForAllVersions ++ printOptionsScala213OrHigher
154
+ case v if v.startsWith(" 2.13" ) =>
155
+ printOptionsForAllVersions ++ printOptionsScala213OrHigher ++ printOptionsScala2
156
+ case v if v.startsWith(" 2.12" ) => printOptionsForAllVersions ++ printOptionsScala2
157
+ }
158
+ }
159
+ explicitSubcommand <- Seq (true , false )
160
+ explicitSubcommandString =
161
+ if (explicitSubcommand) " (explicit run subcommand)" else " (default subcommand)"
162
+ } test(s " scalac print option: $printOption $explicitSubcommandString" ) {
147
163
emptyInputs.fromRoot { root =>
148
- val printOptionsForAllVersions = Seq (" -X" , " -Xshow-phases" , " -Y" )
149
- val printOptionsSince213 = Seq (" -V" , " -Vphases" , " -W" )
150
- val version213OrHigher =
151
- actualScalaVersion.startsWith(" 2.13" ) || actualScalaVersion.startsWith(" 3" )
152
- val printOptionsToTest = printOptionsForAllVersions ++
164
+ val res =
153
165
(
154
- if (version213OrHigher) printOptionsSince213
155
- else Seq .empty
156
- )
157
- printOptionsToTest.foreach { printOption =>
158
- val res = os.proc(
159
- TestUtil .cli,
160
- extraOptions,
161
- printOption
162
- )
163
- .call(cwd = root, mergeErrIntoOut = true )
164
- expect(res.out.text().nonEmpty)
165
- }
166
+ if (explicitSubcommand) os.proc(TestUtil .cli, " run" , printOption, extraOptions)
167
+ else os.proc(TestUtil .cli, printOption, extraOptions)
168
+ ).call(cwd = root, mergeErrIntoOut = true )
169
+ expect(res.exitCode == 0 )
170
+ expect(res.out.text().nonEmpty)
166
171
}
167
172
}
168
173
0 commit comments