Skip to content

Commit 0036e7a

Browse files
authored
Merge pull request scala#7301 from som-snytt/issue/deflag
Partest warns about orphan flags or check
2 parents 3a8a338 + 4764a3e commit 0036e7a

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/partest/scala/tools/partest/TestKinds.scala

+9-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,15 @@ class TestKinds(pathSettings: PathSettings) {
3535
(candidates exists matches)
3636
}
3737

38-
def testsFor(kind: String): List[Path] = (pathSettings.srcDir / kind toDirectory).list.toList filter denotesTestPath
38+
def testsFor(kind: String): (List[Path], List[Path]) = {
39+
val (ti, others) = (pathSettings.srcDir / kind).toDirectory.list.partition(denotesTestPath)
40+
val ts = ti.toList
41+
val names = ts.toSet
42+
def warnable(p: Path) = (p.hasExtension("flags") || p.hasExtension("check")) &&
43+
!names(p.changeExtension("scala")) && !names(p.parent / p.stripExtension)
44+
(ts, others.filter(warnable).toList)
45+
}
3946
def grepFor(expr: String): List[Path] = standardTests filter (t => pathMatchesExpr(t, expr))
40-
def standardTests: List[Path] = standardKinds flatMap testsFor
47+
def standardTests: List[Path] = standardKinds flatMap (k => testsFor(k)._1)
4148
def failedTests: List[Path] = standardTests filter (p => logOf(p).isFile)
4249
}

src/partest/scala/tools/partest/nest/AbstractRunner.scala

+5-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ class AbstractRunner(val config: RunnerSpec.Config, protected final val testSour
214214
else if (miscTests.isEmpty && invalid.isEmpty) standardKinds // If no kinds, --grep, or individual tests were given, assume --all, unless there were invalid files specified
215215
else Nil
216216
)
217-
val kindsTests = kinds flatMap testsFor
217+
val kindsTests = kinds.flatMap { k =>
218+
val (good, bad) = testsFor(k)
219+
bad.foreach(baddie => echoWarning(s"Extraneous file: $baddie"))
220+
good
221+
}
218222

219223
def testContributors = {
220224
List(

0 commit comments

Comments
 (0)