Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistUnitWorkflow.php
| Show All 17 Lines | return $this->newWorkflowInformation() | ||||
| ->addExample(pht('**unit** [__options__] --commit __commit__')) | ->addExample(pht('**unit** [__options__] --commit __commit__')) | ||||
| ->setHelp($help); | ->setHelp($help); | ||||
| } | } | ||||
| public function getWorkflowArguments() { | public function getWorkflowArguments() { | ||||
| return array( | return array( | ||||
| $this->newWorkflowArgument('commit') | $this->newWorkflowArgument('commit') | ||||
| ->setParameter('commit'), | ->setParameter('commit'), | ||||
| $this->newWorkflowArgument('format') | $this->newWorkflowArgument('sink') | ||||
| ->setParameter('format'), | ->setParameter('format'), | ||||
| $this->newWorkflowArgument('everything'), | $this->newWorkflowArgument('everything'), | ||||
| $this->newWorkflowArgument('paths') | $this->newWorkflowArgument('paths') | ||||
| ->setWildcard(true), | ->setWildcard(true), | ||||
| // TOOLSETS: Restore "--target". | // TOOLSETS: Restore "--target". | ||||
| ); | ); | ||||
| } | } | ||||
| Show All 11 Lines | public function runWorkflow() { | ||||
| $overseer = id(new ArcanistUnitOverseer()) | $overseer = id(new ArcanistUnitOverseer()) | ||||
| ->setDirectory($directory); | ->setDirectory($directory); | ||||
| // TOOLSETS: For now, we're treating every invocation of "arc unit" as | // TOOLSETS: For now, we're treating every invocation of "arc unit" as | ||||
| // though it is "arc unit --everything", and ignoring the "--commit" flag | // though it is "arc unit --everything", and ignoring the "--commit" flag | ||||
| // and "paths" arguments. | // and "paths" arguments. | ||||
| $formatter = $this->newUnitFormatter(); | $sinks = array(); | ||||
| $overseer->setFormatter($formatter); | $sinks[] = $this->newUnitSink(); | ||||
| $overseer->setSinks($sinks); | |||||
| $overseer->execute(); | $overseer->execute(); | ||||
| foreach ($sinks as $sink) { | |||||
| $result = $sink->getOutput(); | |||||
| if ($result !== null) { | |||||
| echo $result; | |||||
| } | |||||
| } | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| private function newUnitFormatter() { | private function newUnitSink() { | ||||
| $formatters = ArcanistUnitFormatter::getAllUnitFormatters(); | $sinks = ArcanistUnitSink::getAllUnitSinks(); | ||||
| $format_key = $this->getArgument('format'); | $sink_key = $this->getArgument('sink'); | ||||
| if (!strlen($format_key)) { | if (!strlen($sink_key)) { | ||||
| $format_key = ArcanistDefaultUnitFormatter::FORMATTER_KEY; | $sink_key = ArcanistDefaultUnitSink::SINKKEY; | ||||
| } | } | ||||
| $formatter = idx($formatters, $format_key); | $sink = idx($sinks, $sink_key); | ||||
| if (!$formatter) { | if (!$sink) { | ||||
| throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
| pht( | pht( | ||||
| 'Unit test output format ("%s") is unknown. Supported formats '. | 'Unit test output sink ("%s") is unknown. Supported sinks '. | ||||
| 'are: %s.', | 'are: %s.', | ||||
| $format_key, | $sink_key, | ||||
| implode(', ', array_keys($formatters)))); | implode(', ', array_keys($sinks)))); | ||||
| } | } | ||||
| return $formatter; | return $sink; | ||||
| } | } | ||||
| } | } | ||||