Problem/Motivation

When running core tests using run-tests.sh, the results of every test are printed to the screen when using —verbose. Developers are usually only interested in failing tests. It would be beneficial to only print out non-passing results.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3215724

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

Beakerboy created an issue. See original summary.

mcdruid’s picture

Thanks, I think this is a great idea.

Personally I'd probably go for something like --failures or --fail-only instead of --no_pass.

Will take a proper look at this ASAP.

beakerboy’s picture

I chose “no_pass” because the test results are either pass, fail, or exception. I didn’t want anyone to be surprised if “fail-only” also printed exceptions. I’m not going to fight over it though, so whatever you want to get it merged is fine by me.

mcdruid’s picture

Status: Active » Reviewed & tested by the community
Issue tags: +Pending Drupal 7 commit

I chose “no_pass” because the test results are either pass, fail, or exception. I didn’t want anyone to be surprised if “fail-only” also printed exceptions.

Ah I see, that makes sense. I'll see what @Fabianx thinks, but I'd be happy with --no-pass or --fail-only (I don't think it's horribly unexpected for the latter to include exceptions too).

(There's already an arg called test_names which is likely why you went for underscore, but I don't think it's expected to pass test_names on the cli, and I'd prefer dashes to underscores in the arg names.)

We can tweak the arg name on commit.

A quick bit of manual testing; I added this:

drupal-7.x$ git diff modules/simpletest/tests/common.test

class FeedIconTest extends DrupalWebTestCase {
     $text = theme_feed_icon($variables);
     preg_match('/title="(.*?)"/', $text, $matches);
     $this->assertEqual($matches[1], 'Subscribe to &"'', 'theme_feed_icon() escapes reserved HTML characters.');
+    $this->assertTrue(FALSE, 'oh noes!');
+    $this->assertFalse($variables['foobar'] == 'baz', 'ruh roh');
   }

Without the new --no_pass arg:

drupal-7.x$ sudo -u www-data php scripts/run-tests.sh --verbose --class FeedIconTest

Drupal test run
---------------

Tests to be run:
 - Feed icon (FeedIconTest)

Test run started:
 Wednesday, May 26, 2021 - 11:20

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

Feed icon 2 passes, 1 fail, and 1 exception

Test run duration: 15 sec

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


---- FeedIconTest ----


Status    Group      Filename          Line Function                            
--------------------------------------------------------------------------------
Pass      Other      common.test       3146 FeedIconTest->testFeedIconEscaping(
    theme_feed_icon() escapes reserved HTML characters.
Fail      Other      common.test       3147 FeedIconTest->testFeedIconEscaping(
    oh noes!
Exception Notice     common.test       3148 FeedIconTest->testFeedIconEscaping(
    Undefined index: foobar
Pass      Other      common.test       3148 FeedIconTest->testFeedIconEscaping(
    ruh roh

...and with it:

drupal-7.x$ sudo -u www-data php scripts/run-tests.sh --verbose --no_pass --class FeedIconTest

Drupal test run
---------------

Tests to be run:
 - Feed icon (FeedIconTest)

Test run started:
 Wednesday, May 26, 2021 - 11:21

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

Feed icon 2 passes, 1 fail, and 1 exception

Test run duration: 15 sec

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


---- FeedIconTest ----


Status    Group      Filename          Line Function                            
--------------------------------------------------------------------------------
Fail      Other      common.test       3147 FeedIconTest->testFeedIconEscaping(
    oh noes!
Exception Notice     common.test       3148 FeedIconTest->testFeedIconEscaping(
    Undefined index: foobar

So LGTM!

I suppose we could emit a message if the new arg is passed without --verbose, but that's very much a nice-to-have.

fabianx’s picture

RTBC + 1, let's use --fail-only as it's more descriptive and an exception is technically a failure that simpletest just chooses to display differently.

  • mcdruid committed 27adf03 on 7.x
    Issue #3215724 by Beakerboy: Add option to only print failing tests
    
mcdruid’s picture

Assigned: beakerboy » Unassigned
Status: Reviewed & tested by the community » Fixed
Issue tags: -Pending Drupal 7 commit

This is great; only wish we'd done it sooner!

Thanks!

Status: Fixed » Closed (fixed)

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