Changeset View
Changeset View
Standalone View
Standalone View
src/unit/engine/PytestTestEngine.php
| <?php | <?php | ||||
| /** | /** | ||||
| * Very basic 'py.test' unit test engine wrapper. | * Very basic 'py.test' unit test engine wrapper. | ||||
| * | |||||
| * @group unitrun | |||||
| */ | */ | ||||
| final class PytestTestEngine extends ArcanistBaseUnitTestEngine { | final class PytestTestEngine extends ArcanistBaseUnitTestEngine { | ||||
| public function run() { | public function run() { | ||||
| $working_copy = $this->getWorkingCopy(); | $working_copy = $this->getWorkingCopy(); | ||||
| $this->project_root = $working_copy->getProjectRoot(); | $this->project_root = $working_copy->getProjectRoot(); | ||||
| $junit_tmp = new TempFile(); | $junit_tmp = new TempFile(); | ||||
| $cover_tmp = new TempFile(); | $cover_tmp = new TempFile(); | ||||
| $future = $this->buildTestFuture($junit_tmp, $cover_tmp); | $future = $this->buildTestFuture($junit_tmp, $cover_tmp); | ||||
| $future->resolvex(); | $future->resolvex(); | ||||
| $future = new ExecFuture('coverage xml -o %s', $cover_tmp); | $future = new ExecFuture('coverage xml -o %s', $cover_tmp); | ||||
| $future->setCWD($this->project_root); | $future->setCWD($this->project_root); | ||||
| $future->resolvex(); | $future->resolvex(); | ||||
| return $this->parseTestResults($junit_tmp, $cover_tmp); | return $this->parseTestResults($junit_tmp, $cover_tmp); | ||||
| } | } | ||||
| public function buildTestFuture($junit_tmp, $cover_tmp) { | public function buildTestFuture($junit_tmp, $cover_tmp) { | ||||
| $paths = $this->getPaths(); | $paths = $this->getPaths(); | ||||
| $cmd_line = csprintf('py.test --junitxml %s', | $cmd_line = csprintf('py.test --junitxml %s', $junit_tmp); | ||||
| $junit_tmp); | |||||
| if ($this->getEnableCoverage() !== false) { | if ($this->getEnableCoverage() !== false) { | ||||
| $cmd_line = csprintf('coverage run --source %s -m %C', | $cmd_line = csprintf( | ||||
| $this->project_root, $cmd_line); | 'coverage run --source %s -m %C', | ||||
| $this->project_root, | |||||
| $cmd_line); | |||||
| } | } | ||||
| return new ExecFuture('%C', $cmd_line); | return new ExecFuture('%C', $cmd_line); | ||||
| } | } | ||||
| public function parseTestResults($junit_tmp, $cover_tmp) { | public function parseTestResults($junit_tmp, $cover_tmp) { | ||||
| $parser = new ArcanistXUnitTestResultParser(); | $parser = new ArcanistXUnitTestResultParser(); | ||||
| $results = $parser->parseTestResults( | $results = $parser->parseTestResults( | ||||
| ▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | foreach ($classes as $class) { | ||||
| } | } | ||||
| } | } | ||||
| $reports[$relative_path] = $coverage; | $reports[$relative_path] = $coverage; | ||||
| } | } | ||||
| return $reports; | return $reports; | ||||
| } | } | ||||
| } | } | ||||