Page MenuHomePhabricator

Pytest engine should not execute "coverage" if --no-coverage flag is provided.
Open, Needs TriagePublic

Description

Steps to Reproduce:

  • Correctly set up a repository which contains a python project to work with arcanist.
  • Ensure py.test --junit-xml=my_test_output executes tests appropriately.
  • Ensure arcanist source is correctly liberated.
  • Modify .arcconfig to include the following:
{
  ...
  "load": [
    "path/to/arcanist/src
  ],
  "unit.engine": "PytestTestEngine"
}
  • Execute arc unit --no-coverage

Expected Result:

  • arcanist loads test engine library and calls PytestTestEngine's run method.
  • Test engine executes py.test
  • Test results are displayed in terminal.
  • No coverage information is displayed.

Actual Result:

  • arcanist loads test engine library and calls PytestTestEngine's run method.
  • No test results are displayed.
  • Even though --no-coverage was used, an exception about the coverage command is raised:
Exception
Command failed with error #127!
COMMAND
coverage xml -o '/private/var/folders/08/rbqy5jmn1rj8dv_4df5s9clw0000gn/T/5siiwl87brk8gg8c/7232-aMOGIU'

STDOUT
(empty)

STDERR
sh: coverage: command not found

Steps to Fix:

Modify PytestTestEngine at line 30 to make execution of coverage command conditional.
Current:

public function run() {
  ...
  $future = new ExecFuture('coverage xml -o %s', $cover_tmp);
  $future->setCWD($this->projectRoot);
  $future->resolvex();

  return $this->parseTestResults($junit_tmp, $cover_tmp);
}

Correct:

public function run() {
  ...
  if ($this->getEnableCoverage() !== false) { 
    $future = new ExecFuture('coverage xml -o %s', $cover_tmp);
    $future->setCWD($this->projectRoot);
    $future->resolvex();
  }

  return $this->parseTestResults($junit_tmp, $cover_tmp);
}