Fix running gradle tests on windows

This commit is contained in:
Alexey Tsvetkov
2016-10-28 09:05:48 +03:00
parent 2c1699bc89
commit fa6ed71fbd
2 changed files with 6 additions and 20 deletions
@@ -28,7 +28,7 @@ abstract class BaseGradleIT {
@After
fun tearDown() {
deleteRecursively(workingDir)
workingDir.deleteRecursively()
}
companion object {
@@ -227,13 +227,12 @@ abstract class BaseGradleIT {
}
private fun Iterable<File>.projectRelativePaths(project: Project): Iterable<String> {
// val projectDir = File(workingDir.canonicalFile, project.projectName)
return map { it.canonicalFile.toRelativeString(project.projectDir) }
}
fun CompiledProject.assertSameFiles(expected: Iterable<String>, actual: Iterable<String>, messagePrefix: String): CompiledProject {
val expectedSet = expected.toSortedSet().joinToString("\n")
val actualSet = actual.toSortedSet().joinToString("\n")
val expectedSet = expected.map { it.normalizePath() }.toSortedSet().joinToString("\n")
val actualSet = actual.map { it.normalizePath() }.toSortedSet().joinToString("\n")
Assert.assertEquals(messagePrefix, expectedSet, actualSet)
return this
}
@@ -301,18 +300,5 @@ abstract class BaseGradleIT {
source.listFiles()?.forEach { copyRecursively(it, target) }
}
fun deleteRecursively(f: File): Unit {
if (f.isDirectory) {
f.listFiles()?.forEach { deleteRecursively(it) }
val fileList = f.listFiles()
if (fileList != null) {
if (!fileList.isEmpty()) {
fail("Expected $f to be empty but it has files: ${fileList.joinToString { it.name }}")
}
} else {
fail("Error listing directory content")
}
}
f.delete()
}
private fun String.normalizePath() = replace("\\", "/")
}
@@ -21,7 +21,7 @@ class BuildLogParserParametrizedIT : BaseGradleIT() {
val logFile = File(testDir, LOG_FILE_NAME)
assert(logFile.isFile) { "Log file: $logFile does not exist" }
val actualNormalized = dumpBuildLog(parseTestBuildLog(logFile)).trim()
val actualNormalized = dumpBuildLog(parseTestBuildLog(logFile)).replace("\r\n", "\n").trim()
val expectedFile = File(testDir, EXPECTED_PARSED_LOG_FILE_NAME)
if (!expectedFile.isFile) {
@@ -31,7 +31,7 @@ class BuildLogParserParametrizedIT : BaseGradleIT() {
throw AssertionError("Expected file log did not exist, created: $expectedFile")
}
val expectedNormalized = expectedFile.readText().trim()
val expectedNormalized = expectedFile.readText().replace("\r\n", "\n").trim()
Assert.assertEquals("Parsed content was unexpected: ", expectedNormalized, actualNormalized)
// parse expected, dump again and compare (to check that dumped log can be parsed again)