mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 00:42:40 +01:00
arc unit --output none
Summary: Support for no output from arc unit (For scripts, etc). Also include --output param, analogous to arc lint --output. Test Plan: run all 6 variants + `--output bad-value` Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D6642
This commit is contained in:
parent
5b69749812
commit
d54f0f69d4
1 changed files with 45 additions and 9 deletions
|
@ -72,6 +72,18 @@ EOTEXT
|
||||||
'json' => array(
|
'json' => array(
|
||||||
'help' => 'Report results in JSON format.',
|
'help' => 'Report results in JSON format.',
|
||||||
),
|
),
|
||||||
|
'output' => array(
|
||||||
|
'param' => 'format',
|
||||||
|
'help' =>
|
||||||
|
"With 'full', show full pretty report (Default). ".
|
||||||
|
"With 'json', report results in JSON format. ".
|
||||||
|
"With 'ugly', use uglier (but more efficient) JSON formatting. ".
|
||||||
|
"With 'none', don't print results. ",
|
||||||
|
'conflicts' => array(
|
||||||
|
'json' => 'Only one output format allowed',
|
||||||
|
'ugly' => 'Only one output format allowed',
|
||||||
|
)
|
||||||
|
),
|
||||||
'everything' => array(
|
'everything' => array(
|
||||||
'help' => 'Run every test.',
|
'help' => 'Run every test.',
|
||||||
'conflicts' => array(
|
'conflicts' => array(
|
||||||
|
@ -162,9 +174,9 @@ EOTEXT
|
||||||
|
|
||||||
$console = PhutilConsole::getConsole();
|
$console = PhutilConsole::getConsole();
|
||||||
|
|
||||||
$json_output = $this->getArgument('json');
|
$output_format = $this->getOutputFormat();
|
||||||
|
|
||||||
if ($json_output) {
|
if ($output_format !== 'full') {
|
||||||
$console->disableOut();
|
$console->disableOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,17 +264,24 @@ EOTEXT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($json_output) {
|
if ($output_format !== 'full') {
|
||||||
$console->enableOut();
|
$console->enableOut();
|
||||||
|
}
|
||||||
$data = array_values(mpull($results, 'toDictionary'));
|
$data = array_values(mpull($results, 'toDictionary'));
|
||||||
|
switch ($output_format) {
|
||||||
if ($this->getArgument('ugly')) {
|
case 'ugly':
|
||||||
$console->writeOut('%s', json_encode($data));
|
$console->writeOut('%s', json_encode($data));
|
||||||
} else {
|
break;
|
||||||
|
case 'json':
|
||||||
$json = new PhutilJSON();
|
$json = new PhutilJSON();
|
||||||
$console->writeOut('%s', $json->encodeFormatted($data));
|
$console->writeOut('%s', $json->encodeFormatted($data));
|
||||||
}
|
break;
|
||||||
|
case 'full':
|
||||||
|
// already printed
|
||||||
|
break;
|
||||||
|
case 'none':
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $overall_result;
|
return $overall_result;
|
||||||
|
@ -316,4 +335,21 @@ EOTEXT
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getOutputFormat() {
|
||||||
|
if ($this->getArgument('ugly')) {
|
||||||
|
return 'ugly';
|
||||||
|
}
|
||||||
|
if ($this->getArgument('json')) {
|
||||||
|
return 'json';
|
||||||
|
}
|
||||||
|
$format = $this->getArgument('output');
|
||||||
|
$known_formats = array(
|
||||||
|
'none' => 'none',
|
||||||
|
'json' => 'json',
|
||||||
|
'ugly' => 'ugly',
|
||||||
|
'full' => 'full',
|
||||||
|
);
|
||||||
|
return idx($known_formats, $format, 'full');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue