[K/N][tests] Make mention of the test data file grouping more visible
When running `codegen/box` tests, Kotlin/Native test infrastructure divides test data files into groups and compiles each group in a single compilation. As a result, compilation problem with one test can cause an unrelated nearby test to fail. To make this less frustrating, this commit adjusts test failure reports: it moves the test grouping mention from the bottom of a report to the top and makes the wording more clear and actionable.
This commit is contained in:
committed by
Space Team
parent
deb7999bfb
commit
8a8eb18efd
+24
-12
@@ -53,12 +53,7 @@ internal abstract class LoggedData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CompilerParameters(
|
class CompilerInput(private val sourceModules: Collection<TestModule>) : LoggedData() {
|
||||||
private val home: KotlinNativeHome,
|
|
||||||
private val compilerArgs: Array<String>,
|
|
||||||
private val sourceModules: Collection<TestModule>,
|
|
||||||
private val environment: JVMEnvironment = JVMEnvironment() // Capture environment.
|
|
||||||
) : LoggedData() {
|
|
||||||
private val testDataFiles: List<File>
|
private val testDataFiles: List<File>
|
||||||
get() = buildList {
|
get() = buildList {
|
||||||
sourceModules.forEach { module ->
|
sourceModules.forEach { module ->
|
||||||
@@ -68,16 +63,30 @@ internal abstract class LoggedData {
|
|||||||
sort()
|
sort()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun computeText(): String = buildString {
|
||||||
|
val files = testDataFiles
|
||||||
|
if (files.size > 1) {
|
||||||
|
appendLine("NOTE: this compilation includes multiple test data files!")
|
||||||
|
appendLine(" So a test failure doesn't imply that something is wrong with that particular test.")
|
||||||
|
appendLine(" To check the single test data file, rerun the test with the following Gradle flag:")
|
||||||
|
appendLine(" -Pkotlin.internal.native.test.forceStandalone=true")
|
||||||
|
appendLine()
|
||||||
|
appendList("TEST DATA FILES (COMPILED TOGETHER):", testDataFiles)
|
||||||
|
} else {
|
||||||
|
appendLine("TEST DATA FILE: ${files.singleOrNull()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CompilerParameters(
|
||||||
|
private val home: KotlinNativeHome,
|
||||||
|
private val compilerArgs: Array<String>,
|
||||||
|
private val environment: JVMEnvironment = JVMEnvironment() // Capture environment.
|
||||||
|
) : LoggedData() {
|
||||||
override fun computeText() = buildString {
|
override fun computeText() = buildString {
|
||||||
appendArguments("COMPILER ARGUMENTS:", listOf(home.dir.resolve("bin/kotlinc-native").path) + compilerArgs)
|
appendArguments("COMPILER ARGUMENTS:", listOf(home.dir.resolve("bin/kotlinc-native").path) + compilerArgs)
|
||||||
appendLine()
|
appendLine()
|
||||||
appendLine(environment)
|
appendLine(environment)
|
||||||
|
|
||||||
val testDataFiles = testDataFiles
|
|
||||||
if (testDataFiles.isNotEmpty()) {
|
|
||||||
appendLine()
|
|
||||||
appendList("TEST DATA FILES (COMPILED TOGETHER):", testDataFiles)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +109,7 @@ internal abstract class LoggedData {
|
|||||||
|
|
||||||
class CompilationToolCall(
|
class CompilationToolCall(
|
||||||
private val toolName: String,
|
private val toolName: String,
|
||||||
|
private val input: LoggedData?,
|
||||||
private val parameters: LoggedData,
|
private val parameters: LoggedData,
|
||||||
val exitCode: ExitCode,
|
val exitCode: ExitCode,
|
||||||
val toolOutput: String,
|
val toolOutput: String,
|
||||||
@@ -113,6 +123,8 @@ internal abstract class LoggedData {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return buildString {
|
return buildString {
|
||||||
|
input?.let(::appendLine)
|
||||||
|
|
||||||
if (problems.isNotEmpty()) {
|
if (problems.isNotEmpty()) {
|
||||||
appendLine("$toolName PROBLEMS:")
|
appendLine("$toolName PROBLEMS:")
|
||||||
problems.forEach(::appendLine)
|
problems.forEach(::appendLine)
|
||||||
|
|||||||
+12
-3
@@ -89,7 +89,8 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
|
|||||||
applySources()
|
applySources()
|
||||||
}
|
}
|
||||||
|
|
||||||
val loggedCompilerParameters = LoggedData.CompilerParameters(home, compilerArgs, sourceModules)
|
val loggedCompilerInput = LoggedData.CompilerInput(sourceModules)
|
||||||
|
val loggedCompilerParameters = LoggedData.CompilerParameters(home, compilerArgs)
|
||||||
|
|
||||||
val (loggedCompilerCall: LoggedData, result: TestCompilationResult.ImmediateResult<out A>) = try {
|
val (loggedCompilerCall: LoggedData, result: TestCompilationResult.ImmediateResult<out A>) = try {
|
||||||
val compilerToolCallResult = when (compilerOutputInterceptor) {
|
val compilerToolCallResult = when (compilerOutputInterceptor) {
|
||||||
@@ -105,8 +106,15 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
|
|||||||
|
|
||||||
val (exitCode, compilerOutput, compilerOutputHasErrors, duration) = compilerToolCallResult
|
val (exitCode, compilerOutput, compilerOutputHasErrors, duration) = compilerToolCallResult
|
||||||
|
|
||||||
val loggedCompilationToolCall =
|
val loggedCompilationToolCall = LoggedData.CompilationToolCall(
|
||||||
LoggedData.CompilationToolCall("COMPILER", loggedCompilerParameters, exitCode, compilerOutput, compilerOutputHasErrors, duration)
|
"COMPILER",
|
||||||
|
loggedCompilerInput,
|
||||||
|
loggedCompilerParameters,
|
||||||
|
exitCode,
|
||||||
|
compilerOutput,
|
||||||
|
compilerOutputHasErrors,
|
||||||
|
duration
|
||||||
|
)
|
||||||
|
|
||||||
val result = if (exitCode != ExitCode.OK || compilerOutputHasErrors)
|
val result = if (exitCode != ExitCode.OK || compilerOutputHasErrors)
|
||||||
TestCompilationResult.CompilationToolFailure(loggedCompilationToolCall)
|
TestCompilationResult.CompilationToolFailure(loggedCompilationToolCall)
|
||||||
@@ -282,6 +290,7 @@ internal class CInteropCompilation(
|
|||||||
|
|
||||||
val loggedInteropCall = LoggedData.CompilationToolCall(
|
val loggedInteropCall = LoggedData.CompilationToolCall(
|
||||||
toolName = "CINTEROP",
|
toolName = "CINTEROP",
|
||||||
|
input = null,
|
||||||
parameters = loggedCInteropParameters,
|
parameters = loggedCInteropParameters,
|
||||||
exitCode = exitCode,
|
exitCode = exitCode,
|
||||||
toolOutput = cinteropOutput,
|
toolOutput = cinteropOutput,
|
||||||
|
|||||||
Reference in New Issue
Block a user