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:

  1. skipped/incomplete tests are reported as passed as this was not a concept in Simpletest
  2. "PHPUnit errors" and "shell execution failures" are reported with the same error level
  3. PHPUnit returns detailed test duration data that is not reported
  4. --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.

CommentFileSizeAuthor
#134 after3.png405.67 KBmondrake
#134 after2.png275.85 KBmondrake
#134 after1.png449.73 KBmondrake
#134 before3.png517.22 KBmondrake
#134 before2.png266.18 KBmondrake
#134 before1.png394.35 KBmondrake
#127 2905007-nr-bot.txt4.09 KBneeds-review-queue-bot
#103 2905007-103.patch126.74 KBmondrake
#103 2905007-103-for-review-do-not-test.patch43.96 KBmondrake
#103 interdiff_99-103.txt4.26 KBmondrake
#99 2905007-99.patch125.97 KBmondrake
#99 interdiff_98-99.txt858 bytesmondrake
#99 2905007-99-for-review-do-not-test.patch42.82 KBmondrake
#98 2905007-98-for-review-do-not-test.patch42.78 KBmondrake
#98 2905007-98.patch125.94 KBmondrake
#98 interdiff_93-98.patch11.39 KBmondrake
#95 2905007-95.patch125.48 KBmondrake
#93 interdiff_90-93.txt8.14 KBmondrake
#93 2905007-93-for-review-do-not-test.patch40.94 KBmondrake
#93 2905007-93.patch125.07 KBmondrake
#90 interdiff_89-90.txt7.5 KBmondrake
#90 2905007-90-for-review-do-not-test.patch37.86 KBmondrake
#90 2905007-90.patch121.99 KBmondrake
#89 2905007-89-for-review-do-not-test.patch36.2 KBmondrake
#89 2905007-89.patch120.33 KBmondrake
#84 2905007-84.patch55.14 KBmondrake
#81 interdiff_80-81.txt505 bytesmondrake
#81 2905007-81.patch55.13 KBmondrake
#80 interdiff_79-80.txt7.22 KBmondrake
#80 2905007-80.patch55.05 KBmondrake
#79 interdiff_76-79.txt2.68 KBmondrake
#79 2905007-79.patch48.13 KBmondrake
#78 2905007-78.patch48.13 KBmondrake
#78 interdiff_76-78.txt2.68 KBmondrake
#76 2905007-76.patch46.61 KBmondrake
#74 2905007-74.patch60.36 KBmondrake
#71 2905007-71.patch60.09 KBmondrake
#66 interdiff_65-66.txt8.75 KBmondrake
#66 2905007-66.patch60.04 KBmondrake
#65 2905007-65.patch61.61 KBmondrake
#65 interdiff_64-65.txt22.2 KBmondrake
#64 interdiff_62-64.txt4.61 KBmondrake
#64 2905007-64.patch62.74 KBmondrake
#62 interdiff_54-62.txt5.89 KBmondrake
#62 2905007-62.patch60.54 KBmondrake
#56 incomplete.jpg68.05 KBmile23
#54 2905007-54.patch56.94 KBmondrake
#54 interdiff_51-54.txt2.78 KBmondrake
#51 interdiff_49-51.txt29.84 KBmondrake
#51 2905007-51.patch55.89 KBmondrake
#49 2905007-49.patch57.2 KBmondrake
#49 interdiff_48-49.txt23.16 KBmondrake
#48 interdiff.txt1.06 KBmile23
#48 2905007_48.patch41.31 KBmile23
#46 interdiff.txt21.32 KBmile23
#46 2905007_46.patch40.48 KBmile23
#40 skipped_json_test.jpg55.86 KBmile23
#36 interdiff.txt1.74 KBmile23
#36 2905007_36.patch26.41 KBmile23
#34 interdiff.txt1.1 KBmile23
#34 2905007_34.patch28.16 KBmile23
#31 2905007_31.patch27.36 KBmile23
#28 interdiff.txt2.34 KBmile23
#28 2905007_28.patch26.37 KBmile23
#26 interdiff.txt7.25 KBmile23
#26 2905007_26.patch25.86 KBmile23
#23 interdiff.txt7.68 KBmile23
#23 2905007_23.patch29.56 KBmile23
#21 interdiff.txt2.69 KBmile23
#21 2905007_21.patch29.58 KBmile23
#19 interdiff.txt4.36 KBmile23
#19 2905007_19.patch28.59 KBmile23
#19 2905007_19_timing-do-not-test.patch13.21 KBmile23
#18 interdiff.txt1.5 KBmile23
#18 2905007_18.patch28.72 KBmile23
#17 interdiff.txt3.73 KBmile23
#17 2905007_17_timing_do-not-test.patch11.69 KBmile23
#17 2905007_17.patch27.38 KBmile23
#15 interdiff.txt13.96 KBmile23
#15 2905007_15.patch26.6 KBmile23
#13 skipped_test.jpg241.12 KBmile23
#13 2905007_13.patch17.02 KBmile23

Issue fork drupal-2905007

Command icon 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:

Comments

Mile23 created an issue. See original summary.

mile23’s picture

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mixologic’s picture

Cant 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.

mile23’s picture

It'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. :-)

mile23’s picture

simpletest.install says this in hook_schema():

      'status' => [
        'type' => 'varchar',
        'length' => 9,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Message status. Core understands pass, fail, exception.',
      ],

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:

      <testsuite name="Drupal\Tests\Component\Annotation\AnnotationBaseTest" file="/Users/paul/pj2/drupal/core/tests/Drupal/Tests/Component/Annotation/AnnotationBaseTest.php" tests="2" assertions="2" failures="0" errors="0" time="0.009006">
          <testcase name="testGetId" class="Drupal\Tests\Component\Annotation\AnnotationBaseTest" file="/Users/paul/pj2/drupal/core/tests/Drupal/Tests/Component/Annotation/AnnotationBaseTest.php" line="28" assertions="1" time="0.004501"/>
          <testcase name="testSetClass" class="Drupal\Tests\Component\Annotation\AnnotationBaseTest" file="/Users/paul/pj2/drupal/core/tests/Drupal/Tests/Component/Annotation/AnnotationBaseTest.php" line="39" assertions="1" time="0.004505"/>
        </testsuite>

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:

{
    "event": "test",
    "suite": "Drupal\\Tests\\Component\\Annotation\\AnnotationBaseTest",
    "test": "Drupal\\Tests\\Component\\Annotation\\AnnotationBaseTest::testSetProvider",
    "status": "error",
    "time": 0.00547909736633,
    "trace": [
        {
            "file": "\/Users\/paul\/pj2\/drupal\/core\/tests\/Drupal\/Tests\/Component\/Annotation\/AnnotationBaseTest.php",
            "line": 19,
            "function": "markTestSkipped",
            "class": "PHPUnit_Framework_Assert",
            "type": "::"
        }
    ],
    "message": "Skipped Test: I skipped it!",
    "output": ""
}

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 --browser is 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.

mile23’s picture

Title: Allow run-tests.sh to reflect skipped PHPUnit-based tests » Allow run-tests.sh to reflect skipped/risky/incomplete PHPUnit-based tests

Updating scope for #2907728-90: Installer: Convert system functional tests to phpunit because it's the same solution.

mile23’s picture

BTW, this JUnit reporting problem goes away in PHPUnit 6.1:

          <testcase name="testSetProvider" class="Drupal\Tests\Component\Annotation\AnnotationBaseTest" classname="Drupal.Tests.Component.Annotation.AnnotationBaseTest" file="/Users/paul/pj2/drupal/core/tests/Drupal/Tests/Component/Annotation/AnnotationBaseTest.php" line="18" assertions="0" time="0.000660">
            <skipped/>
          </testcase>

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:

          <testcase name="testSetProvider" class="Drupal\Tests\Component\Annotation\AnnotationBaseTest" classname="Drupal.Tests.Component.Annotation.AnnotationBaseTest" file="/Users/paul/pj2/drupal/core/tests/Drupal/Tests/Component/Annotation/AnnotationBaseTest.php" line="18" assertions="0" time="0.000300">
            <error type="PHPUnit\Framework\RiskyTestError">Risky Test
</error>
          </testcase>

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.

Mixologic’s picture

I suggest we not care about this

If 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?

mile23’s picture

OK 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

alexpott’s picture

Status: Postponed » Active

@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.

mile23’s picture

That 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.

mile23’s picture

Status: Active » Needs review
StatusFileSize
new17.02 KB
new241.12 KB

WiP. 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.

Status: Needs review » Needs work

The last submitted patch, 13: 2905007_13.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mile23’s picture

Status: Needs work » Needs review
Issue tags: +Needs change record
StatusFileSize
new26.6 KB
new13.96 KB

Deprecates simpletest_phpunit_xml_to_rows(), simpletest_phpunit_find_testcases(), and simpletest_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

Status: Needs review » Needs work

The last submitted patch, 15: 2905007_15.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new27.38 KB
new11.69 KB
new3.73 KB

Fixed 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):

Over 23886 iterations:
JUnitHelper time: 14.504240036011
simpletest_phpunit_xml_to_rows() time: 9.3026301860809
mile23’s picture

StatusFileSize
new28.72 KB
new1.5 KB

From the console log:

Hmm.....

18:43:55 PHP Notice:  Undefined index: #skipped in /var/www/html/core/scripts/run-tests.sh on line 1228
18:43:57 
18:43:57 Notice: Undefined index: #skipped in /var/www/html/core/scripts/run-tests.sh on line 1228
18:43:57 Drupal\system\Tests\Ajax\CommandsTest                         92 passes   

Hello, TestBase! #1273478: Implement @requires and @dependencies within TestBase, mark tests as skipped

But also:

19:00:08 Drupal\Tests\rest\Functional\EntityResource\Comment\CommentX   2 passes             4 skipped/incomplete                            
19:00:10 Drupal\Tests\rest\Functional\EntityResource\Comment\CommentX   2 passes             4 skipped/incomplete                            
19:00:10 Drupal\Tests\rest\Functional\EntityResource\Comment\CommentJ   6 passes                                                             
19:00:12 Drupal\Tests\rest\Functional\EntityResource\Comment\CommentX   2 passes             4 skipped/incomplete  

So that's nice.

mile23’s picture

StatusFileSize
new13.21 KB
new28.59 KB
new4.36 KB

Now with fast:

Over 23886 iterations:
JUnitHelper time: 7.8263108730316
JUnitHelper recursive time: 9.7474420070648
simpletest_phpunit_xml_to_rows() time: 8.9688141345978

'Recursive' in this report means porting over the recursive XML parsing from simpletest_phpunit_find_testcases() rather than just using xpath('.//testcase'). It turns out xpath() 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.

mile23’s picture

  1. +++ b/core/lib/Drupal/Core/Test/JUnitHelper.php
    @@ -0,0 +1,131 @@
    +      if ($testcase->error) {
    ...
    +    if ($status == 'skipped') {
    

    Should be elseif.

  2. +++ b/core/modules/simpletest/simpletest.module
    @@ -798,6 +803,9 @@ function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file) {
     function simpletest_phpunit_find_testcases(\SimpleXMLElement $element, \SimpleXMLElement $parent = NULL) {
    

    Replace contents with $element->xpath('.//testcase')

mile23’s picture

Issue tags: -Needs change record
StatusFileSize
new29.58 KB
new2.69 KB

Addresses #20, adds change record: https://www.drupal.org/node/2966954

dawehner’s picture

Just some quick review

  1. +++ b/core/modules/simpletest/tests/src/Unit/SimpletestJUnitDeprecationTest.php
    @@ -0,0 +1,54 @@
    +/**
    + * @group simpletest
    + * @group legacy
    + */
    +class SimpletestJUnitDeprecationTest extends UnitTestCase {
    +
    +  protected function setUp() {
    +    parent::setUp();
    +    require_once __DIR__ . '/../../../simpletest.module';
    +  }
    +
    

    Can we ensure to run this test in isolation?

  2. +++ b/core/tests/Drupal/Tests/Core/Test/JUnitHelperTest.php
    @@ -0,0 +1,87 @@
    +    $this->assertEquals(count($records), 4, 'All testcases got extracted');
    

    You can use assertCount instead

mile23’s picture

StatusFileSize
new29.56 KB
new7.68 KB

Thanks.

Addressed #22, added CR link to deprecation messages.

mile23’s picture

Getting 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.

mile23’s picture

#23 test run for PHP 5.6 says things like this:

21:01:07 Drupal\Tests\workflows\Kernel\WorkflowAccessControlHandlerTe   1 passes                                                             
21:01:07                                                               12 passes                                                             
21:01:08 Drupal\Tests\views_ui\Functional\TokenizeAreaUITest            1 passes     

Resulting in about a zillion of these:

21:05:19 PHP Notice:  Undefined index:  in /opt/drupalci/testrunner/src/DrupalCI/Build/Artifact/Junit/JunitXmlBuilder.php on line 82

Not an issue in PHP 7.

mile23’s picture

Issue tags: +Needs followup
StatusFileSize
new25.86 KB
new7.25 KB

simpletest_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.

dawehner’s picture

+++ b/core/modules/simpletest/simpletest.module
@@ -774,8 +782,27 @@ function simpletest_mail_alter(&$message) {
+  // Use the new JUnit helper if we're using a suitable version of PHPUnit.
+  if (version_compare($phpunit_version, '6.0.0', '>')) {
+    $helper = new JUnitHelper($test_id, $phpunit_xml_file);
+    return $helper->getRecords() ?: NULL;
+  }

@@ -838,6 +871,11 @@ function simpletest_phpunit_find_testcases(\SimpleXMLElement $element, \SimpleXM
  *
  * @return array
  *   An array containing the {simpletest} result row.
+ *
+ * @deprecated in Drupal 8.6.x for removal before Drupal 9.0.0. Use
+ *   \Drupal\Core\Test\JUnitHelper to convert JUnit to simpletest database rows.
+ *
+ * @see https://www.drupal.org/node/2966954
  */
 function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcase) {

What about changing the documentation of simpletest_phpunit_testcase_to_row to 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.

mile23’s picture

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dww’s picture

Category: Task » Bug report
Status: Needs review » Needs work
Issue tags: +Needs reroll

@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:

Test summary
------------

Drupal\Tests\system\FunctionalJavascript\OffCanvasTest         6 passes

Test run duration: 47 sec

Detailed test results
---------------------

---- Drupal\Tests\system\FunctionalJavascript\OffCanvasTest ----

Status    Group      Filename          Line Function
--------------------------------------------------------------------------------
Pass      Other      OffCanvasTest.php   33 Drupal\Tests\system\FunctionalJavas
Pass      Other      OffCanvasTest.php   33 Drupal\Tests\system\FunctionalJavas
Pass      Other      OffCanvasTest.php   33 Drupal\Tests\system\FunctionalJavas
Pass      Other      OffCanvasTest.php   33 Drupal\Tests\system\FunctionalJavas
Pass      Other      OffCanvasTest.php   33 Drupal\Tests\system\FunctionalJavas
Pass      Other      OffCanvasTest.php  114 Drupal\Tests\system\FunctionalJavas

With #28 applied, I now see this:

Test summary
------------

Drupal\Tests\system\FunctionalJavascript\OffCanvasTest         0 passes             6 skipped/incomplete

Test run duration: 46 sec

Detailed test results
---------------------

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

mile23’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new27.36 KB

Reroll for 8.7.x.

Thanks, @dww.

All of this is about to get shuffled around: #3030136: The Fate Of Run-Tests.Sh

dww’s picture

Thanks and thanks! Following the parent [meta] and The Fate issues now.

Cheers,
-Derek

Status: Needs review » Needs work

The last submitted patch, 31: 2905007_31.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new28.16 KB
new1.1 KB

Tests passing.

alexpott’s picture

+++ b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php
@@ -116,4 +117,33 @@ public function testUserAgentValidation() {
+  /**
+   * Tests that PHPUnit and KernelTestBase tests work through the UI.
+   */
+  public function testTestingThroughUI() {
+    $this->drupalGet('admin/config/development/testing');
+    $this->assertTrue(strpos($this->drupalSettings['simpleTest']['images'][0], 'core/misc/menu-collapsed.png') > 0, 'drupalSettings contains a link to core/misc/menu-collapsed.png.');
+    // We can not test WebTestBase tests here since they require a valid .htkey
+    // to be created. However this scenario is covered by the testception of
+    // \Drupal\simpletest\Tests\SimpleTestTest.
+
+    $tests = [
+      // A KernelTestBase test.
+      'Drupal\KernelTests\KernelTestBaseTest',
+      // A PHPUnit unit test.
+      'Drupal\Tests\action\Unit\Menu\ActionLocalTasksTest',
+      // A PHPUnit functional test.
+      ThroughUITest::class,
+    ];
+
+    foreach ($tests as $test) {
+      $this->drupalGet('admin/config/development/testing');
+      $edit = [
+        "tests[$test]" => TRUE,
+      ];
+      $this->drupalPostForm(NULL, $edit, t('Run tests'));
+      $this->assertText('0 fails, 0 skipped, 0 exceptions');
+    }
+  }

I think this is being added back by mistake.

mile23’s picture

StatusFileSize
new26.41 KB
new1.74 KB

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mile23’s picture

Version: 8.8.x-dev » 8.7.x-dev
Issue summary: View changes

Patch still applies, moving to 8.7.x because it's a test improvement.

mile23’s picture

Patch still applies, re-running test.

mile23’s picture

StatusFileSize
new55.86 KB

This result chosen randomly from the console log:

Is marked incomplete:

  public function testNormalizeRelated() {
    $this->markTestIncomplete('This fails and should be fixed by https://www.drupal.org/project/jsonapi/issues/2922121');

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.

mile23’s picture

Issue summary: View changes
mondrake’s picture

Version: 8.7.x-dev » 8.8.x-dev

Patch 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?

mondrake’s picture

Assigned: Unassigned » mondrake

I am working on trying to expose 'risky' and 'incomplete' test results separately.

mondrake’s picture

Assigned: mondrake » Unassigned

Hmm, #43 is complicated... PHPUnit's PHPUnit\Util\Log\JUnit reports 'skipped' and 'incomplete' tests in one and the same way via doAddSkipped, 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?

mile23’s picture

The '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. :-)

mile23’s picture

StatusFileSize
new40.48 KB
new21.32 KB

Closed #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.

Status: Needs review » Needs work

The last submitted patch, 46: 2905007_46.patch, failed testing. View results

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new41.31 KB
new1.06 KB

Hopefully fixing the fails.

mondrake’s picture

StatusFileSize
new23.16 KB
new57.2 KB

This 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 additional messageattribute 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...

Status: Needs review » Needs work

The last submitted patch, 49: 2905007-49.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mondrake’s picture

StatusFileSize
new55.89 KB
new29.84 KB

Just some progress.

mondrake’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 51: 2905007-51.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mondrake’s picture

Status: Needs work » Needs review
StatusFileSize
new2.78 KB
new56.94 KB

This should account separately for 'incomplete' tests now. I increased the size of the {simpletest}.status column to 12 to allow the text 'incomplete' to fit in.

Status: Needs review » Needs work

The last submitted patch, 54: 2905007-54.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mile23’s picture

StatusFileSize
new68.05 KB

Nice. Compare to #40 to see how much more clear this is.

mondrake’s picture

The failure in #54 is very tricky - Drupal\Tests\simpletest\Functional\SimpletestUiTest::testTestingThroughUI is a functional test testing that the simpletest UI performs correctly some tests. That means that run-test.sh is 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?

mile23’s picture

Assigned: Unassigned » mile23

I'll give it a shot.

mondrake’s picture

Great. 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.

mile23’s picture

Assigned: mile23 » Unassigned

OK, 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.

SimpletestUiTest does 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 runner

To debug I limited SimpletestUiTest to only run ThroughUITest. (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.

mondrake’s picture

Assigned: Unassigned » mondrake

Maybe I got the problem - since we no longer pass the junit result file path via the --log-junit option, but rather as an environment variable SIMPLETEST_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.

mondrake’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
StatusFileSize
new60.54 KB
new5.89 KB

This 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 exec calls.

Status: Needs review » Needs work

The last submitted patch, 62: 2905007-62.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mondrake’s picture

Assigned: mondrake » Unassigned
Status: Needs work » Needs review
StatusFileSize
new62.74 KB
new4.61 KB

Hopefully, this should come back green.

mondrake’s picture

StatusFileSize
new22.2 KB
new61.61 KB

Only code style cleanup here, the c/p of the JUnit listener was using a different CS standard.

mondrake’s picture

StatusFileSize
new60.04 KB
new8.75 KB

DRYed a bit the JUnitListener implemenation and cleaned up CS issues.

mile23’s picture

Some minor stuff.

  1. +++ b/core/lib/Drupal/Core/Test/JUnitListener.php
    @@ -0,0 +1,354 @@
    +/**
    + * A TestListener that generates a logfile of the test execution in XML markup.
    + *
    + * The XML markup used is the same as the one that is used by the JUnit Ant task.
    + */
    

    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.

  2. +++ b/core/lib/Drupal/Core/Test/JUnitListener.php
    @@ -0,0 +1,354 @@
    +class JUnitListener implements TestListener {
    

    Let's put the listener with the others in core/tests/Drupal/Tests/Listeners/.

  3. +++ b/core/modules/simpletest/simpletest.module
    @@ -320,34 +356,35 @@ function simpletest_phpunit_configuration_filepath() {
      * @return string
      *   The results as returned by exec().
    
    @@ -358,26 +395,18 @@ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpun
    +  return '';
    

    Pretty sure we need to return $output, though the return value is never used in core. ::shrugs::

mondrake’s picture

@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 - exec returns "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.

mile23’s picture

Re: #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.

MHO 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).

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.

Mixologic’s picture

One 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=...

mondrake’s picture

StatusFileSize
new60.09 KB
mile23’s picture

Thanks.

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.

mondrake’s picture

Status: Needs review » Postponed

#72 sure. I'll try to keep up with those changes as they happen to avoid major headache later.

mondrake’s picture

StatusFileSize
new60.36 KB
mondrake’s picture

Assigned: Unassigned » mondrake
mondrake’s picture

StatusFileSize
new46.61 KB
mondrake’s picture

A 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.

mondrake’s picture

StatusFileSize
new2.68 KB
new48.13 KB

Addressing failures of #76.

mondrake’s picture

StatusFileSize
new48.13 KB
new2.68 KB
mondrake’s picture

StatusFileSize
new55.05 KB
new7.22 KB
mondrake’s picture

StatusFileSize
new55.13 KB
new505 bytes
Mixologic’s picture

Maybe not worry about #70 so much. I think I have a solution for jenkins now.

mile23’s picture

I 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.

mondrake’s picture

StatusFileSize
new55.14 KB

Just a reroll to keep up with HEAD.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mondrake’s picture

Version: 8.9.x-dev » 9.0.x-dev
Component: simpletest.module » phpunit
Assigned: mondrake » Unassigned
alexpott’s picture

Status: Postponed » Needs work
Issue tags: -Needs framework manager review

Looking at the changes to TestDatabase here:

+++ b/core/lib/Drupal/Core/Test/TestDatabase.php
@@ -341,10 +341,10 @@ public static function testingSchema() {
         'status' => [
           'type' => 'varchar',
-          'length' => 9,
+          'length' => 12,
           'not null' => TRUE,
           'default' => '',
-          'description' => 'Message status. Core understands pass, fail, exception.',
+          'description' => 'Message status.',
         ],

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.

xjm’s picture

Version: 9.0.x-dev » 9.1.x-dev

This 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!

mondrake’s picture

Status: Needs work » Needs review
StatusFileSize
new120.33 KB
new36.2 KB
mondrake’s picture

StatusFileSize
new121.99 KB
new37.86 KB
new7.5 KB

Listeners' signatures changed since #84.

mondrake’s picture

I 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.

mondrake’s picture

#91 we probably need to encapsulate Drupal\Core\Test\JUnitListener in DrupalListener instead of adding it to the listeners in the phpunit.xml file.

mondrake’s picture

StatusFileSize
new125.07 KB
new40.94 KB
new8.14 KB

The last submitted patch, 93: 2905007-93.patch, failed testing. View results

mondrake’s picture

StatusFileSize
new125.48 KB

Status: Needs review » Needs work

The last submitted patch, 95: 2905007-95.patch, failed testing. View results

mondrake’s picture

Assigned: Unassigned » mondrake
mondrake’s picture

Status: Needs work » Needs review
StatusFileSize
new11.39 KB
new125.94 KB
new42.78 KB

Fixing deprecation.

mondrake’s picture

StatusFileSize
new42.82 KB
new858 bytes
new125.97 KB
mondrake’s picture

Assigned: mondrake » Unassigned
mondrake’s picture

Title: Allow run-tests.sh to reflect skipped/risky/incomplete PHPUnit-based tests » Allow run-tests.sh to report skipped/risky/incomplete PHPUnit-based tests
mondrake’s picture

Issue summary: View changes

I think it would be useful to expose also the duration of the each test run in the run-test.sh output, something like...

09:43:58 32.4s Drupal\Tests\jsonapi\Functional\ConfigTestTest 7 passes, 1 skipped

thoughts?

mondrake’s picture

StatusFileSize
new4.26 KB
new43.96 KB
new126.74 KB

Trying #102.

Status: Needs review » Needs work

The last submitted patch, 103: 2905007-103.patch, failed testing. View results

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mondrake’s picture

Status: Needs work » Needs review
mondrake’s picture

@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

alexpott’s picture

I'd lean towards a no too.

smustgrave’s picture

Would also say no but depends when exactly that switch will happen?

mondrake’s picture

Status: Needs review » Closed (won't fix)

Four leaning no account for at least a full no…

catch’s picture

Status: Closed (won't fix) » Needs work

We'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.

alexpott’s picture

@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.

mondrake’s picture

Version: 10.1.x-dev » 11.x-dev

Opened a new branch, just tried to merge the old MR with 11.x. Will fail badly...

catch’s picture

@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.

mondrake’s picture

In 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.

mondrake’s picture

Title: Allow run-tests.sh to report skipped/risky/incomplete PHPUnit-based tests » Allow run-tests.sh to report skipped/incomplete PHPUnit-based tests
mondrake’s picture

Status: Needs work » Needs review

This 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.

mondrake’s picture

mondrake’s picture

OK, fully green now.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new4.09 KB

The 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.

needs-review-queue-bot’s picture

Status: Needs work » Needs review

False positive

mondrake’s picture

rebased

mondrake’s picture

mondrake’s picture

Issue summary: View changes
mondrake’s picture

Title: Allow run-tests.sh to report skipped/incomplete PHPUnit-based tests » Allow run-tests.sh to report skipped/incomplete PHPUnit tests
mondrake’s picture

rebased

mondrake’s picture

Issue summary: View changes
StatusFileSize
new394.35 KB
new266.18 KB
new517.22 KB
new449.73 KB
new275.85 KB
new405.67 KB

adding before/after screenshots

mile23’s picture

This is all great.

Do we need child issues to fix existing skipped tests that were previously ignored?

mondrake’s picture

@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.

mondrake’s picture

Issue summary: View changes
mile23’s picture

OK, 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.

mondrake’s picture

in one of those 'after' images, we see a block test marked red. Do we need to file an issue to fix that test?

Aha 😀

Those screenshots actually captured a random test failure… those won’t go away with this MR... 😀

mondrake’s picture

rebased

mile23’s picture

Do 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. :-)

mondrake’s picture

merged with HEAD

Do we have some steps to demo locally?

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.sh for the group noted above with --verbose option and enjoy the improvements

I'd give a provisional RTBC but I think the original patch was mine

I think there are so few people who would be able to RTBC this, that someone has to be bold...

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Leaning 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.

mondrake’s picture

To meaningfully manual test this, apply the MR patch locally, break some tests, and run tests via run-tests.sh, and llok at results.

dww’s picture

Re: #143/#144: Or don't start chromedriver locally and try to run any FunctionalJavascript test.

  • catch committed faeda6e6 on 11.x
    Issue #2905007 by mondrake, mile23, alexpott, Mixologic, dww, dawehner:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

I 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.