@@ -7,15 +7,18 @@ import reporting.StoreReporter
7
7
import vulpix .TestConfiguration
8
8
9
9
import core .Contexts .{Context , ContextBase }
10
- import dotty .tools .dotc .config .Settings ._
10
+ import dotty .tools .Useables .given
11
+ import dotty .tools .dotc .config .Settings .*
11
12
import dotty .tools .vulpix .TestConfiguration .mkClasspath
12
13
13
- import java .nio .file ._
14
+ import java .nio .file .* , Files . *
14
15
15
16
import org .junit .Test
16
17
import org .junit .Assert .{assertEquals , assertFalse , assertTrue }
17
18
18
- class SettingsTests {
19
+ import scala .util .Using
20
+
21
+ class SettingsTests :
19
22
20
23
@ Test def missingOutputDir : Unit =
21
24
val options = Array (" -d" , " not_here" )
@@ -227,10 +230,25 @@ class SettingsTests {
227
230
assertFalse(" Multiple conflicting options is a warning" , summary.warnings.isEmpty)
228
231
assertTrue(summary.warnings.forall(_.contains(" updated" )))
229
232
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
+
230
249
// use the supplied summary for evaluating settings
231
250
private def withProcessedArgs (summary : ArgsSummary )(f : SettingsState ?=> Unit ) = f(using summary.sstate)
232
251
233
252
// evaluate a setting using only a SettingsState (instead of a full-blown Context)
234
253
extension [T ](setting : Setting [T ])
235
254
private def value (using ss : SettingsState ): T = setting.valueIn(ss)
236
- }
0 commit comments