diff --git a/src/workflow/ArcanistLintWorkflow.php b/src/workflow/ArcanistLintWorkflow.php index cd8cb8fc..89fd54bd 100644 --- a/src/workflow/ArcanistLintWorkflow.php +++ b/src/workflow/ArcanistLintWorkflow.php @@ -263,6 +263,8 @@ EOTEXT $all_autofix = true; + $console = PhutilConsole::getConsole(); + foreach ($results as $result) { $result_all_autofix = $result->isAllAutofix(); @@ -276,7 +278,7 @@ EOTEXT $lint_result = $renderer->renderLintResult($result); if ($lint_result) { - echo $lint_result; + $console->writeOut('%s', $lint_result); } if ($apply_patches && $result->isPatchable()) { @@ -294,12 +296,15 @@ EOTEXT // TODO: Improve the behavior here, make it more like // difference_render(). - passthru(csprintf("diff -u %s %s", $old_file, $new_file)); + list(, $stdout, $stderr) = + exec_manual("diff -u %s %s", $old_file, $new_file); + $console->writeOut('%s', $stdout); + $console->writeErr('%s', $stderr); $prompt = phutil_console_format( "Apply this patch to __%s__?", $result->getPath()); - if (!phutil_console_confirm($prompt, $default_no = false)) { + if (!$console->confirm($prompt, $default_no = false)) { continue; } } @@ -316,12 +321,12 @@ EOTEXT if ($this->shouldAmendWithoutPrompt || ($this->shouldAmendAutofixesWithoutPrompt && $all_autofix)) { - echo phutil_console_format( + $console->writeOut( "** LINT NOTICE ** Automatically amending HEAD ". "with lint patches.\n"); $amend = true; } else { - $amend = phutil_console_confirm("Amend HEAD with lint patches?"); + $amend = $console->confirm("Amend HEAD with lint patches?"); } if ($amend) { @@ -367,7 +372,7 @@ EOTEXT if (!$this->getParentWorkflow()) { if ($result_code == self::RESULT_OKAY) { - echo $renderer->renderOkayResult(); + $console->writeOut('%s', $renderer->renderOkayResult()); } } diff --git a/src/workflow/ArcanistUnitWorkflow.php b/src/workflow/ArcanistUnitWorkflow.php index 8666e63f..fe28b754 100644 --- a/src/workflow/ArcanistUnitWorkflow.php +++ b/src/workflow/ArcanistUnitWorkflow.php @@ -163,6 +163,8 @@ EOTEXT '** POSTPONED **'), ); + $console = PhutilConsole::getConsole(); + $unresolved = array(); $coverage = array(); $postponed_count = 0; @@ -173,15 +175,18 @@ EOTEXT $unresolved[] = $result; } else { if ($this->engine->shouldEchoTestResults()) { - echo ' '.$status_codes[$result_code]; + $duration = ''; if ($result_code == ArcanistUnitTestResult::RESULT_PASS) { - echo ' '.self::formatTestDuration($result->getDuration()); + $duration = ' '.self::formatTestDuration($result->getDuration()); } - echo ' '.$result->getName()."\n"; + $console->writeOut( + " %s %s\n", + $status_codes[$result_code].$duration, + $result->getName()); } if ($result_code != ArcanistUnitTestResult::RESULT_PASS) { if ($this->engine->shouldEchoTestResults()) { - echo $result->getUserData()."\n"; + $console->writeOut("%s\n", $result->getUserData()); } $unresolved[] = $result; } @@ -193,9 +198,10 @@ EOTEXT } } if ($postponed_count) { - echo sprintf("%s %s\n", - $status_codes[ArcanistUnitTestResult::RESULT_POSTPONED], - pht('%d test(s)', $postponed_count)); + $console->writeOut( + "%s %s\n", + $status_codes[ArcanistUnitTestResult::RESULT_POSTPONED], + pht('%d test(s)', $postponed_count)); } if ($coverage) { @@ -215,13 +221,11 @@ EOTEXT $file_coverage[$file] = $coverage; $file_reports[$file] = $report; } - echo "\n"; - echo phutil_console_format('__COVERAGE REPORT__'); - echo "\n"; + $console->writeOut("\n__COVERAGE REPORT__\n"); asort($file_coverage); foreach ($file_coverage as $file => $coverage) { - echo phutil_console_format( + $console->writeOut( " **%s%%** %s\n", sprintf('% 3d', (int)(100 * $coverage)), $file); @@ -230,9 +234,11 @@ EOTEXT if ($this->getArgument('detailed-coverage') && Filesystem::pathExists($full_path) && is_file($full_path)) { - echo $this->renderDetailedCoverageReport( - Filesystem::readFile($full_path), - $file_reports[$file]); + $console->writeOut( + '%s', + $this->renderDetailedCoverageReport( + Filesystem::readFile($full_path), + $file_reports[$file])); } } }