-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Code location hints for PHPT and @requires #3467
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
Code location hints for PHPT and @requires #3467
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3467 +/- ##
============================================
+ Coverage 82.63% 82.88% +0.25%
- Complexity 3616 3636 +20
============================================
Files 144 144
Lines 9437 9513 +76
============================================
+ Hits 7798 7885 +87
+ Misses 1639 1628 -11
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #3467 +/- ##
============================================
+ Coverage 82.63% 82.88% +0.25%
- Complexity 3616 3638 +22
============================================
Files 144 144
Lines 9437 9517 +80
============================================
+ Hits 7798 7888 +90
+ Misses 1639 1629 -10
Continue to review full report at Codecov.
|
@requires
docblocks
@sebastianbergmann While experimenting with test collections I ended up with a bunch of regexes, shell scripts and too many tabs open. This pull request is the result of consolidating the scripts into a clean way to add new code location hints to the verbose stack traces. The whitespace visualization together with new code hints is a really nice help when debugging end-to-end tests, like the loggers. I will refine it further in future pull requests for the Basic test suite. The new test duration format makes the colored testdox quieter and easier to read; no more lists of random Have a look and let me know if you see anything that needs work. |
@sebastianbergmann Ah well, I found a missing case. For some reason I'll have working code hints for that scenario via a workaround soon, but any insight into what's going on would be great. From if ($e instanceof ExpectationFailedException) {
/** @var ExpectationFailedException $e */
if ($e->getComparisonFailure()) {
$diff = $e->getComparisonFailure()->getDiff();
} else {
$diff = $e->getMessage();
}
$hint = $this->getLocationHintFromDiff($diff, $sections);
$trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
\array_unshift($trace, $hint);
$failure = new PHPTAssertionFailedError($e->getMessage(), 0, $trace[0]['file'], $trace[0]['line'], $trace);
// \print_r(['hint' => $hint]);
} |
New functionality
Implemented code location hints for:
--SKIPIF--
--EXPECT--
,--EXPECTF--
and--EXPECTREGEX--
--{SECTION}_EXTERNAL--
sections@requires
-annotations intestMethod
docblocksWhen a test gets marked skipped due to missing requirements PHPUnit will search through the relevant sections and annotations. For failing end-to-end tests it will try to locate the source of the problem in the
$expected
definition.For unit tests the system uses metadata already available as a performance trade-off and can miss the exact line due to empty lines between docblocks and method definitions. This rarely happens as coding style fixers clean this scenario up.
For PHPT, the already parsed sections are searched for the exception message instead of trying to analyse the code in the sections. External files are reported to the user but not scanned for exact line numbers to keep it fast.
Misc improvements
basic
test collection (À tout de suite: fast self-test suite #3453) is already in use to test--debug
@testdox
descriptionsExamples
Unit tests
PHPT
--SKIPIF--
Output in IntelliJ / PHPStorm with
--teamcity
option