#37 closed defect (wontfix)

wp-test.php does not exit with proper error code when tests fail

Reported by: benbalter Owned by:
Priority: minor Milestone: Legacy - Improve Framework
Component: Test Framework Keywords: has-patch
Cc: benbalter

Description

If running wp-test.php as part of an automated test (e.g., using Travis CI), even when a test fails, the script simply ends (what's interpreted as a passing return code 0).

Instead, it should exit(1) on failure, and even better explicitly exit(0) on success so that the proper exit code is passed to other programs.

( The attached patch also removed the closing PHP tag )

Attachments (3)

37.diff (500 bytes) - added by benbalter 13 months ago.
37-1.diff (1.2 KB) - added by benbalter 13 months ago.
Only exit with error code when -x flag is present
37.2.diff (1.1 KB) - added by nacin 13 months ago.

Download all attachments as: .zip

Change History (8)

Only exit with error code when -x flag is present

Per nacin, updated ticket with 2nd patch attachment:37-1.diff that only exits with the proper error code when a -x flag is passed.

Error code now returns the combined number of errors/warnings each time (0 = success, >0 = failure).

I don't think this is going to behave like you want:

exit ( intval( $result->failureCount() ) + intval( $result->errorCount() ) ); 

Exit codes are an unsigned byte. They're limited to a range of 0-255. Anything outside that range would just roll over.

For example, if the combined error and failure count was 355, the above code would set the exit code to 355, but that's outside the range, so any process that checked the exit code would see 99.

comment:3 follow-up: ↓ 4   benbalter13 months ago

So perhaps it should just exit 0 or 1 for success/fail?

comment:4 in reply to: ↑ 3   nacin13 months ago

Replying to benbalter:

So perhaps it should just exit 0 or 1 for success/fail?

Yes.

nacin13 months ago

  • Resolution set to wontfix
  • Status changed from new to closed

This will work fine when using the TextUI runner.

Note: See TracTickets for help on using tickets.