Rework simpletest backend

Damien Tournoud - September 7, 2008 - 12:23
Project:Drupal
Version:7.x-dev
Component:simpletest.module
Category:task
Priority:normal
Assigned:Unassigned
Status:closed
Description

As #250047: Rework the SimpleTest results interface and clean-up of backend code became a monster patch, here is an extract of the patch that only rework the backend.

Highlights:

  • Fix the backtracing logic of _assert()
  • Remove the artificial limit on the size of the 'message' field (once again a regression of the DB:TNG patch: we changed that field to be a TEXT in #293500)
  • Fixed error handling inside tests
  • Rename {simpletest}.caller to {simpletest}.function for consistency
  • Improvements to code comments and documentation

Compared to boombatower's patch:

  • I used a slightly different backtracing logic, in order to get the good caller name: for an assertion, we know return the name of the function that called the assertion, not the name of the assertion function itself.
  • I kept $custom_caller (renamed $caller), because (1) we need it for errorHandler() because we don't want to backtrace in case there is an error in an assertion function, (2) I need it for #304924: Extend drupal_error_handler to manage exceptions.
  • I revised several comments and corrected typos.
AttachmentSizeStatusTest resultOperations
simpletest-backend-rework.patch8.89 KBIgnoredNoneNone

#1

Damien Tournoud - September 7, 2008 - 12:53

After a discussion with chx on the IRC, I rewrote the backtracing logic a bit and added useful comments.

AttachmentSizeStatusTest resultOperations
simpletest-backend-rework-2.patch9.08 KBIgnoredNoneNone

#2

Damien Tournoud - September 7, 2008 - 13:22

After new dicussions with chx, I simplified the getCallerContext() method a moved it to common.inc with the name _drupal_get_last_caller(). This is for future extensibility, as it will be useful in #304924: Extend drupal_error_handler to manage exceptions.

AttachmentSizeStatusTest resultOperations
simpletest-backend-rework-3.patch9.77 KBIgnoredNoneNone

#3

Damien Tournoud - September 7, 2008 - 13:34

Here are results before and after the patch. Notice how file and line numbers were wrong: there were the line and file number of the call to the function, not those of the call to the assertion inside the function.

AttachmentSizeStatusTest resultOperations
before-rework.png156.87 KBIgnoredNoneNone
after-rework.png159.86 KBIgnoredNoneNone

#4

Damien Tournoud - September 7, 2008 - 13:57

Adds an exception handler for tests. Essentially, this is #293521: Simpletest should catch exceptions but adapted to the context of this patch.

AttachmentSizeStatusTest resultOperations
simpletest-backend-rework-4.patch10.74 KBIgnoredNoneNone

#5

Damien Tournoud - September 7, 2008 - 14:21

Again on chx' suggestion, here is a slight change in the backtracing logic: we now ignore all methods from DrupalWebTestCase, not only the assertions. The result actually looks great (see attached screenshot).

AttachmentSizeStatusTest resultOperations
new-backtracing.png176.3 KBIgnoredNoneNone
simpletest-backend-rework-5.patch10.69 KBIgnoredNoneNone

#6

Damien Tournoud - September 7, 2008 - 15:02

Here a new patch that removes two unneeded lines, and adds tests of the new backtracing code to simpletest.test.

AttachmentSizeStatusTest resultOperations
simpletest-backend-rework-6.patch15.01 KBIgnoredNoneNone

#7

chx - September 7, 2008 - 15:04
Status:needs review» reviewed & tested by the community

I run out of ideas of what to add / remove / fix and I even channeled Dries to DamZ on IRC by asking for a new test. So, I believe this is ready.

#8

boombatower - September 7, 2008 - 19:08

Errrr....can I review this...I worked on the other patch that this stems from and I not really sure I like what is going on. Don't have time at the moment, but should later.

#9

webchick - September 7, 2008 - 19:25
Status:reviewed & tested by the community» needs review

Yes, I'd like to hear your thoughts. I do agree with splitting this from the UI changes, however. That other patch is currently in discussion about buttons and placement and descriptions, and this patch looks like it fixes a lot of underlying things that will help us fix other testing system stuff in the meantime.

#10

boombatower - September 9, 2008 - 03:21
Status:needs review» reviewed & tested by the community

The patch looks good, simpletest.test passes. Just includes the back-end changes from my patch.

Once this goes in I'll work on re-rolling the other patch to reflect this, could be fun with the large overlap and slight differences. :)

#11

boombatower - September 9, 2008 - 03:26

Would probably be a good idea if someone ran all the tests.

#12

maartenvg - September 9, 2008 - 14:39

I ran all the test and everything passes, 5390 passes to be exact. :)

#13

boombatower - September 9, 2008 - 20:27

Great, looks like it is ready to go.

#14

webchick - September 9, 2008 - 20:39

I'll be taking a look at this after supper and committing it providing I don't find any remaining issues.

#15

chx - September 10, 2008 - 04:01

Just PHPdoc and indent fixes. Do not credit me.

AttachmentSizeStatusTest resultOperations
simpletest-backend-rework.patch15.22 KBIgnoredNoneNone

#16

webchick - September 10, 2008 - 04:15

Committed this, with a couple minor PHPDoc tweaks. Thanks!

Now let's get #250047: Rework the SimpleTest results interface and clean-up of backend code in. ;)

Btw, I talked over with chx that _drupal_get_last_caller($backtrace) looks like it could be generalized a bit and re-used in multiple places, if it accepts an index of how far back to parse... _db_query() does (or used to before DBTNG?) a similar thing where it grabs the "true" calling function rather than db_query() for more sensible debug messages.

Can be handled in a follow-up patch, but I'm curious about Damien's thoughts on that.

#17

webchick - September 10, 2008 - 04:15
Status:reviewed & tested by the community» fixed

#18

Damien Tournoud - September 10, 2008 - 09:50

Btw, I talked over with chx that _drupal_get_last_caller($backtrace) looks like it could be generalized a bit and re-used in multiple places.

Of course, that's exactly the plan. That's also why it is placed just below drupal_error_handler() in common.inc :) I already have a mockup of this in #304924: Extend drupal_error_handler to manage exceptions, but it will require a reroll and some more testing.

#19

Anonymous (not verified) - September 24, 2008 - 09:52
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.