Skip to content

Commit

Permalink
Rename run to runAndSucceed in integration tests Runner
Browse files Browse the repository at this point in the history
  • Loading branch information
qurbonzoda committed Sep 10, 2024
1 parent 1dcf8be commit 9729a3d
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Runner(
if (print) forwardStdOutput(System.out.bufferedWriter()) else this
}

fun run(vararg tasks: String, fn: BuildResult.() -> Unit = {}) {
fun runAndSucceed(vararg tasks: String, fn: BuildResult.() -> Unit = {}) {
val gradle = gradle(*tasks)
val buildResult = gradle.build()
buildResult.fn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AnnotationsValidationTest : GradleTest() {
assertOutputContains(error)
}
} else {
runner.run(platformBenchmarkTask) {
runner.runAndSucceed(platformBenchmarkTask) {
assertOutputContains("BUILD SUCCESSFUL")
}
}
Expand All @@ -44,7 +44,7 @@ class AnnotationsValidationTest : GradleTest() {
assertOutputContains(jvmSpecificError)
}
} else {
runner.run("jvmBenchmark") {
runner.runAndSucceed("jvmBenchmark") {
assertOutputContains("BUILD SUCCESSFUL")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ class ConfigurationCacheTest : GradleTest() {
}
}

project.run(*invokedTasks.toTypedArray(), "--configuration-cache") {
project.runAndSucceed(*invokedTasks.toTypedArray(), "--configuration-cache") {
assertTasksExecuted(invokedTasks + executedTasks)
assertConfigurationCacheStored()
}
project.run("clean", "--configuration-cache") {
project.runAndSucceed("clean", "--configuration-cache") {
assertConfigurationCacheStored()
}
project.run(*invokedTasks.toTypedArray(), "--configuration-cache") {
project.runAndSucceed(*invokedTasks.toTypedArray(), "--configuration-cache") {
assertTasksExecuted(invokedTasks + executedTasks)
assertConfigurationCacheReused()
}
project.run(*invokedTasks.toTypedArray(), "--configuration-cache") {
project.runAndSucceed(*invokedTasks.toTypedArray(), "--configuration-cache") {
assertTasksUpToDate(executedTasks)
assertConfigurationCacheReused()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class InvalidTargetingTest : GradleTest() {
@Test
fun testWasmNodeJs() {
val runner = project("invalid-target/wasm-nodejs", true)
runner.run("wasmJsBenchmark") // Successful
runner.runAndSucceed("wasmJsBenchmark")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class JvmToolchainsTest : GradleTest() {
fun testJvmToolchainSetup() {
val runner = project("kmp-with-toolchain", true, GradleTestVersion.v8_0) {
}
runner.run("benchmark") {
runner.runAndSucceed("benchmark") {
assertEquals(TaskOutcome.SUCCESS, task(":jvmBenchmark")!!.outcome)
assertOutputDoesNotContain("<failure>")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class KotlinNativeTest : GradleTest() {
val target = "native"
val capitalizedTarget = target.replaceFirstChar { it.uppercaseChar() }

runner.run(":${target}BenchmarkGenerate")
runner.run(":compile${capitalizedTarget}BenchmarkKotlin${capitalizedTarget}")
runner.run(":${capitalizedTarget}Benchmark")
runner.runAndSucceed(":${target}BenchmarkGenerate")
runner.runAndSucceed(":compile${capitalizedTarget}BenchmarkKotlin${capitalizedTarget}")
runner.runAndSucceed(":${capitalizedTarget}Benchmark")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class OptionsOverrideAnnotationsTest : GradleTest() {
configuration("config") {
setupBlock()
}
}.run("nativeConfigBenchmark") {
}.runAndSucceed("nativeConfigBenchmark") {
val reportText = reports("config").single().readText()
checkBlock(reportText, output)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class OptionsValidationTest : GradleTest() {
mode = "AverageTime"
}
}
runner.run("validOptionsBenchmark") // Successful
runner.runAndSucceed("validOptionsBenchmark")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ReportFormatTest : GradleTest() {
formats.forEach { format ->
val name = format ?: "jsonDefault"
val ext = format ?: "json"
runner.run("${name}Benchmark")
runner.runAndSucceed("${name}Benchmark")
val reports = reports(name)
assertEquals(targets.size, reports.size)
assertEquals(targets.map { "$it.$ext" }.toSet(), reports.map(File::getName).toSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SourceSetAsBenchmarkTargetTest : GradleTest() {
register(jvmBenchmark) { jmhVersion = "1.21" }
}

runner.run("${configuration}Benchmark")
runner.runAndSucceed("${configuration}Benchmark")
val reports = reports(configuration)
assertEquals(targets.size, reports.size)
assertEquals(targets.map { "$it.json" }.toSet(), reports.map(File::getName).toSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SuiteSourceGeneratorTest : GradleTest() {
private inline fun testSourceGenerator(setupBlock: Runner.() -> Unit, checkBlock: Runner.() -> Unit) {
project("source-generation").apply {
setupBlock()
run("nativeBenchmarkGenerate")
runAndSucceed("nativeBenchmarkGenerate")
checkBlock()
}
}
Expand Down Expand Up @@ -169,7 +169,7 @@ class SuiteSourceGeneratorTest : GradleTest() {

private fun generateAndCompile(target: String) {
project("kotlin-multiplatform", true).let { runner ->
runner.run(":${target}BenchmarkGenerate")
runner.runAndSucceed(":${target}BenchmarkGenerate")

runner.generatedDir(target, "RootBenchmark_Descriptor.kt") { descriptorFile ->
val text = descriptorFile.readText()
Expand All @@ -180,7 +180,7 @@ class SuiteSourceGeneratorTest : GradleTest() {
}

val capitalizedTarget = target.replaceFirstChar { it.uppercaseChar() }
runner.run(":compile${capitalizedTarget}BenchmarkKotlin${capitalizedTarget}")
runner.runAndSucceed(":compile${capitalizedTarget}BenchmarkKotlin${capitalizedTarget}")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SupportedGradleVersionTest : GradleTest() {
fun `when using min supported Gradle version, expect no warning`() {
val runner = project("kotlin-multiplatform", gradleVersion = GradleTestVersion.MinSupportedGradleVersion)

runner.run(":help", "-q") {
runner.runAndSucceed(":help", "-q") {
assertOutputDoesNotContain(warningMessage)
}
}
Expand All @@ -39,7 +39,7 @@ class SupportedGradleVersionTest : GradleTest() {
fun `when using unsupported Gradle version, expect warning`() {
val runner = project("kotlin-multiplatform", gradleVersion = GradleTestVersion.UnsupportedGradleVersion)

runner.run(":help", "-q") {
runner.runAndSucceed(":help", "-q") {
assertOutputContains(warningMessage)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class WasmGcOptionsTest : GradleTest() {
val runner = project(
"wasm-gc-non-experimental/wasm-nodejs", true, kotlinVersion = "1.9.24"
)
runner.run("wasmJsBenchmark")
runner.runAndSucceed("wasmJsBenchmark")
}

@Test
Expand All @@ -20,6 +20,6 @@ class WasmGcOptionsTest : GradleTest() {
val runner = project(
"wasm-gc-non-experimental/wasm-d8", true, kotlinVersion = "1.9.24"
)
runner.run( "wasmJsBenchmark")
runner.runAndSucceed( "wasmJsBenchmark")
}
}

0 comments on commit 9729a3d

Please sign in to comment.