mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Fix zip test.
This commit is contained in:
parent
400a73b51b
commit
469419fe2e
1 changed files with 13 additions and 11 deletions
|
@ -43,7 +43,7 @@ class VerifyKobaltZipTest : KobaltTest() {
|
||||||
} else if (entry.name.endsWith("kobalt-wrapper.jar")) {
|
} else if (entry.name.endsWith("kobalt-wrapper.jar")) {
|
||||||
val ins = zipFile.getInputStream(entry)
|
val ins = zipFile.getInputStream(entry)
|
||||||
foundWrapperJar = true
|
foundWrapperJar = true
|
||||||
assertExistsInJar(JarInputStream(ins), "kobalt.properties")
|
assertExistsInJar(jarContents(JarInputStream(ins)), "kobalt.properties")
|
||||||
}
|
}
|
||||||
entry = stream.nextEntry
|
entry = stream.nextEntry
|
||||||
}
|
}
|
||||||
|
@ -73,26 +73,28 @@ class VerifyKobaltZipTest : KobaltTest() {
|
||||||
|
|
||||||
private fun verifyMainJarFile(ins: InputStream) {
|
private fun verifyMainJarFile(ins: InputStream) {
|
||||||
JarInputStream(ins).let { jar ->
|
JarInputStream(ins).let { jar ->
|
||||||
assertExistsInJar(jar, "com/beust/kobalt/MainKt.class",
|
val setContent = jarContents(jar)
|
||||||
|
assertExistsInJar(setContent, "com/beust/kobalt/MainKt.class",
|
||||||
"templates/kobaltPlugin/kobaltPlugin.jar", "com/beust/kobalt/Args.class",
|
"templates/kobaltPlugin/kobaltPlugin.jar", "com/beust/kobalt/Args.class",
|
||||||
"com/beust/kobalt/wrapper/Main.class")
|
"com/beust/kobalt/wrapper/Main.class")
|
||||||
assertDoesNotExistInJar(jar, "BuildKt.class")
|
assertDoesNotExistInJar(setContent, "BuildKt.class")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun assertExistsInJar(ins: JarInputStream, vararg fileNames: String)
|
private fun assertExistsInJar(content: Set<String>, vararg fileNames: String)
|
||||||
= assertExistence(ins, true, *fileNames)
|
= assertExistence(content, true, *fileNames)
|
||||||
|
|
||||||
private fun assertDoesNotExistInJar(ins: JarInputStream, vararg fileNames: String)
|
private fun assertDoesNotExistInJar(content: Set<String>, vararg fileNames: String)
|
||||||
= assertExistence(ins, false, *fileNames)
|
= assertExistence(content, false, *fileNames)
|
||||||
|
|
||||||
private fun assertExistence(ins: JarInputStream, verifyExistence: Boolean, vararg fileNames: String) {
|
private fun assertExistence(content: Set<String>, verifyExistence: Boolean, vararg fileNames: String) {
|
||||||
with(jarContents(ins)) {
|
with(content) {
|
||||||
fileNames.forEach { fileName ->
|
fileNames.forEach { fileName ->
|
||||||
if (verifyExistence) {
|
if (verifyExistence) {
|
||||||
Assert.assertTrue(contains(fileName), "Couldn't find $fileName")
|
Assert.assertTrue(contains(fileName), "Couldn't find $fileName")
|
||||||
} else {
|
} else {
|
||||||
Assert.assertFalse(contains(fileName), "Couldn't find $fileName")
|
val exists = content.contains(fileName)
|
||||||
|
Assert.assertFalse(exists, "The jar file should not contain $fileName")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +104,7 @@ class VerifyKobaltZipTest : KobaltTest() {
|
||||||
val sourceJarPath = KFiles.joinDir("kobaltBuild", "libs", jarName)
|
val sourceJarPath = KFiles.joinDir("kobaltBuild", "libs", jarName)
|
||||||
val file = File(sourceJarPath)
|
val file = File(sourceJarPath)
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
assertExistsInJar(JarInputStream(FileInputStream(file)), *fileNames)
|
assertExistsInJar(jarContents(JarInputStream(FileInputStream(file))), *fileNames)
|
||||||
} else {
|
} else {
|
||||||
kobaltLog(1, "Couldn't find $file, skipping test")
|
kobaltLog(1, "Couldn't find $file, skipping test")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue