@@ -5,15 +5,18 @@ import reporting.StoreReporter
5
5
import vulpix .TestConfiguration
6
6
7
7
import core .Contexts .{Context , ContextBase }
8
- import dotty .tools .dotc .config .Settings ._
8
+ import dotty .tools .Useables .given
9
+ import dotty .tools .dotc .config .Settings .*
9
10
import dotty .tools .vulpix .TestConfiguration .mkClasspath
10
11
11
- import java .nio .file ._
12
+ import java .nio .file .* , Files . *
12
13
13
14
import org .junit .Test
14
- import org .junit .Assert ._
15
+ import org .junit .Assert .*
15
16
16
- class SettingsTests {
17
+ import scala .util .Using
18
+
19
+ class SettingsTests :
17
20
18
21
@ Test def missingOutputDir : Unit =
19
22
val options = Array (" -d" , " not_here" )
@@ -225,10 +228,25 @@ class SettingsTests {
225
228
assertFalse(" Multiple conflicting options is a warning" , summary.warnings.isEmpty)
226
229
assertTrue(summary.warnings.forall(_.contains(" updated" )))
227
230
231
+ @ Test def `dir option also warns` : Unit =
232
+ import java .nio .file .{Path => JPath }
233
+ import io .PlainFile , PlainFile .*
234
+ val abc : PlainFile = JPath .of(" a" , " b" , " c" ).toPlainFile
235
+ object Settings extends SettingGroup :
236
+ val option = OutputSetting (" -option" , " out" , " A file" , JPath .of(" a" , " b" , " c" ).toPlainFile)
237
+ Using .resource(createTempDirectory(" i13887" )) { dir =>
238
+ val target = createDirectory(dir.resolve(" x" ))
239
+ val mistake = createDirectory(dir.resolve(" y" ))
240
+ val args = List (" -option" , target.toString, " -option" , mistake.toString)
241
+ val summary = Settings .processArguments(args, processAll = true )
242
+ assertTrue(" Multiple options is not an error" , summary.errors.isEmpty)
243
+ assertFalse(" Multiple conflicting options is a warning" , summary.warnings.isEmpty)
244
+ assertTrue(summary.warnings.forall(_.contains(" updated" )))
245
+ }
246
+
228
247
// use the supplied summary for evaluating settings
229
248
private def withProcessedArgs (summary : ArgsSummary )(f : SettingsState ?=> Unit ) = f(using summary.sstate)
230
249
231
250
// evaluate a setting using only a SettingsState (instead of a full-blown Context)
232
251
extension [T ](setting : Setting [T ])
233
252
private def value (using ss : SettingsState ): T = setting.valueIn(ss)
234
- }
0 commit comments