func printTestResults(state *core.BuildState, aggregatedResults core.TestResults, failedTargets []core.BuildLabel, duration float64) { if len(failedTargets) > 0 { for _, failed := range failedTargets { target := state.Graph.TargetOrDie(failed) if len(target.Results.Failures) == 0 { if target.Results.TimedOut { printf("${WHITE_ON_RED}Fail:${RED_NO_BG} %s ${WHITE_ON_RED}Timed out${RESET}\n", target.Label) } else { printf("${WHITE_ON_RED}Fail:${RED_NO_BG} %s ${WHITE_ON_RED}Failed to run test${RESET}\n", target.Label) } } else { printf("${WHITE_ON_RED}Fail:${RED_NO_BG} %s ${BOLD_GREEN}%3d passed ${BOLD_YELLOW}%3d skipped ${BOLD_RED}%3d failed ${BOLD_WHITE}Took %3.1fs${RESET}\n", target.Label, target.Results.Passed, target.Results.Skipped, target.Results.Failed, target.Results.Duration) for _, failure := range target.Results.Failures { printf("${BOLD_RED}Failure: %s in %s${RESET}\n", failure.Type, failure.Name) printf("%s\n", failure.Traceback) if len(failure.Stdout) > 0 { printf("${BOLD_RED}Standard output:${RESET}\n%s\n", failure.Stdout) } if len(failure.Stderr) > 0 { printf("${BOLD_RED}Standard error:${RESET}\n%s\n", failure.Stderr) } } } if len(target.Results.Output) > 0 { printf("${BOLD_RED}Full output:${RESET}\n%s\n", target.Results.Output) } if target.Results.Flakes > 0 { printf("${BOLD_MAGENTA}Flaky target; made %s before giving up${RESET}\n", pluralise(target.Results.Flakes, "attempt", "attempts")) } } } // Print individual test results i := 0 for _, target := range state.Graph.AllTargets() { if target.IsTest && target.Results.NumTests > 0 { if target.Results.Failed > 0 { printf("${RED}%s${RESET} %s\n", target.Label, testResultMessage(target.Results, failedTargets)) } else { printf("${GREEN}%s${RESET} %s\n", target.Label, testResultMessage(target.Results, failedTargets)) } if state.ShowTestOutput && target.Results.Output != "" { printf("Test output:\n%s\n", target.Results.Output) } i++ } } aggregatedResults.Duration = -0.1 // Exclude this from being displayed later. printf(fmt.Sprintf("${BOLD_WHITE}%s and %s${BOLD_WHITE}. Total time %0.2fs.${RESET}\n", pluralise(i, "test target", "test targets"), testResultMessage(aggregatedResults, failedTargets), duration)) }