mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 16:07:12 -07:00
Disable new runner for now.
This commit is contained in:
parent
3b83d8d5d9
commit
6c16c59aa6
1 changed files with 44 additions and 32 deletions
|
@ -26,7 +26,7 @@ class TestNgRunner : GenericTestRunner() {
|
||||||
|
|
||||||
override val annotationPackage = "org.testng"
|
override val annotationPackage = "org.testng"
|
||||||
|
|
||||||
fun defaultOutput(project: Project) = KFiles.joinDir(KFiles.KOBALT_BUILD_DIR, project.buildDirectory, "test-output")
|
fun defaultOutput(project: Project) = KFiles.joinDir(project.buildDirectory, "test-output")
|
||||||
|
|
||||||
override fun args(project: Project, context: KobaltContext, classpath: List<IClasspathDependency>,
|
override fun args(project: Project, context: KobaltContext, classpath: List<IClasspathDependency>,
|
||||||
testConfig: TestConfig) = arrayListOf<String>().apply {
|
testConfig: TestConfig) = arrayListOf<String>().apply {
|
||||||
|
@ -61,61 +61,73 @@ class TestNgRunner : GenericTestRunner() {
|
||||||
|
|
||||||
val VERSION_6_10 = StringVersion("6.10")
|
val VERSION_6_10 = StringVersion("6.10")
|
||||||
|
|
||||||
override fun runTests(project: Project, context: KobaltContext, classpath: List<IClasspathDependency>,
|
fun _runTests(project: Project, context: KobaltContext, classpath: List<IClasspathDependency>,
|
||||||
configName: String): Boolean {
|
configName: String): Boolean {
|
||||||
|
|
||||||
context.logger.log(project.name, 1, "Running enhanced TestNG runner")
|
val testConfig = project.testConfigs.firstOrNull { it.name == configName }
|
||||||
|
|
||||||
val testngDependency = (project.testDependencies.filter { it.id.contains("testng") }
|
if (testConfig != null) {
|
||||||
.firstOrNull() as AetherDependency).version
|
context.logger.log(project.name, 1, "Running enhanced TestNG runner")
|
||||||
val remoteRunnerVersion = findRemoteRunnerVersion(testngDependency)
|
|
||||||
val result =
|
val testngDependency = (project.testDependencies.filter { it.id.contains("testng") }
|
||||||
if (remoteRunnerVersion != null) {
|
.firstOrNull() as AetherDependency).version
|
||||||
|
val versions = findRemoteRunnerVersion(testngDependency)
|
||||||
|
val result =
|
||||||
|
if (versions != null) {
|
||||||
context.logger.log(project.name, 1, "Modern TestNG, displaying colors")
|
context.logger.log(project.name, 1, "Modern TestNG, displaying colors")
|
||||||
displayPrettyColors(project, context, classpath, remoteRunnerVersion)
|
displayPrettyColors(project, context, classpath, testConfig, versions)
|
||||||
} else {
|
} else {
|
||||||
context.logger.log(project.name, 1, "Older TestNG ($testngDependency), using the old runner")
|
context.logger.log(project.name, 1, "Older TestNG ($testngDependency), using the old runner")
|
||||||
super.runTests(project, context, classpath, configName)
|
super.runTests(project, context, classpath, configName)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findRemoteRunnerVersion(testngVersion: String) : String? {
|
private fun findRemoteRunnerVersion(testngVersion: String) : Pair<String, String>? {
|
||||||
val tng = StringVersion(testngVersion)
|
val tng = StringVersion(testngVersion)
|
||||||
val result =
|
val result =
|
||||||
if (tng >= VERSION_6_10) "testng-remote6_10"
|
if (tng >= VERSION_6_10) Pair(testngVersion, "testng-remote6_10")
|
||||||
else if (tng >= StringVersion("6.9.10")) "testng-remote6_9_10"
|
else if (tng >= StringVersion("6.9.10")) Pair("6.9.10", "testng-remote6_9_10")
|
||||||
else if (tng >= StringVersion("6.9.7")) "testng-remote6_9_7"
|
else if (tng >= StringVersion("6.9.7")) Pair("6.9.7", "testng-remote6_9_7")
|
||||||
else if (tng >= StringVersion("6.5.1")) "testng-remote6_5_0"
|
else if (tng >= StringVersion("6.5.1")) Pair("6.5.1", "testng-remote6_5_0")
|
||||||
else if (tng >= StringVersion("6.0")) "testng-remote6_0"
|
else if (tng >= StringVersion("6.0")) Pair("6.0", "testng-remote6_0")
|
||||||
else null
|
else null
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun displayPrettyColors(project: Project, context: KobaltContext, classpath: List<IClasspathDependency>,
|
private fun displayPrettyColors(project: Project, context: KobaltContext,
|
||||||
remoteRunnerVersion: String?)
|
classpath: List<IClasspathDependency>, testConfig: TestConfig, versions: Pair<String, String>): Boolean {
|
||||||
: Boolean {
|
|
||||||
val port = 2345
|
val port = 2345
|
||||||
|
|
||||||
|
val testngVersion = versions.first
|
||||||
|
val remoteRunnerVersion = versions.second
|
||||||
val dep = with(context.dependencyManager) {
|
val dep = with(context.dependencyManager) {
|
||||||
val jf = create("org.testng.testng-remote:testng-remote:1.3.0")
|
val jf = create("org.testng.testng-remote:testng-remote:1.3.0")
|
||||||
val tr = create("org.testng.testng-remote:$remoteRunnerVersion:1.3.0")
|
val tr = create("org.testng.testng-remote:$remoteRunnerVersion:1.3.0")
|
||||||
val testng = create("org.testng:testng:6.10")
|
val testng = create("org.testng:testng:6.10")
|
||||||
transitiveClosure(listOf(jf, tr, testng))
|
transitiveClosure(listOf(jf, tr /*, testng */))
|
||||||
}
|
}
|
||||||
|
|
||||||
val cp = (classpath + dep).distinct().map { it.jarFile.get() }
|
val cp = (classpath + dep).distinct().map { it.jarFile.get() }
|
||||||
.joinToString(File.pathSeparator)
|
.joinToString(File.pathSeparator)
|
||||||
val passedArgs = listOf(
|
val calculatedArgs = args(project, context, classpath, testConfig)
|
||||||
"-classpath",
|
|
||||||
cp,
|
val jvmArgs = arrayListOf("-classpath", cp)
|
||||||
|
if (testConfig.jvmArgs.any()) {
|
||||||
|
jvmArgs.addAll(testConfig.jvmArgs)
|
||||||
|
}
|
||||||
|
val remoteArgs = listOf(
|
||||||
"org.testng.remote.RemoteTestNG",
|
"org.testng.remote.RemoteTestNG",
|
||||||
"-serport", port.toString(),
|
"-serport", port.toString(),
|
||||||
"-version", "6.10",
|
"-version", testngVersion,
|
||||||
"-dontexit",
|
"-dontexit",
|
||||||
RemoteArgs.PROTOCOL,
|
RemoteArgs.PROTOCOL,
|
||||||
"json",
|
"json")
|
||||||
"src/test/resources/testng.xml")
|
|
||||||
|
val passedArgs = jvmArgs + remoteArgs + calculatedArgs
|
||||||
|
|
||||||
Thread {
|
Thread {
|
||||||
runCommand {
|
runCommand {
|
||||||
|
@ -125,12 +137,12 @@ class TestNgRunner : GenericTestRunner() {
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
|
|
||||||
// Thread {
|
// Thread {
|
||||||
// val args2 = arrayOf("-serport", port.toString(), "-dontexit", RemoteArgs.PROTOCOL, "json",
|
// val args2 = arrayOf("-serport", port.toString(), "-dontexit", RemoteArgs.PROTOCOL, "json",
|
||||||
// "-version", "6.10",
|
// "-version", "6.10",
|
||||||
// "src/test/resources/testng.xml")
|
// "src/test/resources/testng.xml")
|
||||||
// RemoteTestNG.main(args2)
|
// RemoteTestNG.main(args2)
|
||||||
// }.start()
|
// }.start()
|
||||||
|
|
||||||
val mh = MessageHub(JsonMessageSender("localhost", port, true))
|
val mh = MessageHub(JsonMessageSender("localhost", port, true))
|
||||||
mh.setDebug(true)
|
mh.setDebug(true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue