Skip to content

Commit c4a010e

Browse files
committed
Partest rename NegStates
1 parent a4e58e2 commit c4a010e

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

test/dotty/partest/DottyPartestRunner.scala

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,26 @@ class DottyRunner(testFile: File, suiteRunner: SuiteRunner) extends nest.Runner(
101101
import TestState.{ Crash, Fail }
102102
import scala.reflect.internal.FatalError
103103

104-
sealed abstract class State
105-
case class FoundFailed() extends State
106-
case class FailedWithWrongNErr(expected: String, found: String) extends State
107-
case class NoneFailed() extends State
104+
sealed abstract class NegTestState
105+
// Don't get confused, the neg test passes when compilation fails for at
106+
// least one round (optionally checking the number of compiler errors and
107+
// compiler console output)
108+
case class CompFailed() extends NegTestState
109+
// the neg test fails when all rounds return either of these:
110+
case class CompFailedButWrongNErr(expected: String, found: String) extends NegTestState
111+
case class CompFailedButWrongDiff() extends NegTestState
112+
case class CompSucceeded() extends NegTestState
108113

109114
def nerrIsOk(reason: String) = {
110115
import scala.util.matching.Regex
111116
val nerrFinder = """compilation failed with (\d\d+) errors""".r
112117
reason match {
113118
case nerrFinder(found) =>
114119
SFile(FileOps(testFile) changeExtension "nerr").safeSlurp match {
115-
case Some(exp) if (exp != found) => FailedWithWrongNErr(exp, found)
116-
case _ => FoundFailed
120+
case Some(exp) if (exp != found) => CompFailedButWrongNErr(exp, found)
121+
case _ => CompFailed
117122
}
118-
case _ => FoundFailed
123+
case _ => CompFailed
119124
}
120125
}
121126

@@ -129,19 +134,31 @@ class DottyRunner(testFile: File, suiteRunner: SuiteRunner) extends nest.Runner(
129134

130135
val failureStates = compFailingRounds.map({ case (result, _) => result match {
131136
// or, OK, we'll let you crash the compiler with a FatalError if you supply a check file
132-
case Crash(_, t, _) if !checkFile.canRead || !t.isInstanceOf[FatalError] => NoneFailed
133-
case Fail(_, reason, _) => if (diffIsOk) nerrIsOk(reason) else NoneFailed
134-
case _ => if (diffIsOk) FoundFailed else NoneFailed
137+
case Crash(_, t, _) if !checkFile.canRead || !t.isInstanceOf[FatalError] => CompSucceeded
138+
case Fail(_, reason, _) => if (diffIsOk) nerrIsOk(reason) else CompFailedButWrongDiff
139+
case _ => if (diffIsOk) CompFailed else CompFailedButWrongDiff
135140
}})
136141

137-
if (failureStates.exists({ case FoundFailed => true; case _ => false })) {
142+
if (failureStates.exists({ case CompFailed => true; case _ => false })) {
138143
true
139144
} else {
140145
val existsNerr = failureStates.exists({
141-
case FailedWithWrongNErr(exp, found) => nextTestActionFailing(s"wrong number of compilation errors, expected: $exp, found: $found"); true
146+
case CompFailedButWrongNErr(exp, found) => nextTestActionFailing(s"wrong number of compilation errors, expected: $exp, found: $found"); true
142147
case _ => false
143148
})
144-
if (existsNerr) false else nextTestActionFailing("expected compilation failure")
149+
if (existsNerr) {
150+
false
151+
} else {
152+
val existsDiff = failureStates.exists({
153+
case CompFailedButWrongDiff() => nextTestActionFailing(s"output differs"); true
154+
case _ => false
155+
})
156+
if (existsDiff) {
157+
false
158+
} else {
159+
nextTestActionFailing("expected compilation failure")
160+
}
161+
}
145162
}
146163
}
147164
}

0 commit comments

Comments
 (0)