Assert that formatter snippet test output is stable (#1270)

This commit is contained in:
Jen Basch
2025-10-29 17:08:43 -07:00
committed by GitHub
parent 1d6261b263
commit 7bf150055c
4 changed files with 65 additions and 8 deletions

View File

@@ -111,12 +111,14 @@ data class SnippetOutcome(val expectedOutFile: Path, val actual: String, val suc
}
}
private fun failWithDiff(message: String): Nothing =
if (System.getProperty("sun.java.command", "").contains("intellij")) {
// IntelliJ only shows diffs for AssertionFailedError
throw AssertionFailedError(message, expected, actual)
} else {
// Gradle test logging/report only shows diffs for PklAssertionFailedError
throw PklAssertionFailedError(message, expected, actual)
}
private fun failWithDiff(message: String): Nothing = failWithDiff(message, expected, actual)
}
fun failWithDiff(message: String, expected: String, actual: String): Nothing =
if (System.getProperty("sun.java.command", "").contains("intellij")) {
// IntelliJ only shows diffs for AssertionFailedError
throw AssertionFailedError(message, expected, actual)
} else {
// Gradle test logging/report only shows diffs for PklAssertionFailedError
throw PklAssertionFailedError(message, expected, actual)
}