Skip to content

Commit 02a80b8

Browse files
committed
fix: refactor smoke test e2e tests to use already running gradle instance
1 parent 1c4c662 commit 02a80b8

File tree

1 file changed

+16
-14
lines changed
  • tests/codegen/smoke-tests/src/test/kotlin/aws/sdk/kotlin/test/codegen/smoketest

1 file changed

+16
-14
lines changed

tests/codegen/smoke-tests/src/test/kotlin/aws/sdk/kotlin/test/codegen/smoketest/SmokeTestE2ETest.kt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
package aws.sdk.kotlin.tests.codegen.smoketests
6+
package aws.sdk.kotlin.test.codegen.smoketest
77

88
import aws.sdk.kotlin.codegen.smoketests.AWS_SERVICE_FILTER
99
import aws.sdk.kotlin.codegen.smoketests.AWS_SKIP_TAGS
10-
import org.gradle.testkit.runner.GradleRunner
1110
import java.io.File
1211
import kotlin.test.Test
1312
import kotlin.test.assertContains
@@ -30,7 +29,7 @@ class SmokeTestE2ETest {
3029

3130
@Test
3231
fun exceptionService() {
33-
val smokeTestRunnerOutput = runSmokeTests("exceptionService", expectingFailure = true)
32+
val smokeTestRunnerOutput = runSmokeTests("exceptionService")
3433

3534
assertContains(smokeTestRunnerOutput, "not ok ExceptionService ExceptionTest - no error expected from service")
3635
assertContains(smokeTestRunnerOutput, "#aws.smithy.kotlin.runtime.http.interceptors.SmokeTestsFailureException: Smoke test failed with HTTP status code: 400")
@@ -58,21 +57,24 @@ class SmokeTestE2ETest {
5857
private fun runSmokeTests(
5958
service: String,
6059
envVars: Map<String, String> = emptyMap(),
61-
expectingFailure: Boolean = false,
6260
): String {
6361
val sdkRootDir = System.getProperty("user.dir") + "/../../../"
64-
65-
val task = GradleRunner.create()
66-
.withProjectDir(File(sdkRootDir))
67-
.withArguments(
68-
"--stacktrace", // Make sure unexpected errors are debuggable
69-
"-Paws.kotlin.native=false", // FIXME: Remove `-Paws.kotlin.native=false` when Kotlin Native is ready
62+
val processBuilder =
63+
ProcessBuilder(
64+
"./gradlew",
7065
":tests:codegen:smoke-tests:services:$service:smokeTest",
66+
// Make sure unexpected errors are debuggable
67+
"--stacktrace",
68+
// FIXME: Remove `-Paws.kotlin.native=false` when Kotlin Native is ready
69+
"-Paws.kotlin.native=false",
7170
)
72-
.withEnvironment(envVars)
73-
.forwardOutput()
71+
.directory(File(sdkRootDir))
72+
.redirectErrorStream(true)
73+
74+
processBuilder.environment().putAll(envVars)
7475

75-
val buildResult = if (expectingFailure) task.buildAndFail() else task.build()
76+
val process = processBuilder.start()
77+
val output = process.inputStream.bufferedReader().use { it.readText() }
7678

77-
return buildResult.output
79+
return output
7880
}

0 commit comments

Comments
 (0)