mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Pass TaskResult better in tests.
This commit is contained in:
parent
521dfc327b
commit
2746f57b9a
2 changed files with 36 additions and 26 deletions
|
@ -36,30 +36,38 @@ abstract class GenericTestRunner(open val project: Project, open val classpath:
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun runTests() {
|
/**
|
||||||
|
* @return true if all the tests passed
|
||||||
|
*/
|
||||||
|
fun runTests() : Boolean {
|
||||||
val jvm = JavaInfo.create(File(SystemProperties.javaBase))
|
val jvm = JavaInfo.create(File(SystemProperties.javaBase))
|
||||||
val java = jvm.javaExecutable
|
val java = jvm.javaExecutable
|
||||||
val allArgs = arrayListOf<String>().apply {
|
if (args.size > 0) {
|
||||||
add(java!!.absolutePath)
|
val allArgs = arrayListOf<String>().apply {
|
||||||
add("-classpath")
|
add(java!!.absolutePath)
|
||||||
add(classpath.map { it.jarFile.get().absolutePath }.joinToString(File.pathSeparator))
|
add("-classpath")
|
||||||
add(mainClass)
|
add(classpath.map { it.jarFile.get().absolutePath }.joinToString(File.pathSeparator))
|
||||||
addAll(args)
|
add(mainClass)
|
||||||
}
|
addAll(args)
|
||||||
|
}
|
||||||
|
|
||||||
val pb = ProcessBuilder(allArgs)
|
val pb = ProcessBuilder(allArgs)
|
||||||
pb.directory(File(project.directory))
|
pb.directory(File(project.directory))
|
||||||
pb.inheritIO()
|
pb.inheritIO()
|
||||||
log(1, "Running tests with classpath size ${classpath.size}")
|
log(1, "Running tests with classpath size ${classpath.size}")
|
||||||
log(2, "Launching " + allArgs.joinToString(" "))
|
log(2, "Launching " + allArgs.joinToString(" "))
|
||||||
val process = pb.start()
|
val process = pb.start()
|
||||||
val errorCode = process.waitFor()
|
val errorCode = process.waitFor()
|
||||||
if (errorCode == 0) {
|
if (errorCode == 0) {
|
||||||
log(1, "All tests passed")
|
log(1, "All tests passed")
|
||||||
|
} else {
|
||||||
|
log(1, "Test failures")
|
||||||
|
}
|
||||||
|
return errorCode == 0
|
||||||
} else {
|
} else {
|
||||||
log(1, "Test failures")
|
log(2, "Couldn't find any test classes")
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,18 +64,20 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
||||||
result.addAll(dependencyManager.calculateDependencies(project, context, it))
|
result.addAll(dependencyManager.calculateDependencies(project, context, it))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dependencyManager.reorderDependencies(result)
|
val result2 = dependencyManager.reorderDependencies(result)
|
||||||
|
return result2
|
||||||
}
|
}
|
||||||
|
|
||||||
@Task(name = TASK_TEST, description = "Run the tests", runAfter = arrayOf("compile", "compileTest"))
|
@Task(name = TASK_TEST, description = "Run the tests", runAfter = arrayOf("compile", "compileTest"))
|
||||||
fun taskTest(project: Project) : TaskResult {
|
fun taskTest(project: Project) : TaskResult {
|
||||||
lp(project, "Running tests")
|
lp(project, "Running tests")
|
||||||
if (project.testDependencies.any { it.id.contains("testng")} ) {
|
val success =
|
||||||
TestNgRunner(project, testDependencies(project)).runTests()
|
if (project.testDependencies.any { it.id.contains("testng")} ) {
|
||||||
} else {
|
TestNgRunner(project, testDependencies(project)).runTests()
|
||||||
JUnitRunner(project, testDependencies(project)).runTests()
|
} else {
|
||||||
}
|
JUnitRunner(project, testDependencies(project)).runTests()
|
||||||
return TaskResult()
|
}
|
||||||
|
return TaskResult(success)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Task(name = TASK_CLEAN, description = "Clean the project", runBefore = arrayOf("compile"))
|
@Task(name = TASK_CLEAN, description = "Clean the project", runBefore = arrayOf("compile"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue