-
Notifications
You must be signed in to change notification settings - Fork 73
Switch output dependency from TAP to Teamcity #237
Conversation
…ing ---teamcity flag) Checkout output on all scenarios just to be sure nothing else bugs out the output
Tests have a single failure which seems to have crept in via a possible PHPUnit bug from PHPUnit 5.2.0 onwards. I'm not sure if it's expected or not, but I've reported it here: sebastianbergmann/phpunit#2665 If the outcome is something expected/deprecated or otherwise not to be fixed, I'll scrub the offending test. |
@padraic I was wondering if it might make sense to have adapters for each logging format, so to avoid couple the implementation to a specific one and be able to swap between them more easily. |
@omissis That makes sense. There was a reason originally for the tight coupling, but that's no longer an issue. |
@humbug/core Ready for review here now. There is one test now marked skipped - against the old PHPUnit suite assembly method using AllTests.php files. Can't quite find it documented in the PHPUnit changelog, but Sebastian certainly doesn't consider this a supported feature anymore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a first review, there's some questions for you :)
src/ProcessRunner.php
Outdated
$process->stop(); | ||
return; | ||
$hasFailure = true; | ||
//$process->stop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the comments?
<directory>.</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing ending blank line
Stdout: | ||
> TAP version 13 | ||
> not ok 1 - Error: FooTest::testAddsNumbers | ||
##teamcity[testFailed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we no longer get to know where it's failing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The teamcity block will have it - but the block varies between test runs, so I just checked that it was output for the scenario..
src/Renderer/Text.php
Outdated
|
||
protected function extractFail($output) | ||
{ | ||
$result = preg_match('%##teamcity\[testFailed.*\]%', $output, $matches); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (preg_match('%##teamcity\[testFailed.*\]%', $output, $matches)) {
return $matches[0];
}
return 'No failure output was detected by Humbug, but a failure was reported by PHPUnit.';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also be simplified by a ternary operator
src/Renderer/Text.php
Outdated
@@ -316,4 +316,13 @@ protected function headAndTail($output, $lineCount = 20, $omittedMarker = '[...M | |||
array_slice($lines, -$lineCount, $lineCount) | |||
)); | |||
} | |||
|
|||
protected function extractFail($output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make it private?
src/Adapter/AdapterAbstract.php
Outdated
&& !preg_match("%# TODO%", $line)) { | ||
return false; | ||
} | ||
if (preg_match("%##teamcity\[testFailed%", $output)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (bool) preg_match("%##teamcity\[testFailed%", $output);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to watch the casting to bool with preg_match - that's why I prefer taking the scenic route ;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but isn't it what is done with the if statement? Too me both look strictly equivalent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the short version that would work (excl. errors which return FALSE):
return 0 === preg_match("%##teamcity\[testFailed%", $output);
Added via commit just now.
tests/Adapter/PhpunitTest.php
Outdated
$this->assertTrue($adapter->ok($result)); | ||
} | ||
|
||
public function testAdapterRunsPhpunitCommandWithAlltestsFileTarget() | ||
{ | ||
$this->markTestSkipped('See https://github.com/sebastianbergmann/phpunit/issues/2665'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this issue has been closed and that we shouldn't run that test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True - test should actually be deleted now.
src/Adapter/AdapterAbstract.php
Outdated
if ($result) { | ||
return (int) end($matches[1]); | ||
$this->okCount += $result; | ||
return $this->okCount; // was: (int) end($matches[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect a has* method to always return a boolean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably should, and it's a public method to boot, but something we can clean up with greater forethought for 2.0 when defining interfaces/extension points.
@theofidry Some changes made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last nitpicking, all good for me otherwise
src/Adapter/AdapterAbstract.php
Outdated
&& !preg_match("%# TODO%", $line)) { | ||
return false; | ||
} | ||
if (preg_match("%##teamcity\[testFailed%", $output)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but isn't it what is done with the if statement? Too me both look strictly equivalent
@theofidry In case my comment was lost in changing that, I updated the preg_match block to return 0 === preg_match("%##teamcity\[testFailed%", $output); |
Just some simple changes. I disabled early termination of the ProcessRunner since it shouldn't be needed if we are telling PHPUnit to stop on first failure (via command line option), and it ends up truncating the failure messages when we do it manually.
However, I think the
\Humbug\ProcessRunner
needs a bit of attention beyond this. I've commented out lines, and there seems to some interference when underlying unit-under-test is also using processes. You can spot it by attempting to use Humbug on https://github.com/Seldaek/monolog (for example). The failure between Humbug, and running PHPUnit straight on Monolog, are very different, but you can switch failures by manipulating the ProcessRunner. This was happening WITHOUT my changes, so it's a separate pre-existing issue.Anyways, will add tests and such over next day or so.