Skip to content

Commit 602f0e8

Browse files
committed
Fix path in timeout test
1 parent 528ee5c commit 602f0e8

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

compiler/test/dotty/tools/vulpix/FileDiff.scala

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,26 @@ object FileDiff {
2020
if (!(new File(checkFile)).exists) Nil
2121
else Using(Source.fromFile(checkFile, "UTF-8"))(_.getLines().toList).get
2222

23-
// handle check file path mismatch on windows
24-
def lineMatch(actual: String, expect: String): Boolean = {
25-
val actual1 = actual.stripLineEnd
26-
val expect1 = expect.stripLineEnd
27-
actual1 == expect1 || File.separatorChar == '\\' && actual1.replace('\\', '/') == expect1
28-
}
29-
30-
def linesMatch =
31-
outputLines.length == checkLines.length &&
32-
outputLines.lazyZip(checkLines).forall(lineMatch)
33-
34-
if (!linesMatch) Some(
23+
if (!matches(outputLines, checkLines)) Some(
3524
s"""|Output from '$sourceTitle' did not match check file. Actual output:
3625
|${outputLines.mkString(EOL)}
3726
|""".stripMargin + "\n")
3827
else None
3928
}
4029

30+
def matches(actual: String, expect: String): Boolean = {
31+
val actual1 = actual.stripLineEnd
32+
val expect1 = expect.stripLineEnd
33+
34+
// handle check file path mismatch on windows
35+
actual1 == expect1 || File.separatorChar == '\\' && actual1.replace('\\', '/') == expect1
36+
}
37+
38+
def matches(actual: Seq[String], expect: Seq[String]): Boolean = {
39+
actual.length == expect.length
40+
&& actual.lazyZip(expect).forall(matches)
41+
}
42+
4143
def dump(path: String, content: Seq[String]): Unit = {
4244
val outFile = dotty.tools.io.File(path)
4345
outFile.writeAll(content.mkString("", EOL, EOL))

compiler/test/dotty/tools/vulpix/VulpixUnitTests.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ class VulpixUnitTests extends ParallelTesting {
9191
}
9292

9393
@Test def runTimeout: Unit = {
94-
val fileName = s"tests${JFile.separatorChar}vulpix-tests${JFile.separatorChar}unit${JFile.separatorChar}timeout.scala"
94+
val fileName = s"tests/vulpix-tests/unit/timeout.scala"
9595
try {
9696
compileFile(fileName, defaultOptions).checkRuns()
9797
fail()
9898
} catch {
9999
case ae: AssertionError =>
100-
assertEquals(s"Run test failed, but should not, reasons:\n\n - encountered 1 test failures(s) - test '${fileName}' timed out",
101-
ae.getMessage)
100+
val message = s"Run test failed, but should not, reasons:\n\n - encountered 1 test failures(s) - test '${fileName}' timed out"
101+
assert(FileDiff.matches(message, ae.getMessage))
102102
}
103103
}
104104
}

0 commit comments

Comments
 (0)