-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multivalued setting can be set multiply #9731
Changes from all commits
3e24960
973b285
196b3fa
ae55323
22e76e8
0772585
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,23 +1,23 @@ | ||||||
package dotty.tools | ||||||
package dotc | ||||||
|
||||||
import reporting.StoreReporter | ||||||
import vulpix.TestConfiguration | ||||||
|
||||||
import org.junit.Test | ||||||
import org.junit.Assert._ | ||||||
import dotty.tools.vulpix.TestConfiguration.mkClasspath | ||||||
|
||||||
import java.nio.file._ | ||||||
|
||||||
import dotty.tools.vulpix.TestConfiguration.mkClasspath | ||||||
import org.junit.Test | ||||||
import org.junit.Assert._ | ||||||
|
||||||
class SettingsTests { | ||||||
|
||||||
@Test def missingOutputDir: Unit = { | ||||||
@Test def missingOutputDir: Unit = | ||||||
val options = Array("-d", "not_here") | ||||||
val reporter = Main.process(options) | ||||||
val reporter = Main.process(options, reporter = StoreReporter()) | ||||||
assertEquals(1, reporter.errorCount) | ||||||
assertEquals("'not_here' does not exist or is not a directory or .jar file", reporter.allErrors.head.message) | ||||||
} | ||||||
|
||||||
@Test def jarOutput: Unit = { | ||||||
val source = "tests/pos/Foo.scala" | ||||||
|
@@ -29,13 +29,12 @@ class SettingsTests { | |||||
assertTrue(Files.exists(out)) | ||||||
} | ||||||
|
||||||
@Test def t8124: Unit = { | ||||||
val source = Paths.get("tests/pos/Foo.scala").normalize | ||||||
@Test def `t8124 Don't crash on missing argument`: Unit = | ||||||
val source = Paths.get("tests/pos/Foo.scala").normalize | ||||||
val outputDir = Paths.get("out/testSettings").normalize | ||||||
if (Files.notExists(outputDir)) Files.createDirectory(outputDir) | ||||||
val options = Array("-encoding", "-d", outputDir.toString, source.toString) | ||||||
val reporter = Main.process(options) | ||||||
if Files.notExists(outputDir) then Files.createDirectory(outputDir) | ||||||
// -encoding takes an arg! | ||||||
val options = Array("-encoding", "-d", outputDir.toString, source.toString) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The argument is missing for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ticket is about the missing arg. |
||||||
val reporter = Main.process(options, reporter = StoreReporter()) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
assertEquals(1, reporter.errorCount) | ||||||
} | ||||||
|
||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package dotty.tools.dotc | ||
package config | ||
|
||
import CommandLineParser.tokenize | ||
import Settings._ | ||
|
||
import org.junit.Test | ||
import org.junit.Assert._ | ||
|
||
class ScalaSettingsTests: | ||
|
||
@Test def `A multistring setting is multivalued`: Unit = | ||
class SUT extends SettingGroup: | ||
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.") | ||
val sut = SUT() | ||
val args = tokenize("-language:implicitConversions,dynamics") | ||
val sumy = ArgsSummary(sut.defaultState, args, errors = Nil, warnings = Nil) | ||
val res = sut.processArguments(sumy, processAll = true, skipped = Nil) | ||
val set = sut.language.valueIn(res.sstate) | ||
assertEquals(1, args.length) | ||
assertTrue("No warnings!", res.warnings.isEmpty) | ||
assertTrue("No errors!", res.errors.isEmpty) | ||
assertTrue("Has the feature", set.contains("implicitConversions")) | ||
assertTrue("Has the feature", set.contains("dynamics")) | ||
|
||
@Test def `t9719 Apply -language more than once`: Unit = | ||
class SUT extends SettingGroup: | ||
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.") | ||
val sut = SUT() | ||
val args = tokenize("-language:implicitConversions -language:dynamics") | ||
val sumy = ArgsSummary(sut.defaultState, args, errors = Nil, warnings = Nil) | ||
val res = sut.processArguments(sumy, processAll = true, skipped = Nil) | ||
val set = sut.language.valueIn(res.sstate) | ||
assertEquals(2, args.length) | ||
assertTrue("No warnings!", res.warnings.isEmpty) | ||
assertTrue("No errors!", res.errors.isEmpty) | ||
assertTrue("Has the feature", set.contains("implicitConversions")) | ||
assertTrue("Has the feature", set.contains("dynamics")) | ||
|
||
@Test def `Warn if multistring element is supplied multiply`: Unit = | ||
class SUT extends SettingGroup: | ||
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.") | ||
val sut = SUT() | ||
val args = tokenize("-language:dynamics -language:implicitConversions -language:dynamics") | ||
val sumy = ArgsSummary(sut.defaultState, args, errors = Nil, warnings = Nil) | ||
val res = sut.processArguments(sumy, processAll = true, skipped = Nil) | ||
val set = sut.language.valueIn(res.sstate) | ||
assertEquals(3, args.length) | ||
assertEquals("Must warn", 1, res.warnings.length) | ||
assertTrue("No errors!", res.errors.isEmpty) | ||
assertTrue("Has the feature", set.contains("implicitConversions")) | ||
assertTrue("Has the feature", set.contains("dynamics")) | ||
|
||
end ScalaSettingsTests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.