[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(
|
||||
private val home: KotlinNativeHome,
|
||||
private val compilerArgs: Array<String>,
|
||||
private val sourceModules: Collection<TestModule>,
|
||||
private val environment: JVMEnvironment = JVMEnvironment() // Capture environment.
|
||||
) : LoggedData() {
|
||||
class CompilerInput(private val sourceModules: Collection<TestModule>) : LoggedData() {
|
||||
private val testDataFiles: List<File>
|
||||
get() = buildList {
|
||||
sourceModules.forEach { module ->
|
||||
@@ -68,16 +63,30 @@ internal abstract class LoggedData {
|
||||
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 {
|
||||
appendArguments("COMPILER ARGUMENTS:", listOf(home.dir.resolve("bin/kotlinc-native").path) + compilerArgs)
|
||||
appendLine()
|
||||
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(
|
||||
private val toolName: String,
|
||||
private val input: LoggedData?,
|
||||
private val parameters: LoggedData,
|
||||
val exitCode: ExitCode,
|
||||
val toolOutput: String,
|
||||
@@ -113,6 +123,8 @@ internal abstract class LoggedData {
|
||||
)
|
||||
|
||||
return buildString {
|
||||
input?.let(::appendLine)
|
||||
|
||||
if (problems.isNotEmpty()) {
|
||||
appendLine("$toolName PROBLEMS:")
|
||||
problems.forEach(::appendLine)
|
||||
|
||||
+12
-3
@@ -89,7 +89,8 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
|
||||
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 compilerToolCallResult = when (compilerOutputInterceptor) {
|
||||
@@ -105,8 +106,15 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
|
||||
|
||||
val (exitCode, compilerOutput, compilerOutputHasErrors, duration) = compilerToolCallResult
|
||||
|
||||
val loggedCompilationToolCall =
|
||||
LoggedData.CompilationToolCall("COMPILER", loggedCompilerParameters, exitCode, compilerOutput, compilerOutputHasErrors, duration)
|
||||
val loggedCompilationToolCall = LoggedData.CompilationToolCall(
|
||||
"COMPILER",
|
||||
loggedCompilerInput,
|
||||
loggedCompilerParameters,
|
||||
exitCode,
|
||||
compilerOutput,
|
||||
compilerOutputHasErrors,
|
||||
duration
|
||||
)
|
||||
|
||||
val result = if (exitCode != ExitCode.OK || compilerOutputHasErrors)
|
||||
TestCompilationResult.CompilationToolFailure(loggedCompilationToolCall)
|
||||
@@ -282,6 +290,7 @@ internal class CInteropCompilation(
|
||||
|
||||
val loggedInteropCall = LoggedData.CompilationToolCall(
|
||||
toolName = "CINTEROP",
|
||||
input = null,
|
||||
parameters = loggedCInteropParameters,
|
||||
exitCode = exitCode,
|
||||
toolOutput = cinteropOutput,
|
||||
|
||||
Reference in New Issue
Block a user