Repository: JetBrains/kotlin
File: libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativePerformanceTask.kt (Kotlin)

Code before:

    // Get compile task and associated with it other compile tasks.
    private fun getAllExecutedTasks(compilation: KotlinCompilation<*>): List<Task> {
        val tasks = mutableListOf(compilation.compileKotlinTask as Task)
        compilation.associateWith.forEach {
            tasks += getAllExecutedTasks(it)
        }
        return tasks
    }

    @TaskAction
    fun generate() {
        val compileTasks = if (settings.includeAssociatedTasks)
            getAllExecutedTasks(binary.linkTask.compilation)
        else
            listOf(binary.linkTask.compilation.compileKotlinTask)
        val allExecutedTasks = listOf(binary.linkTask) + compileTasks
        val upToDateTasks = allExecutedTasks.filter { it.state.upToDate }.map { it.name }.joinToString("\n", "- ")
        if (upToDateTasks.isEmpty()) {
            if (reportDirectory.exists()) {
                project.delete(reportDirectory.absolutePath)
            }
            project.logger.warn("Next compile tasks which are needed for time measurement are upToDate and weren't executed:\n${upToDateTasks}")
            return
        }
        val successStatus = allExecutedTasks.map { it.state.failure == null }.reduce { acc, it -> acc && it }
        // Get code size metric.
        var codeSize: String? = null
        if (TrackableMetric.CODE_SIZE in settings.metrics) {
            codeSize = binary.outputFile.let {
                if (it.exists()) "CODE_SIZE ${it.length()}" else null
            }
        }
        // Get compile time.
        var compileTime: String? = null
        if (TrackableMetric.COMPILE_TIME in settings.metrics) {
            compileTime = getCompilationResults(
                allExecutedTasks.map { it.path },
                successStatus
            )
        }

        // Create report.
        if (!reportDirectory.exists()) {
            project.mkdir(reportDirectory.absolutePath)
        }
        val name = settings.binaryNamesForReport[binary]!!
        outputFile.writeText(name)
        if (compileTime != null) {
            outputFile.appendText("\n$compileTime")
        }

Review comment (bug):
```suggestion
        val successStatus = allExecutedTasks.all { it.state.failure == null }
```

Code after:

    // Get compile task and associated with it other compile tasks.
    private fun getAllExecutedTasks(compilation: KotlinCompilation<*>): List<Task> {
        val tasks = mutableListOf(compilation.compileKotlinTask as Task)
        compilation.associateWith.forEach {
            tasks += getAllExecutedTasks(it)
        }
        return tasks
    }

    @TaskAction
    fun generate() {
        val compileTasks = if (settings.includeAssociatedTasks)
            getAllExecutedTasks(binary.linkTask.compilation)
        else
            listOf(binary.linkTask.compilation.compileKotlinTask)
        val allExecutedTasks = listOf(binary.linkTask) + compileTasks
        val upToDateTasks = allExecutedTasks.filter { it.state.upToDate }.map { it.name }
        if (upToDateTasks.isNotEmpty()) {
            if (outputFile.exists()) {
                project.delete(outputFile.absolutePath)
            }
            project.logger.warn("Next compile tasks which are needed for time measurement are upToDate" +
                                        " and weren't executed:\n${upToDateTasks.joinToString("\n", "- ")}")
            return
        }
        val successStatus = allExecutedTasks.all { it.state.failure == null }
        // Get code size metric.
        var codeSize: String? = null
        if (TrackableMetric.CODE_SIZE in settings.metrics) {
            codeSize = binary.outputFile.let {
                if (it.exists()) "CODE_SIZE ${it.length()}" else null
            }
        }
        // Get compile time.
        var compileTime: String? = null
        if (TrackableMetric.COMPILE_TIME in settings.metrics) {
            compileTime = getCompilationResults(
                allExecutedTasks.map { it.path },
                successStatus
            )
        }

        // Create report.
        if (!reportDirectory.exists()) {
            project.mkdir(reportDirectory.absolutePath)
        }
        val name = settings.binaryNamesForReport[binary]!!
        outputFile.writeText(name)
        if (compileTime != null) {
            outputFile.appendText("\n$compileTime")