Now that the PDO is very close to land, we need to make sure that the testing framework can intercept uncaught exceptions.

Uncaught exceptions are fatal in some cases in PHP, an they can stop a test case completely (ie. the following test* methods will not get executed).

Comments

chx’s picture

Title: Simpletest should catch uncaught exceptions » Simpletest does not catch uncaught exceptions
Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community
damien tournoud’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.1 KB

The same, with a better backtracing.

boombatower’s picture

What are you considering fatal uncaught exceptions?

Adding

breakMe();

To a test causes a crash of batch process and redirect to page that informs me of an error that occurred.

damien tournoud’s picture

StatusFileSize
new1.55 KB

@boombatower: we don't need to crash the batch process. We should handle that gracefully.

A cleanest patch is attached.

For those wondering what the set_exception_handler could be used for if we already run the tests in a try/catch block: in PHP it is 100% possible to throw an exception that is not a child of the Exception class. We catch those here. Silly, isn't it?

damien tournoud’s picture

Title: Simpletest does not catch uncaught exceptions » Simpletest should catch exceptions
boombatower’s picture

@Damien Tournoud: I'm aware that we are trying to catch them gracefully, I was stating that it didn't catch them.

boombatower’s picture

Status: Needs review » Needs work

It still crashes if I add that code to any test.

Based on: "we don't need to crash the batch process. We should handle that gracefully." needs work?

boombatower’s picture

Catches:

$i = 1 / 0;

If that is all we can/intend to catch this works.

boombatower’s picture

Would suggest that #250047: Rework the SimpleTest results interface and clean-up of backend code gets in so that the custom caller is not needed. (check that)

boombatower’s picture

Status: Needs work » Closed (duplicate)

Correct me if I'm wrong, but I believe #305077: Rework simpletest backend has this functionality now.