@@ -5,15 +5,18 @@ import reporting.StoreReporter
55import vulpix .TestConfiguration
66
77import core .Contexts .{Context , ContextBase }
8- import dotty .tools .dotc .config .Settings ._
8+ import dotty .tools .Useables .given
9+ import dotty .tools .dotc .config .Settings .*
910import dotty .tools .vulpix .TestConfiguration .mkClasspath
1011
11- import java .nio .file ._
12+ import java .nio .file .* , Files . *
1213
1314import org .junit .Test
14- import org .junit .Assert ._
15+ import org .junit .Assert .*
1516
16- class SettingsTests {
17+ import scala .util .Using
18+
19+ class SettingsTests :
1720
1821 @ Test def missingOutputDir : Unit =
1922 val options = Array (" -d" , " not_here" )
@@ -225,10 +228,25 @@ class SettingsTests {
225228 assertFalse(" Multiple conflicting options is a warning" , summary.warnings.isEmpty)
226229 assertTrue(summary.warnings.forall(_.contains(" updated" )))
227230
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+
228247 // use the supplied summary for evaluating settings
229248 private def withProcessedArgs (summary : ArgsSummary )(f : SettingsState ?=> Unit ) = f(using summary.sstate)
230249
231250 // evaluate a setting using only a SettingsState (instead of a full-blown Context)
232251 extension [T ](setting : Setting [T ])
233252 private def value (using ss : SettingsState ): T = setting.valueIn(ss)
234- }
0 commit comments