private $console;
private $hasWarnedExternals = false;
private $unresolvedLint;
- private $lintExcuse;
- private $unitExcuse;
+ private $excuses = array('lint' => null, 'unit' => null);
private $testResults;
private $diffID;
private $revisionID;
if ($background) {
$server = new PhutilConsoleServer();
$server->addExecFutureClient($lint_unit);
+ $server->setHandler(array($this, 'handleServerMessage'));
$server->run();
list($err) = $lint_unit->resolve();
return 1;
}
} else {
+ $server = $this->console->getServer();
+ $server->setHandler(array($this, 'handleServerMessage'));
$data = $this->runLintUnit();
}
$lint_result = $data['lintResult'];
- $this->lintExcuse = $data['lintExcuse'];
$this->unresolvedLint = $data['unresolvedLint'];
$this->postponedLinters = $data['postponedLinters'];
$unit_result = $data['unitResult'];
- $this->unitExcuse = $data['unitExcuse'];
$this->testResults = $data['testResults'];
$changes = $this->generateChanges();
$unit_result = $this->runUnit();
return array(
'lintResult' => $lint_result,
- 'lintExcuse' => $this->lintExcuse,
'unresolvedLint' => $this->unresolvedLint,
'postponedLinters' => $this->postponedLinters,
'unitResult' => $unit_result,
- 'unitExcuse' => $this->unitExcuse,
'testResults' => $this->testResults,
);
}
"<bg:green>** LINT OKAY **</bg> No lint problems.\n");
break;
case ArcanistLintWorkflow::RESULT_WARNINGS:
- $this->lintExcuse = $this->getErrorExcuse(
+ $this->getErrorExcuse(
+ 'lint',
"Lint issued unresolved warnings.",
'lint-excuses');
break;
case ArcanistLintWorkflow::RESULT_ERRORS:
$this->console->writeOut(
"<bg:red>** LINT ERRORS **</bg> Lint raised errors!\n");
- $this->lintExcuse = $this->getErrorExcuse(
+ $this->getErrorExcuse(
+ 'lint',
"Lint issued unresolved errors!",
'lint-excuses');
break;
case ArcanistUnitWorkflow::RESULT_FAIL:
$this->console->writeOut(
"<bg:red>** UNIT ERRORS **</bg> Unit testing raised errors!\n");
- $this->unitExcuse = $this->getErrorExcuse(
+ $this->getErrorExcuse(
+ 'unit',
"Unit test results include failures!",
'unit-excuses');
break;
return $this->testResults;
}
- private function getErrorExcuse($prompt, $history) {
+ private function getErrorExcuse($type, $prompt, $history) {
if ($this->getArgument('excuse')) {
$prompt .= " Ignore them?";
if (!$this->console->confirm($prompt)) {
throw new ArcanistUserAbortException();
}
- return $this->getArgument('excuse');
+ $this->excuses[$type] = $this->getArgument('excuse');
+ return;
}
$history = $this->getRepositoryAPI()->getScratchFilePath($history);
$prompt .= " Provide explanation to continue or press Enter to abort.";
$this->console->writeOut("\n\n%s", phutil_console_wrap($prompt));
- $return = $this->console->prompt("Explanation:", $history);
- if ($return == '') {
+ $this->console->sendMessage(array(
+ 'type' => $type,
+ 'prompt' => "Explanation:",
+ 'history' => $history,
+ ));
+ }
+
+ public function handleServerMessage(PhutilConsoleMessage $message) {
+ $data = $message->getData();
+ $response = phutil_console_prompt($data['prompt'], idx($data, 'history'));
+ if ($response == '') {
throw new ArcanistUserAbortException();
}
- return $return;
+ $this->excuses[$data['type']] = $response;
+ return null;
}
if ($this->unresolvedLint) {
$this->updateDiffProperty('arc:lint', json_encode($this->unresolvedLint));
- if (strlen($this->lintExcuse)) {
+ if (strlen($this->excuses['lint'])) {
$this->updateDiffProperty('arc:lint-excuse',
- json_encode($this->lintExcuse));
+ json_encode($this->excuses['lint']));
}
}
}
$this->updateDiffProperty('arc:unit', json_encode($this->testResults));
- if (strlen($this->unitExcuse)) {
+ if (strlen($this->excuses['unit'])) {
$this->updateDiffProperty('arc:unit-excuse',
- json_encode($this->unitExcuse));
+ json_encode($this->excuses['unit']));
}
}