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:
+18
-14
@@ -807,28 +807,32 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun testFileDoesNotExistWarning() {
|
fun testFileDoesNotExistWarning() {
|
||||||
|
fun absoluteFiles(vararg paths: String): Array<File> =
|
||||||
|
paths.map { File(it).absoluteFile }.toTypedArray()
|
||||||
|
|
||||||
initProject(JVM_MOCK_RUNTIME)
|
initProject(JVM_MOCK_RUNTIME)
|
||||||
|
|
||||||
|
val filesToBeReported = absoluteFiles("badroot.jar", "some/test.class")
|
||||||
|
val otherFiles = absoluteFiles("test/other/file.xml", "some/other/baddir")
|
||||||
|
|
||||||
AbstractKotlinJpsBuildTestCase.addDependency(
|
AbstractKotlinJpsBuildTestCase.addDependency(
|
||||||
JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "LibraryWithBadRoots",
|
JpsJavaDependencyScope.COMPILE,
|
||||||
File("badroot.jar"),
|
Lists.newArrayList(findModule("module")),
|
||||||
File("test/other/file.xml"),
|
false,
|
||||||
File("some/test.class"),
|
"LibraryWithBadRoots",
|
||||||
File("some/other/baddir"))
|
*(filesToBeReported + otherFiles)
|
||||||
|
)
|
||||||
|
|
||||||
val result = buildAllModules()
|
val result = buildAllModules()
|
||||||
result.assertSuccessful()
|
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(
|
val expectedText = expectedWarnings.sorted().joinToString("\n")
|
||||||
arrayOf(
|
val actualText = actualWarnings.sorted().joinToString("\n")
|
||||||
"""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"""),
|
Assert.assertEquals(expectedText, actualText)
|
||||||
warnings.map {
|
|
||||||
it.messageText.replace(File("").absolutePath, "TEST_PATH").replace("\\", "/")
|
|
||||||
}.sorted().toTypedArray()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testHelp() {
|
fun testHelp() {
|
||||||
|
|||||||
+18
-14
@@ -806,28 +806,32 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun testFileDoesNotExistWarning() {
|
fun testFileDoesNotExistWarning() {
|
||||||
|
fun absoluteFiles(vararg paths: String): Array<File> =
|
||||||
|
paths.map { File(it).absoluteFile }.toTypedArray()
|
||||||
|
|
||||||
initProject(JVM_MOCK_RUNTIME)
|
initProject(JVM_MOCK_RUNTIME)
|
||||||
|
|
||||||
|
val filesToBeReported = absoluteFiles("badroot.jar", "some/test.class")
|
||||||
|
val otherFiles = absoluteFiles("test/other/file.xml", "some/other/baddir")
|
||||||
|
|
||||||
AbstractKotlinJpsBuildTestCase.addDependency(
|
AbstractKotlinJpsBuildTestCase.addDependency(
|
||||||
JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "LibraryWithBadRoots",
|
JpsJavaDependencyScope.COMPILE,
|
||||||
File("badroot.jar"),
|
Lists.newArrayList(findModule("module")),
|
||||||
File("test/other/file.xml"),
|
false,
|
||||||
File("some/test.class"),
|
"LibraryWithBadRoots",
|
||||||
File("some/other/baddir"))
|
*(filesToBeReported + otherFiles)
|
||||||
|
)
|
||||||
|
|
||||||
val result = buildAllModules()
|
val result = buildAllModules()
|
||||||
result.assertSuccessful()
|
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(
|
val expectedText = expectedWarnings.sorted().joinToString("\n")
|
||||||
arrayOf(
|
val actualText = actualWarnings.sorted().joinToString("\n")
|
||||||
"""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"""),
|
Assert.assertEquals(expectedText, actualText)
|
||||||
warnings.map {
|
|
||||||
it.messageText.replace(File("").absolutePath, "TEST_PATH").replace("\\", "/")
|
|
||||||
}.sorted().toTypedArray()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testHelp() {
|
fun testHelp() {
|
||||||
|
|||||||
Reference in New Issue
Block a user