1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28:12 -07:00

Fix local tests.

This commit is contained in:
Cedric Beust 2016-04-18 18:53:57 -07:00
parent 7d6ac61876
commit f7912f40e7

View file

@ -39,34 +39,38 @@ class VerifyKobaltZipTest : KobaltTest() {
val mainJarFilePath = "kobalt-$KOBALT_VERSION.jar" val mainJarFilePath = "kobalt-$KOBALT_VERSION.jar"
val zipFilePath = KFiles.joinDir("kobaltBuild", "libs", "kobalt-$KOBALT_VERSION.zip") val zipFilePath = KFiles.joinDir("kobaltBuild", "libs", "kobalt-$KOBALT_VERSION.zip")
val zipFile = JarFile(zipFilePath) if (File(zipFilePath).exists()) {
val stream = JarInputStream(FileInputStream(zipFilePath)) val zipFile = JarFile(zipFilePath)
var entry = stream.nextEntry val stream = JarInputStream(FileInputStream(zipFilePath))
while (entry != null) { var entry = stream.nextEntry
if (entry.name.endsWith("kobaltw")) { while (entry != null) {
foundKobaltw = true if (entry.name.endsWith("kobaltw")) {
} else if (entry.name.endsWith(mainJarFilePath)) { foundKobaltw = true
val ins = zipFile.getInputStream(entry) } else if (entry.name.endsWith(mainJarFilePath)) {
if (ins.available() < 20000000) { val ins = zipFile.getInputStream(entry)
throw KobaltException(mainJarFilePath + " is too small: " + mainJarFilePath) if (ins.available() < 20000000) {
throw KobaltException(mainJarFilePath + " is too small: " + mainJarFilePath)
}
verifyMainJarFile(ins)
foundJar = true
} else if (entry.name.endsWith("kobalt-wrapper.jar")) {
foundWrapperJar = true
} }
verifyMainJarFile(ins) entry = stream.nextEntry
foundJar = true
} else if (entry.name.endsWith("kobalt-wrapper.jar")) {
foundWrapperJar = true
} }
entry = stream.nextEntry if (!foundKobaltw) {
throw KobaltException("Couldn't find kobaltw in $zipFilePath")
}
if (!foundJar) {
throw KobaltException("Couldn't find jar in $zipFilePath")
}
if (!foundWrapperJar) {
throw KobaltException("Couldn't find wrapper jar in $zipFilePath")
}
log(1, "$zipFilePath looks correct")
} else {
log(1, "Couldn't find $zipFilePath, skipping test")
} }
if (! foundKobaltw) {
throw KobaltException("Couldn't find kobaltw in $zipFilePath")
}
if (! foundJar) {
throw KobaltException("Couldn't find jar in $zipFilePath")
}
if (! foundWrapperJar) {
throw KobaltException("Couldn't find wrapper jar in $zipFilePath")
}
log(1, "$zipFilePath looks correct")
} }
private fun assertExistsInJarInputStream(ins: JarInputStream, vararg fileNames: String) { private fun assertExistsInJarInputStream(ins: JarInputStream, vararg fileNames: String) {
@ -79,7 +83,12 @@ class VerifyKobaltZipTest : KobaltTest() {
private fun assertExistsInJar(jarName: String, vararg fileNames: String) { private fun assertExistsInJar(jarName: String, vararg fileNames: String) {
val sourceJarPath = KFiles.joinDir("kobaltBuild", "libs", jarName) val sourceJarPath = KFiles.joinDir("kobaltBuild", "libs", jarName)
assertExistsInJarInputStream(JarInputStream(FileInputStream(File(sourceJarPath))), *fileNames) val file = File(sourceJarPath)
if (file.exists()) {
assertExistsInJarInputStream(JarInputStream(FileInputStream(file)), *fileNames)
} else {
log(1, "Couldn't find $file, skipping test")
}
} }
private fun jarContents(stream: JarInputStream) : Set<String> { private fun jarContents(stream: JarInputStream) : Set<String> {