Closed Bug 680039 Opened 13 years ago Closed 13 years ago

Add stack traces to soft assertion failures

Categories

(Mozilla QA Graveyard :: Mozmill Tests, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: davehunt, Assigned: whimboo)

References

Details

(Whiteboard: [lib])

Attachments

(2 files, 1 obsolete file)

Soft assertions (expects) don't currently have any stack traces when they fail.
Attached patch Patch v1 (API refactor) (obsolete) — Splinter Review
This patch adds stack information to the soft assertion failures. I strip away unwanted properties from the stack, e.g. languageName, which we don't really need. The stack looks a bit different to the one we get with Error().stack. That's something we should investigate later.
Assignee: nobody → hskupin
Status: NEW → ASSIGNED
Attachment #554424 - Flags: review?(gmealer)
Comment on attachment 554424 [details] [diff] [review]
Patch v1 (API refactor)

The code's fine. 

The algorithm is confusing, though. If you don't realize frame and stack are the same structure via copy-by-reference you wonder why all this modification is going on with frame, then stack is returned. Plus you do the same thing with frame on one side and stack on the other, when it's really keeping two stacks in sync.

May help if you had an aFrame reference to aStack that you used inside the while so you're copying frame to frame instead of stack to frame. Comments could help too:

var stack = { };     // new stack to be returned
var frame = stack    // frame being built in new stack, start at base.
var aFrame = aStack; // frame being copied from old stack, start at base.

while (aFrame) {
  frame.caller = null;
  frame.filename = aFrame.filename;
  ...
  // If there's more stack to process, create the next frame

  if (aFrame.caller)
    frame.caller = { };

  // Go to the next frames in each stack
  aFrame = aFrame.caller;
  frame = frame.caller;
}

Even better, use oldFrame/newFrame/newStack instead of aFrame/frame/stack. stack vs. aStack doesn't have any meaning distinguishing them, same with frame vs. aFrame.

r=me with it made a little clearer. Should be pretty quick, and no re-review required from me unless the change is more complex than above.
Attachment #554424 - Flags: review?(gmealer) → review+
Thanks Geo. Yeah, sorry that I haven't really added some documentation beside the code. I now make use of better variable names. Taking over r+.
Attachment #554424 - Attachment is obsolete: true
Attachment #555101 - Flags: review+
Comment on attachment 555101 [details] [diff] [review]
Patch v2 (API refactor) [checked-in]

Landed as:
https://github.com/geoelectric/mozmill-api-refactor/commit/68ce4a248d066d7b41a3c6a76744efc8a18f3461
Attachment #555101 - Attachment description: Patch v2 → Patch v2 (API refactor) [checked-in]
Port to our current shared modules.
Attachment #555105 - Flags: review?(gmealer)
Blocks: 681347
Comment on attachment 555105 [details] [diff] [review]
Patch v1 (Old API)

I like the revised variable names--everything's much clearer. r+ for this patch, too.
Attachment #555105 - Flags: review?(gmealer) → review+
Component: Mozmill Shared Modules → Mozmill Tests
Whiteboard: [lib]
Product: Mozilla QA → Mozilla QA Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: