Problem/Motivation
run-tests.sh and its supporting classes predate the moves to PHPUnit (Simpletest was removed in Drupal 9, June 2020) and to GitLab (DrupalCI was discontinued in 2024), but are still pretty much bound to earlier constraints:
- skipped/incomplete tests are reported as passed as this was not a concept in Simpletest
- "PHPUnit errors" and "shell execution failures" are reported with the same error level
- PHPUnit returns detailed test duration data that is not reported
- --verbose mode is pretty much meaningless as there is no information about the actual test class/method executed
Proposed resolution
Fix all the above. Add some tests. Enjoy a refreshed test output log, until in the future a replacement to run-tests.sh (paratest?) will be suitable for Drupal.
Before/after screenshots
Test summary log
After the patch, each test run reports the count of skipped tests separately from the passed ones. Test run duration is moved to the leftmost position, and includes milliseconds.
Before

After

Detailed test results log
After the patch, each test case is reported with its execution status, full name and duration.
Before

After

Detailed test results w/failed test
After the patch, each test case is still reported with its execution status, full name and duration; passed tests are reported along the failed ones. The actual output of the spawned PHPUnit process is reported at the end of the test class.
Before

After

Remaining tasks
User interface changes
API changes
Data model changes
Original post
This is almost a bug, but I'll call it a task.
run-tests.sh can run PHPUnit-based tests.
However, it can't reflect that a test was skipped.
This is due to two factors:
1) simpletest (and thus run-tests.sh) doesn't have a concept of a skipped test.
2) When a PHPUnit test (< v.5) is skipped, only junit reports will give a clue, which is that the test doesn't pass, fail, or error out. (PHPUnit v.6 junit will tells us that a skip occurred.)
What run-tests.sh does with this is turn it into a pass, because nothing failed or errored out.
Since functional-javascript tests are skipped when phantomJS is not available, this means that tests run using run-tests.sh could look like they're passing when in fact they did not run.
Unfortunately, there doesn't seem to be an easy way to turn skipped tests into fails, without adding a test listener.
Thus, we should modify run-tests.sh to look for the special case of skipped so that users will know that their phantomJS-based tests did not pass because they didn't run.
Since we're doing that, we should work on risky and incomplete status, as well.
| Comment | File | Size | Author |
|---|---|---|---|
| #134 | after3.png | 405.67 KB | mondrake |
| #134 | after2.png | 275.85 KB | mondrake |
| #134 | after1.png | 449.73 KB | mondrake |
| #134 | before3.png | 517.22 KB | mondrake |
| #134 | before2.png | 266.18 KB | mondrake |
Issue fork drupal-2905007
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2905007-11.x
changes, plain diff MR !9027
- 2905007-allow-run-tests.sh-to
changes, plain diff MR !3605
Comments
Comment #2
mile23Comment #4
MixologicCant we add another status of "skipped" or something?
In a perfect world, I would have a way to run just the tests that derive from PHPUnit, and the ones that are simpletest tests separately.
Then, I would process the simpletest xml separately from the phpunit xml.
Comment #5
mile23It's interesting because PHPUnit doesn't report skipped tests either, in any structured way. You have to derive it from the missing status for the test. This wouldn't be hard to account for, but you have to do the accounting for it.
For PHPUnit in Drupal core, we'd end up either writing a test runner/result printer that keeps track of the skips and stores them explicitly in the report, or have an interpreter for CI to use to deduce the skips.
For simpletest there's also this one: #1273478: Implement @requires and @dependencies within TestBase, mark tests as skipped That issue hints at being able to account for skipped tests in the database that run-tests.sh uses for results.
Separating out PHPUnit and Simpletest test runs isn't a bad idea, but that means either figuring out how to do parallel testing in PHPUnit or modifying run-tests.sh to account for skips. So we can decide which is easier and do that. :-)
Comment #6
mile23simpletest.install says this in hook_schema():
That allows for 'skipped' but not 'incomplete.' We could say 'incplt' or something if we wanted to.
A JUnit report from PHPUnit 5 with a skipped test looks like this:
This class has 3 test methods. There is no way to deduce that the first test method (
testSetProvider()) was skipped, because there is no evidence that it exists. We'd then consult the JSON report for the same test:So here we see the skipped test marked as an error. We could then reconcile these two reports to figure out that the test was skipped.
But who wants to do that?
Given that we really don't, in order to store a record of a skipped test, either: PHPUnit adds
<skipped/>to its output: https://github.com/sebastianbergmann/phpunit/issues/2064...or we write our own test result printer which suits our needs. I can't find a third party library which has done this.
We could conceivably subclass
PHPUnit_Util_Log_JUnit::addSkippedTest()and use that as a report printer. This might conflict with our HTML output printer.So the list of tasks goes like this: Add this log printer in order to get good JUnit, figure out the conflict with HTML output printer, modify the simpletest JUnit->{simpletest} converstion to honor the new status messages, and modify the Simpletest UI to report skipped. Remember that
run-tests.sh --browseris the preferred way to get a useful verbose report from run-tests.sh, which is why we need to update Simpletest UI.If we did this, the JUnit reporter would be a good candidate for being a component. Other projects would benefit from reporting skipped tests in JUnit if upstream won't.
Comment #7
mile23Updating scope for #2907728-90: Installer: Convert system functional tests to phpunit because it's the same solution.
Comment #8
mile23BTW, this JUnit reporting problem goes away in PHPUnit 6.1:
Incomplete tests are marked as
<skipped/>, but still report on assertions. If the test is incomplete with no assertions in code, however, it'd be easy to confuse the two. We'd probably be safe making the mistake of assuming 0-assertion incomplete tests are skipped.A risky test gets a callout:
So we can look at error.type and figure out it's a risky test.
I suggest we not care about this until we abandon PHP 5 and normalize on PHPUnit 6.1+ because we don't want to support glue code for a PHPUnit version we're about to quit using.
Comment #9
MixologicIf you're suggesting, lets fix this, but only where it makes sense to, then yeah, +1.
skipped/risky is some valueable data to provide from a CI side because it might also help us solve issues like this one: #2065537: Test class without any methods silently ignored by testbot?
Comment #10
mile23OK then. Let's refactor the JUnit handling so that it's testable so that we can do this. I predict that #2641632: Refactor simpletest's *_phpunit_*() (and junit) functions etc. to a class, deprecate will not be committed before we drop PHP 5 support.
See also #2834033: Add a junit format to run-tests.sh
Comment #11
alexpott@Mile23 I think we should pursue catching skipped tests and risky tests now. Since we using PHPUnit 6 for the majority of Drupal 8 test runs now. It's only that the PHPUnit 4 based test runs won't error for this because patch testing is done on PHPUnit 6.
Comment #12
mile23That leaves us with two options:
1) Figure out how to deduce skipped tests under PHPUnit <6.
2) Not report skipped tests under PHPUnit <6.
(See #6, #8 for why.)
I think the latter is more reasonable, but is risky in its own way.
Either way the JUnit functions should be refactored into a testable helper class, and since we're doing that we might as well postpone on #2641632: Refactor simpletest's *_phpunit_*() (and junit) functions etc. to a class, deprecate where some of that work is already done.
That's why this issue was postponed in #10.
Comment #13
mile23WiP. Still needs some love for run-tests.sh to show you in the console that the test is skipped. Will add a load of unit tests.
Everything else pretty much works, just want the testbot to tell me where I'm wrong.
Comment #15
mile23Deprecates
simpletest_phpunit_xml_to_rows(),simpletest_phpunit_find_testcases(), andsimpletest_phpunit_testcase_to_row().Adds tests.
run-tests.sh now tells you how many tests were skipped or incomplete.
We're now using only the new converter, which is greatly simplified by using xpath.
Follow-up: Make run-tests.sh output JUnit and included skipped info: #2834033: Add a junit format to run-tests.sh
Comment #17
mile23Fixed CS, expanded some of the tests, hopefully fixed the fail from #15.
So now that the tests should all be passing in this patch, the next one will be time to hot-rod. It turns out xpath with an arbitrary location for an element is not all that performant. See the results from the timing test patch (23886 is the current number of tests in core according to the testbot):
Comment #18
mile23From the console log:
Hmm.....
Hello, TestBase! #1273478: Implement @requires and @dependencies within TestBase, mark tests as skipped
But also:
So that's nice.
Comment #19
mile23Now with fast:
'Recursive' in this report means porting over the recursive XML parsing from
simpletest_phpunit_find_testcases()rather than just usingxpath('.//testcase'). It turns outxpath()is faster, at least with PHP 7.1, and the main efficiency bottleneck was in determining the status and fail/error message.So:
We add the ability to show that tests are skipped or incomplete.
We improve performance (a little).
We factor JUnit handling away from the simpletest module, which comports to #2866082: [Plan] Roadmap for Simpletest and allows us to eventually deprecate that module.
We improve maintainability for JUnit handling code by allowing for greater testability and future expansion. Or eventual deprecation and removal, as needed.
Comment #20
mile23Should be elseif.
Replace contents with $element->xpath('.//testcase')
Comment #21
mile23Addresses #20, adds change record: https://www.drupal.org/node/2966954
Comment #22
dawehnerJust some quick review
Can we ensure to run this test in isolation?
You can use assertCount instead
Comment #23
mile23Thanks.
Addressed #22, added CR link to deprecation messages.
Comment #24
mile23Getting back to #4: "Then, I would process the simpletest xml separately from the phpunit xml."
OK, so that means we need to have a way to tell the testbot run_tests task how to process the different types of tests differently. Here's that issue for the testbot: #2943340: Process PHPUnit junit reports separately
It implies that we'll need to change run-tests.sh to support this kind of output. We might not even want to store results in a database for tests which will be reported in junit. That's all out of scope here.
Comment #25
mile23#23 test run for PHP 5.6 says things like this:
Resulting in about a zillion of these:
Not an issue in PHP 7.
Comment #26
mile23simpletest_phpunit_xml_to_rows()and the others are back to being in use but I've left them as annotated as @deprecated. They don't @trigger_error() and they're still in use, so we'll need a follow-up to remove usage and trigger errors.I think this is alright, since the plan is to remove their use when we drop support for PHP 5, but we still need them until then. IIRC that's in core 8.7.x, which I can't file an issue against at the moment.
If we shouldn't @deprecate now, that's fine, I'll change it here and we can do an issue against 8.7.x when that opens.
So basically:
simpletest_phpunit_xml_to_rows()looks to see which version of PHPUnit we're using, and uses the helper class if we're on PHPUnit 6+.This allows us to get info on skipped tests with relative ease, even though we miss out on this information from PHPUnit 4.
Comment #27
dawehnerWhat about changing the documentation of
simpletest_phpunit_testcase_to_rowto document that this is now for phpunit 5.5 only? Maybe this makes it a tiny little bit easier to understand what is going on.Comment #28
mile23Thanks, @dawehner
Added follow-up: #2968538: Remove usages, trigger error for deprecated simpletest JUnit functions when we stop using PHP 5
Amended CR. https://www.drupal.org/node/2966954
Changed deprecation message and added @todos to followup.
Comment #30
dww@berdir pointed me here in Slack. Thanks for all the progress so far! Sadly, this no longer applies to 8.7.x.
On 8.6.x, I'm using the CLI, not the simpletest UI. Patch works like a charm.
If I forgot to start or intentionally kill my chromedriver, run-tests.sh would silently pass all the FunctionalJavascript tests. Even when I put
$this->assertTrue(FALSE, 'this better fail');in the test function. ;)Before:
With #28 applied, I now see this:
I can't comment on the simpletest UI parts, but the CLI looks like a big win. This is a major WTF from my POV. Escalating this to a bug. Silently passing a whole set of tests is really, really evil. At least telling me all 6 test cases were skipped is a huge improvement.
Thanks @Mile23 for fixing this!
-Derek
Comment #31
mile23Reroll for 8.7.x.
Thanks, @dww.
All of this is about to get shuffled around: #3030136: The Fate Of Run-Tests.Sh
Comment #32
dwwThanks and thanks! Following the parent [meta] and The Fate issues now.
Cheers,
-Derek
Comment #34
mile23Tests passing.
Comment #35
alexpottI think this is being added back by mistake.
Comment #36
mile23Indeed, reverting to changes from #2932909: Convert web tests to browser tests for Simpletest module
Comment #38
mile23Patch still applies, moving to 8.7.x because it's a test improvement.
Comment #39
mile23Patch still applies, re-running test.
Comment #40
mile23This result chosen randomly from the console log:
Is marked incomplete:
And points to this issue left over from when jsonapi wasn't in core:
#2922121: When fetching related resources, getResourceType() in CurrentContext gets the wrong resource type.
Which is marked 'Closed (outdated)' in favor of:
#2941685: Port parameter based resource config from REST module
Which is closed without a follow-up, because no one ever dealt with the incomplete test because no one ever saw it.
Comment #41
mile23Comment #42
mondrakePatch still applies on 8.8.x, where's there's no longer PHP 5 nor PHPUnit 4. Skipped and incomplete tests are reported together, whereas risky ones just result as fails since #3059332: Mark kernel tests that perform no assertions as risky. What's left to RTBC here?
Comment #43
mondrakeI am working on trying to expose 'risky' and 'incomplete' test results separately.
Comment #44
mondrakeHmm, #43 is complicated... PHPUnit's
PHPUnit\Util\Log\JUnitreports 'skipped' and 'incomplete' tests in one and the same way viadoAddSkipped, and 'risky' ones as 'errors', so it's not straightforward to split them from the JUnit log. Actually @Mile23 already hit that in #8. I could not find ways to instruct PHPUnit to use a different class for JUnit reporting, any ideas?Comment #45
mile23The 'right' way is to implement a listener and then handle all the different test results however we want.
In one scenario our listener could write the results directly to the database, without having to parse JUnit. There are reasons this is a bad idea, including always having to provide a database in order to run tests when the listener is set. Which is always. Maybe worth it, maybe not.
In another scenario we'd subclass PHPUnit's JUnit listener and modify skipped/incomplete results in the XML DOM with our own special tag. In this way we could add a
<drupal_incomplete/>tag to the JUnit and then pay attention to it when we parse the results. This has the downside of maybe breaking tools which don't like arbitrary tags in XML, though I'm not sure this is really a factor. Just for the record here: There is no such thing as 'official' JUnit, tho we'd do well not to change it up.In another scenario we have our own logging file format that mimics the {simpletest} schema. Then we spit out this type of file in addition to JUnit, and then consume the new file type to add records to the database, or just consume the files for reporting instead of using the database.
And in the best of all possible worlds, we change the {simpletest} schema so it more closely mimics JUnit (with BC for Simpletest) and then we can throw away a bunch of JUnit conversion code. In this scenario, we will have begun to create a general-purpose parallel test runner that scales because it can use a database instead of file IO.
If anyone wants to undertake any of the radical ideas here, let me know and we'll sprint. Otherwise, sneaking a
<drupal_incomplete/>tag into the XML is probably the best way to do it until PHPUnit somehow makes this distinction on its own.Also, I won the bet in #10. :-)
Comment #46
mile23Closed #2968538: Remove usages, trigger error for deprecated simpletest JUnit functions when we stop using PHP 5 since we're already in a post-PHPUnit-4 world.
This patch deprecates and trigger_error()s functions in simpletest.module, and does some refactoring to support that. Adds tests for deprecations and BC.
This patch does NOT address #43, tho we should work on that if we think it's possible.
Comment #48
mile23Hopefully fixing the fails.
Comment #49
mondrakeThis is adding an additional test listener. It is c/p of the PHPUnit Junit logger - but without extending from
Printer. The listener accumulates the test run statistics, and on destruction flushes the XML file. 'risky', 'skipped' and 'incomplete' cases are all managed with an additionalmessageattribute in the<skipped>element of the DOM testcase element - that seems to be allowed in the specs https://llg.cubic.org/docs/junit/.No additional tests yet, nor changes to existing ones, so it will probably fail quite a lot...
Comment #51
mondrakeJust some progress.
Comment #52
mondrakeComment #54
mondrakeThis should account separately for 'incomplete' tests now. I increased the size of the
{simpletest}.statuscolumn to 12 to allow the text 'incomplete' to fit in.Comment #56
mile23Nice. Compare to #40 to see how much more clear this is.
Comment #57
mondrakeThe failure in #54 is very tricky -
Drupal\Tests\simpletest\Functional\SimpletestUiTest::testTestingThroughUIis a functional test testing that the simpletest UI performs correctly some tests. That means thatrun-test.shis called in multiple nesting, once while running the test itself, and once within the test to allow the simpletest form processing the sub-test. I'm quite sure this impacts the approach to pass the junit file path as an environment variable, but the hack I attempted have not been able to get it sorted so far. It's very difficult to try and pass dynamic variables to PHPUnit, unfortunately.Any idea?
Comment #58
mile23I'll give it a shot.
Comment #59
mondrakeGreat. I was just thinking to try and use Symfony’s Process component that allows broader control on environment variables passed to spawned processes. And replace the call to exec with that.
Comment #60
mile23OK, so this breakage is why I wanted to postpone this issue on #2641632: Refactor simpletest's *_phpunit_*() (and junit) functions etc. to a class, deprecate because it's so annoying to try to unravel a batch runner from irreproducible functional test fails.
SimpletestUiTestdoes not spawn another run-tests.sh. It uses the UI form, which creates a batch, which is a whole separate test runner from run-test.sh. We have (at least) two test runners that we maintain, which is why we hold the UI form in disdain. #3028663: Split up simpletest into simpletest and testing_ui to enable easier decisions for Drupal 9 #2750461: Remove Simpletest UI because we don't want to maintain a graphical test runnerTo debug I limited
SimpletestUiTestto only runThroughUITest. (Still 3.75 minutes).So for some reason our changes here lead to an error that you can only see if you look at the HTML generated for
SimpletestUiTest. It's in AJAX command format, so it doesn't actually display properly... You can click the ‘continue to the error page’ link and see that it says ‘No active batch.’This means that the one test I selected is never run, because the batch has somehow failed to get the message that there's a test.Actually it's in the results processing, but still no idea.Since I can’t reproduce it by just running that one test from the form on a dev site, and since I can’t pin down what we changed in #49 that started this fail, I’m going to guess it’s an off-by-one error somewhere in the batch definition of
simpletest_run_tests(). But we didn’t change that, so I dunno.Comment #61
mondrakeMaybe I got the problem - since we no longer pass the junit result file path via the
--log-junitoption, but rather as an environment variableSIMPLETEST_JUNIT_FILE, the directory where that file should be written by the test started within the UI form is no longer prepared. Working on a patch that will also include moving to Symfony Process component.Comment #62
mondrakeThis should fix #54, finally. It will break other stuff but that should be easier to fix later. Certainly more test will be required.
This is introducing Symfony Process to execute the spawned PHPUnit runs, in place of prior
execcalls.Comment #64
mondrakeHopefully, this should come back green.
Comment #65
mondrakeOnly code style cleanup here, the c/p of the JUnit listener was using a different CS standard.
Comment #66
mondrakeDRYed a bit the JUnitListener implemenation and cleaned up CS issues.
Comment #67
mile23Some minor stuff.
Let's add a note that this is based on
PHPUnit\Util\Log\JUnit.Also, the point is that it's not Ant JUnit anymore... :-) We should document what is being added here.
Let's put the listener with the others in core/tests/Drupal/Tests/Listeners/.
Pretty sure we need to return
$output, though the return value is never used in core. ::shrugs::Comment #68
mondrake@Mile23 thanks for review!
#67.1 - I'd daresay that not even PHPUnit's JUnit XML is strictly Ant JUnit compliant: they report 'assertions' as an attribute of the
<testsuite>which is not in the specs. Anyway, I agree - we have our own format here now and it's worth documenting it thoroughly.#67.2 - I disagree with that. Adding PHPUnit extensions (listener, printer classes and traits) in the same namespace of the test is prone to issues, because they get discovered by PHPUnit when it runs --testsuite(s) or --group(s). This causes problems like the ones in #3034015: Class to test deprecation error for deprecated trait triggers deprecation error itself and #2950132-74: Support PHPUnit 7 optionally in Drupal 8, while keeping support for ^6.5. IMHO we should go in the opposite direction of moving the existing classes to
Drupal\Core\Test, or even better have a totally separate namespace for PHPUnit extensions (so that they won't collide either with tests or with SUT). We need framework manager review here, flagging.#67.3 -
execreturns "The last line from the result of the command.", whereas$process->getOutput()will return the entire output. Is it worth extracting the last line to return it given it's not used anywhere?More todos:
1. We need unit tests for the JUnitListener itself.
2. With this change a testsuite containing a risky test is reported green by DrupalCI and SimpletestUI form. I believe it should be reported as a fail, though.
3. We need unit tests for the JUnitHelper processing XML with incomplete and with risky tests - only 'skipped' are tested so far
4. Is it worth to summarise also PHPUnit assertions count in run-tests.sh and Simpletest UI?
5. I noticed that if a testsuite has all the tests marked skipped, it is missing the class name in run-test.sh report (https://dispatcher.drupalci.org/job/drupal_patches/1346/consoleFull - line below
Drupal\Tests\Core\Discovery\YamlDiscoveryTest)Interestingly, the PHP 7.3.x-dev test run in #65 has a significantly lower number of passes compared to other PHP versions - looking at the log it is due to 2366 skipped tests in
Drupal\Tests\Component\Serialization\YamlTest. I suppose it's an indication that the PHP 7.3 image on the bots have not the PHP yaml extension installed.Comment #69
mile23Re: #68:
General agreement on everything.
2. PHPUnit fails risky tests by default, but we also have it explicitly configured in phpunit.xml.dist: https://git.drupalcode.org/project/drupal/blob/8.8.x/core/phpunit.xml.di...
4. Assertion count could be a followup.
You're speaking my language AND preaching to the choir here. :-) That's basically what's proposed in this issue: #2866082: [Plan] Roadmap for Simpletest
But it's out of scope here and we should put the listener with the other listeners. I'd love to see another issue where we move everything to an isolated testing infrastructure place.
Comment #70
MixologicOne thing to consider, and Im not sure where it goes, but the testbots are currently reliant on a very limited junit parser tool because the more advanced one introduced a requirement for an xsl because it insisted that we must have a valid schema for the junit xml because the maintainer of said plugin decided they were tired of troubleshooting other peoples broken xml.
This caused us to have to revert to the more limited parser, which sabotaged a lot of other things we were doing, like the ability to have no tests but still run phpcs.
So, whatever schema we end up with, it would be *really* nice if there were a corresponding .xsl file that I can use on the testbots to validate the xml.
We can base it off of the Ant junit one: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd but what this plugin wants us to do is use an .xsl stylesheet to convert what we have to standard junit: https://wiki.jenkins.io/download/attachments/38633556/input.xsl?version=...
Comment #71
mondrakeJust a reroll of #66 after commit of #2863055: Move TestDiscovery out of simpletest module, minimize dependencies.
Comment #72
mile23Thanks.
There's a whole slew of changes coming down the pike from #3057420: [meta] How to deprecate Simpletest with minimal disruption, particularly #3074433: Decouple run-tests.sh from the simpletest module and #2641632: Refactor simpletest's *_phpunit_*() (and junit) functions etc. to a class, deprecate which will likely break the patch here. Those issues should take priority.
#2641632: Refactor simpletest's *_phpunit_*() (and junit) functions etc. to a class, deprecate in particular adds the JUnitHelper class, which is duplicated here. We should favor the one from that issue.
Comment #73
mondrake#72 sure. I'll try to keep up with those changes as they happen to avoid major headache later.
Comment #74
mondrakeReroll after #3074043: Move simpletest.module DB-related functions to TestDatabase, deprecate
Comment #75
mondrakeComment #76
mondrakeRerolled after #2641632: Refactor simpletest's *_phpunit_*() (and junit) functions etc. to a class, deprecate, this was a tough one, let's see
Comment #77
mondrakeA reminder, we need to add #67, #68, #69, #70 in the IS todos (and do them :)). But waiting for the #3057420: [meta] How to deprecate Simpletest with minimal disruption merry-go-round to settle before tacking that. In the meantime, ... rerolls.
Comment #78
mondrakeAddressing failures of #76.
Comment #79
mondrakeComment #80
mondrakeComment #81
mondrakeComment #82
MixologicMaybe not worry about #70 so much. I think I have a solution for jenkins now.
Comment #83
mile23I think it's fair to say this issue is postponed on #3075608: Introduce TestRun objects and refactor TestDatabase to be testable because we're doing some rearchitecting.
Comment #84
mondrakeJust a reroll to keep up with HEAD.
Comment #86
mondrakeComment #87
alexpottLooking at the changes to TestDatabase here:
I don't see why we're postponed on #3075608: Introduce TestRun objects and refactor TestDatabase to be testable
Also the comment that was about framework manager input was about where to put stuff that's not a test and should not be part of the system-under-test. We have that now - it's
Drupal\TestTools.Comment #88
xjmThis would be a minor-only change. Since 8.9.x and 9.0.x are now in beta, I'm moving this to 9.1.x. Thanks!
Comment #89
mondrakeRerolled, on top of #3075608: Introduce TestRun objects and refactor TestDatabase to be testable.
Comment #90
mondrakeListeners' signatures changed since #84.
Comment #91
mondrakeI cannot figure out how to silence the PHPUnit deprecation message
The "Drupal\Core\Test\JUnitListener" class implements "PHPUnit\Framework\TestListener" that is deprecated Use the `TestHook` interfaces instead.inserting it in the allowed deprecations list in DeprecationListenerTrait does not seem to have any effect.
Comment #92
mondrake#91 we probably need to encapsulate Drupal\Core\Test\JUnitListener in DrupalListener instead of adding it to the listeners in the phpunit.xml file.
Comment #93
mondrakeComment #95
mondrakeComment #97
mondrakeComment #98
mondrakeFixing deprecation.
Comment #99
mondrakeComment #100
mondrakeComment #101
mondrakeComment #102
mondrakeI think it would be useful to expose also the duration of the each test run in the run-test.sh output, something like...
thoughts?
Comment #103
mondrakeTrying #102.
Comment #111
mondrakeRebased after #3075608: Introduce TestRun objects and refactor TestDatabase to be testable and changed to MR workflow.
Comment #112
mondrake@longwave and I discussed on Slack on whether working on this issue would still make sense given the upcoming move to GitLab testing. We leaned to a no, but would like to get more feedback.
For sure it improves the console log output by showing execution time, passes, skips, incomplete etc., see latest MR test log https://dispatcher.drupalci.org/job/drupal_patches/171125/consoleFull
Comment #113
alexpottI'd lean towards a no too.
Comment #114
smustgrave commentedWould also say no but depends when exactly that switch will happen?
Comment #115
mondrakeFour leaning no account for at least a full no…
Comment #117
catchWe're relying on run-tests.sh in gitlab CI, and didn't get very far trying to switch to paratest, so this is still relevant.
Comment #118
alexpott@catch but now we have the reports in gitlab CI we are finally seeing which tests are skipped. You can see this in the gitlab reports. Unfortunately it does not tell you why but it is more information.
Comment #120
mondrakeOpened a new branch, just tried to merge the old MR with 11.x. Will fail badly...
Comment #121
catch@alexpott right but we still print the run-tests.sh output in the job logs, and it'd be better if it matched the test reports in gitlab. I always end up going to the jobs about 95% of the time to see what failed.
Comment #122
mondrakeIn PHPUnit 10+ the Junit log does not separate between skipped and incomplete tests, both are reported as ‘skipped’. Also, there is no specific logic around risky tests.
We can simplify here accordingly.
Comment #123
mondrakeComment #124
mondrakeThis is an issue where the review makes more sense when tests fail :)
What's being output currently by run-tests.sh in the 'Detailed test results' section is very simpletest-ish, and possibly needs reconsideration.
1) the 'Group' column in PHPUnit always bears 'Other', so it's useless. I replaced it with the execution time of the single test case.
2) the 'Function' column in PHPUnit is the name of the test, including the name of the dataset provided by a data provider. I renamed the column to 'test'.
3) all reported lines are adding an empty line - it's meant to bear a message, but in PHPUnit passed and skipped test cases never have one. So just chanhed here to skip printing anything if the message is missing.
Also, in HEAD right now if a PHPUnit test run ends with a 'error' exit code, we have a duplicate line reported for the same test class. Fixed here.
Also fixed that if the PHPUnit runner fails for failure/errors, we miss details of testcases passed/failed/errored.
Reviews, based on the output of the MR, appreciated.
Comment #125
mondrakeRebased after commit of #3465132: Show test run time by class in run-tests.sh output.
Comment #126
mondrakeOK, fully green now.
Comment #127
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #128
needs-review-queue-bot commentedFalse positive
Comment #129
mondrakerebased
Comment #130
mondrakeComment #131
mondrakeComment #132
mondrakeComment #133
mondrakerebased
Comment #134
mondrakeadding before/after screenshots
Comment #135
mile23This is all great.
Do we need child issues to fix existing skipped tests that were previously ignored?
Comment #136
mondrake@mile23 the tests were not ignored, actually. They were reported as if they passed, which is the original reason of this issue - and a cause of confusion.
PHPUnit tests can be marked as ‘skipped’ or ‘incomplete’ in the test code, but both end up as ‘skipped’ in the JUnit log - that’s a JUnit limitation AFAICS.
I do not think there’s a need for generic followups to unskip tests - that’s very much dependent on the use case and should be decided case by case. For example, database driver specific kernel tests are prepared for all drivers all times, but then those of the drivers that are not of the currently running database get skipped. By design.
Comment #137
mondrakeComment #138
mile23OK, I guess I kind of misspoke... I meant maybe there were skipped tests that would otherwise fail, or otherwise cause CI to report failed only because we've made the skipped and incomplete tests visible.
Like, in one of those 'after' images, we see a block test marked red. Do we need to file an issue to fix that test?
I guess if the CI is passing on the PR for this issue then we can decide what to do about them after the PR is merged.
Comment #139
mondrakeAha 😀
Those screenshots actually captured a random test failure… those won’t go away with this MR... 😀
Comment #140
mondrakerebased
Comment #141
mile23Do we have some steps to demo locally? I'd give a provisional RTBC but I think the original patch was mine. Granted that was 2017. :-)
Comment #142
mondrakemerged with HEAD
Well the steps would be
a) apply the patch
b) break a test so that the failure can be reported, take note of the @group of the test (ideally, in a test group where some tests are marked skipped/incomplete so you can see the skips on top of the failure)
c) run
run-tests.shfor the group noted above with--verboseoption and enjoy the improvementsI think there are so few people who would be able to RTBC this, that someone has to be bold...
Comment #143
smustgrave commentedLeaning on the screenshots of #134 and reading the summary seems like a good addition. Not entirely sure how to best test it out but since it's been close to 2 months I'm going to mark to see if we can maybe try out on 11.x. Wonder if it's one of those things that will help when actually used.
Comment #144
mondrakeTo meaningfully manual test this, apply the MR patch locally, break some tests, and run tests via run-tests.sh, and llok at results.
Comment #145
dwwRe: #143/#144: Or don't start chromedriver locally and try to run any FunctionalJavascript test.
Comment #147
catchI don't love having the update in system module, but first of all I thought 'why isn't this in simpletest module' and then I suddenly aged ten years. Unless we don't have the update at all, which would be inconvenient for sites that have this table for whatever reason, even if it's people's local installs, I don't see a way around it.
Apart from that this looks good, and it will unblock more issues in the cluster of issues around modernising run-tests.sh, so let's go ahead here. Functionality looks great from the screenshots and we'll soon see what it's like in gitlab runs too.
Committed/pushed to 11.x, thanks!