Problem/Motivation

On travis builds (or anything else), tests appear to have passed if a method fails with an exception, meaning the test exits early. So the status code is not actually used anywhere and just gets eaten up.

Proposed resolution

Update the $total_status in run-tests.sh for the case that the test runner returned a non-zero error code. Tests that FATAL will then always be caught properly.

Remaining tasks

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip created an issue. See original summary.

damiankloip’s picture

Status: Active » Needs review
catch’s picture

Priority: Major » Critical

Not clear whether this could lead to un-caught DrupalCI failures, but bumping to critical since it definitely means false negatives running tests locally or on travis.

dawehner’s picture

It doesn't cause issues on DrupalCI because it uses the junit XML output ...

Sam152’s picture

dawehner’s picture

Status: Needs review » Needs work

The existing code looks like the following:

        if ($status['exitcode'] === SIMPLETEST_SCRIPT_EXIT_FAILURE) {
          $total_status = max($status['exitcode'], $total_status);
        }
        elseif ($status['exitcode']) {

Together with this addition we can quite improve the code by getting rid of the if and else

dawehner’s picture

Status: Needs work » Reviewed & tested by the community

We tried to implement #6, but the code is quite fragile, and making it actually working, makes the code not really easier to read.
Given that

damiankloip’s picture

  • catch committed b026909 on 8.3.x
    Issue #2776071 by damiankloip: run-tests.sh does not return a non zero...

  • catch committed 8197355 on 8.2.x
    Issue #2776071 by damiankloip: run-tests.sh does not return a non zero...
catch’s picture

Version: 8.2.x-dev » 8.1.x-dev

Committed/pushed to 8.3.x and 8.2.x thanks!

With 8.1.x I'm going to leave it RTBC for a bit, but should be cherry-picked there too. Might make some tests builds fail, but that's the point.

  • catch committed 4e9d207 on 8.2.x
    Revert "Issue #2776071 by damiankloip: run-tests.sh does not return a...

  • catch committed 8658fc3 on 8.3.x
    Revert "Issue #2776071 by damiankloip: run-tests.sh does not return a...
catch’s picture

Version: 8.1.x-dev » 8.3.x-dev
Status: Reviewed & tested by the community » Needs review

Had to revert this. Fatal errors in tests were killing DrupalCI runs because it only looks for 0 and 1 status codes.

Mixologic’s picture

The correct error statuses for a testing script are 0 - ran and tests passed, 1 - ran and tests failed, and anything > 1 is treated as the test-running software had an abnormal abort. So if there is a Fatal Error in a test, that should not be

max($status['exitcode'], $total_status);

This should be just 1. no matter why a test fails or aborts, 1 is the response we're looking for. if run-tests.sh itself dies, then the return signal should reflect that it aborted.

damiankloip’s picture

ok, but that is pretty poor in general.

damiankloip’s picture

So just this?

Mixologic’s picture

ok, but that is pretty poor in general.

We should probably mirror what junit/phpunit do, which is exit 2 on an exception:

https://github.com/junit-team/junit4/blob/9e98a85ecf6e857523fcda91507562...
https://github.com/sebastianbergmann/phpunit/blob/1ef3ff15e87f6bd69cb116...

damiankloip’s picture

Hmm, that's totally not what you said before :) Do we have to stick to 0 or 1 exit codes for now so DrupalCI works?

Mixologic’s picture

That is correct, I did some more reading and research, and have more information. I would stick to 1 or 0 for now, until drupalci knows what to do with a 2.

That being said, however, Im not entirely sure if/how drupalci should do anything different with exceptions vs failed tests. Should the testing system behave any differently if 'tests failed, because they couldnt run due to an exception' vs 'tests failed, because something's not right?' other than report different messaging?

damiankloip’s picture

Yeah. I with you there. I think it's sensible to keep it returning 0 or 1 for now. A fatal in a test is still a failed test technically. So this seems good to me.

neclimdul’s picture

Amusingly run-tests.sh is already ready with a constant for that too. :) drupalci just needs to be updated.

http://cgit.drupalcode.org/drupal/tree/core/scripts/run-tests.sh#n35

I started to RTBC this but should we make a @todo and a follow up to fix this once drupalci is ready to handle the separate exit code?

damiankloip’s picture

Yeah. The script uses that in quite a few places to return that error code already...

A todo sounds like a sane idea to me.

Mixologic’s picture

Opened a related drupalci issue.

damiankloip’s picture

Added todo comment.

neclimdul’s picture

Being as the problem we had was specifically with testbot and to be super sure we don't disrupt anything just confirming that this patch fails well. Think we can RTBC this if it does.

neclimdul’s picture

son of a... so... the previous one is the interdiff and I'll where a brown paper bag for the rest of the day.

The last submitted patch, 26: run_tests_sh_does_not-2776071-26.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 27: run_tests_sh_does_not-2776071-26.patch, failed testing.

neclimdul’s picture

Status: Needs work » Reviewed & tested by the community

perdy

  • catch committed 74d2937 on 8.3.x
    Issue #2776071 by damiankloip, neclimdul, Mixologic: run-tests.sh does...

  • catch committed 56ba4ed on 8.2.x
    Issue #2776071 by damiankloip, neclimdul, Mixologic: run-tests.sh does...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!

Status: Fixed » Closed (fixed)

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