Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#25 | interdiff-2776071-25.txt | 843 bytes | damiankloip |
#25 | 2776071-25.patch | 912 bytes | damiankloip |
Comments
Comment #2
damiankloip CreditAttribution: damiankloip commentedComment #3
catchNot 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.
Comment #4
dawehnerIt doesn't cause issues on DrupalCI because it uses the junit XML output ...
Comment #5
Sam152 CreditAttribution: Sam152 at PreviousNext commentedHad the same for D7 #2189345: run-tests.sh should exit with a failure code if any tests failed.
Comment #6
dawehnerThe existing code looks like the following:
Together with this addition we can quite improve the code by getting rid of the if and else
Comment #7
dawehnerWe 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
Comment #8
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedComment #11
catchCommitted/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.
Comment #14
catchHad to revert this. Fatal errors in tests were killing DrupalCI runs because it only looks for 0 and 1 status codes.
Comment #15
MixologicThe 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
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.
Comment #16
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedok, but that is pretty poor in general.
Comment #17
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedSo just this?
Comment #18
MixologicWe 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...
Comment #19
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedHmm, that's totally not what you said before :) Do we have to stick to 0 or 1 exit codes for now so DrupalCI works?
Comment #20
MixologicThat 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?
Comment #21
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedYeah. 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.
Comment #22
neclimdulAmusingly 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?
Comment #23
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedYeah. The script uses that in quite a few places to return that error code already...
A todo sounds like a sane idea to me.
Comment #24
MixologicOpened a related drupalci issue.
Comment #25
damiankloip CreditAttribution: damiankloip at Tag1 Consulting commentedAdded todo comment.
Comment #26
neclimdulBeing 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.
Comment #27
neclimdulson of a... so... the previous one is the interdiff and I'll where a brown paper bag for the rest of the day.
Comment #30
neclimdulperdy
Comment #33
catchCommitted/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!