Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow optional configuration of expected line endings for TAPTestEngine #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions tap_test_engine/src/TAPTestEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ final class TAPTestEngine extends ArcanistUnitTestEngine {
public function run() {
$projectRoot = $this->getWorkingCopy()->getProjectRoot();
$command = $this->getConfigurationManager()->getConfigFromAnySource('unit.engine.tap.command');
$eol = $this->getConfigurationManager()->getConfigFromAnySource(
'unit.engine.tap.eol'
);

/**
* Specifying line endings via config is optional, so default to PHP_EOL if not specified.
*/
if (!$eol) {
$eol = PHP_EOL;
}

$future = new ExecFuture($command);
$future->setCWD(Filesystem::resolvePath($projectRoot));
Expand All @@ -17,16 +27,16 @@ public function run() {
} while (!$future->isReady());

list($error, $stdout, $stderr) = $future->resolve();
return $this->parseOutput($stdout);
return $this->parseOutput($stdout, $eol);
}

public function shouldEchoTestResults() {
return true;
}

private function parseOutput($output) {
private function parseOutput($output, $eol) {
$results = array();
$lines = explode(PHP_EOL, $output);
$lines = explode($eol, $output);

foreach($lines as $index => $line) {
preg_match('/^(not ok|ok)\s+\d+\s+-?(.*)/', $line, $matches);
Expand Down