Skip to content

Dump output file when test fails #6315

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ vscode-dotty/.vscode-test

community-build/dotty-bootstrapped.version
community-build/sbt-dotty-sbt

# Vulpix output files
*.check.out
55 changes: 27 additions & 28 deletions compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,22 @@ trait ParallelTesting extends RunnerOrchestration { self =>
this
}

protected def updateCheckFile(checkFile: JFile, lines: Seq[String]): Unit = {
val outFile = dotty.tools.io.File(checkFile.toPath)
outFile.writeAll(lines.mkString("", EOL, EOL))
echo("Updated checkfile: " + checkFile.getPath)
protected def dumpOutputToFile(checkFile: JFile, lines: Seq[String]): Unit = {
if (updateCheckFiles) {
val outFile = dotty.tools.io.File(checkFile.toPath)
outFile.writeAll(lines.mkString("", EOL, EOL))
echo("Updated checkfile: " + checkFile.getPath)
} else {
val outFile = dotty.tools.io.File(checkFile.toPath.resolveSibling(checkFile.toPath.getFileName + ".out"))
outFile.writeAll(lines.mkString("", EOL, EOL))
echo(
s"""Test output dumped in: ${outFile.path}
| See diff of the checkfile
| > diff $checkFile $outFile
| Replace checkfile with current output output
| > mv $outFile $checkFile
""".stripMargin)
}
}

/** Returns all files in directory or the file if not a directory */
Expand Down Expand Up @@ -558,26 +570,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
.mkString(EOL)

if (output.mkString(EOL) != check) {
val outFile = dotty.tools.io.File(checkFile.toPath).addExtension(".out")
if (updateCheckFiles) {
updateCheckFile(checkFile, output)
} else {
outFile.writeAll(output.mkString("", EOL, ""))
val msg =
s"""Output differed for test $name, use the following command to see the diff:
| > diff $checkFile $outFile
""".stripMargin

echo(msg)
addFailureInstruction(msg)

// Print build instructions to file and summary:
val buildInstr = testSource.buildInstructions(0, rep.warningCount)
addFailureInstruction(buildInstr)

// Fail target:
failTestSource(testSource)
}

dumpOutputToFile(checkFile, output)

// Print build instructions to file and summary:
val buildInstr = testSource.buildInstructions(0, rep.warningCount)
addFailureInstruction(buildInstr)

// Fail target:
failTestSource(testSource)
}
case _ =>
}
Expand Down Expand Up @@ -651,8 +652,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
// Fail target:
failTestSource(testSource)

if (updateCheckFiles)
updateCheckFile(checkFile.get, outputLines)
dumpOutputToFile(checkFile.get, outputLines)
}
}

Expand Down Expand Up @@ -790,8 +790,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
val expexted = Source.fromFile(checkFile, "UTF-8").getLines().toList
for (msg <- diffMessage(sourceName, actual, expexted)) {
fail(msg)
if (updateCheckFiles)
updateCheckFile(checkFile, actual)
dumpOutputToFile(checkFile, actual)
}
}

Expand Down