@@ -7,15 +7,18 @@ import reporting.StoreReporter
77import vulpix .TestConfiguration
88
99import core .Contexts .{Context , ContextBase }
10- import dotty .tools .dotc .config .Settings ._
10+ import dotty .tools .Useables .given
11+ import dotty .tools .dotc .config .Settings .*
1112import dotty .tools .vulpix .TestConfiguration .mkClasspath
1213
13- import java .nio .file ._
14+ import java .nio .file .* , Files . *
1415
1516import org .junit .Test
1617import org .junit .Assert .{assertEquals , assertFalse , assertTrue }
1718
18- class SettingsTests {
19+ import scala .util .Using
20+
21+ class SettingsTests :
1922
2023 @ Test def missingOutputDir : Unit =
2124 val options = Array (" -d" , " not_here" )
@@ -227,10 +230,25 @@ class SettingsTests {
227230 assertFalse(" Multiple conflicting options is a warning" , summary.warnings.isEmpty)
228231 assertTrue(summary.warnings.forall(_.contains(" updated" )))
229232
233+ @ Test def `dir option also warns` : Unit =
234+ import java .nio .file .Paths
235+ import io .PlainFile , PlainFile .*
236+ val abc : PlainFile = Paths .get(" a" , " b" , " c" ).toPlainFile
237+ object Settings extends SettingGroup :
238+ val option = OutputSetting (" -option" , " out" , " A file" , Paths .get(" a" , " b" , " c" ).toPlainFile)
239+ Using .resource(createTempDirectory(" i13887" )) { dir =>
240+ val target = createDirectory(dir.resolve(" x" ))
241+ val mistake = createDirectory(dir.resolve(" y" ))
242+ val args = List (" -option" , target.toString, " -option" , mistake.toString)
243+ val summary = Settings .processArguments(args, processAll = true )
244+ assertTrue(" Multiple options is not an error" , summary.errors.isEmpty)
245+ assertFalse(" Multiple conflicting options is a warning" , summary.warnings.isEmpty)
246+ assertTrue(summary.warnings.forall(_.contains(" updated" )))
247+ }
248+
230249 // use the supplied summary for evaluating settings
231250 private def withProcessedArgs (summary : ArgsSummary )(f : SettingsState ?=> Unit ) = f(using summary.sstate)
232251
233252 // evaluate a setting using only a SettingsState (instead of a full-blown Context)
234253 extension [T ](setting : Setting [T ])
235254 private def value (using ss : SettingsState ): T = setting.valueIn(ss)
236- }
0 commit comments