Make assertion message more readable in JPS test

The test was failing recently on CI, but assertion message
does not give enough info: arrays' sizes are not equal,
so there were extra warnings, but what they were?

Original commit: adc3e61742
This commit is contained in:
Alexey Tsvetkov
2018-04-09 05:51:06 +03:00
parent 1ad96a7db9
commit bdd795200c
2 changed files with 36 additions and 28 deletions
@@ -807,28 +807,32 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
}
fun testFileDoesNotExistWarning() {
fun absoluteFiles(vararg paths: String): Array<File> =
paths.map { File(it).absoluteFile }.toTypedArray()
initProject(JVM_MOCK_RUNTIME)
val filesToBeReported = absoluteFiles("badroot.jar", "some/test.class")
val otherFiles = absoluteFiles("test/other/file.xml", "some/other/baddir")
AbstractKotlinJpsBuildTestCase.addDependency(
JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "LibraryWithBadRoots",
File("badroot.jar"),
File("test/other/file.xml"),
File("some/test.class"),
File("some/other/baddir"))
JpsJavaDependencyScope.COMPILE,
Lists.newArrayList(findModule("module")),
false,
"LibraryWithBadRoots",
*(filesToBeReported + otherFiles)
)
val result = buildAllModules()
result.assertSuccessful()
val warnings = result.getMessages(BuildMessage.Kind.WARNING)
val actualWarnings = result.getMessages(BuildMessage.Kind.WARNING).map { it.messageText }
val expectedWarnings = filesToBeReported.map { "Classpath entry points to a non-existent location: $it" }
Assert.assertArrayEquals(
arrayOf(
"""Classpath entry points to a non-existent location: TEST_PATH/badroot.jar""",
"""Classpath entry points to a non-existent location: TEST_PATH/some/test.class"""),
warnings.map {
it.messageText.replace(File("").absolutePath, "TEST_PATH").replace("\\", "/")
}.sorted().toTypedArray()
)
val expectedText = expectedWarnings.sorted().joinToString("\n")
val actualText = actualWarnings.sorted().joinToString("\n")
Assert.assertEquals(expectedText, actualText)
}
fun testHelp() {
@@ -806,28 +806,32 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
}
fun testFileDoesNotExistWarning() {
fun absoluteFiles(vararg paths: String): Array<File> =
paths.map { File(it).absoluteFile }.toTypedArray()
initProject(JVM_MOCK_RUNTIME)
val filesToBeReported = absoluteFiles("badroot.jar", "some/test.class")
val otherFiles = absoluteFiles("test/other/file.xml", "some/other/baddir")
AbstractKotlinJpsBuildTestCase.addDependency(
JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "LibraryWithBadRoots",
File("badroot.jar"),
File("test/other/file.xml"),
File("some/test.class"),
File("some/other/baddir"))
JpsJavaDependencyScope.COMPILE,
Lists.newArrayList(findModule("module")),
false,
"LibraryWithBadRoots",
*(filesToBeReported + otherFiles)
)
val result = buildAllModules()
result.assertSuccessful()
val warnings = result.getMessages(BuildMessage.Kind.WARNING)
val actualWarnings = result.getMessages(BuildMessage.Kind.WARNING).map { it.messageText }
val expectedWarnings = filesToBeReported.map { "Classpath entry points to a non-existent location: $it" }
Assert.assertArrayEquals(
arrayOf(
"""Classpath entry points to a non-existent location: TEST_PATH/badroot.jar""",
"""Classpath entry points to a non-existent location: TEST_PATH/some/test.class"""),
warnings.map {
it.messageText.replace(File("").absolutePath, "TEST_PATH").replace("\\", "/")
}.sorted().toTypedArray()
)
val expectedText = expectedWarnings.sorted().joinToString("\n")
val actualText = actualWarnings.sorted().joinToString("\n")
Assert.assertEquals(expectedText, actualText)
}
fun testHelp() {