Closed Bug 648127 Opened 13 years ago Closed 13 years ago

A test failure right after something is dumped without a trailing \n goes unnoticed

Categories

(Testing :: XPCShell Harness, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla6

People

(Reporter: rain1, Assigned: rain1)

References

Details

Attachments

(1 file, 3 obsolete files)

Attached patch WIP (obsolete) — Splinter Review
STR:
Create an xpcshell test with the following code:

function run_test() {
  dump("foo");
  do_check_true(false);
}

The test will pass even though it should fail.

Attached is a WIP patch that prints newlines before each TEST-UNEXPECTED-FAIL, per ted's recommendation. The patch is currently running through the tryserver.

Jason, you wrote the code that prints parent/child for xpcshell tests. Do you know why some but not all the TEST-UNEXPECTED-FAIL statements use _dump()?
Attached patch patch, v1 (obsolete) — Splinter Review
Attachment #524271 - Attachment is obsolete: true
Attachment #524439 - Flags: review?(ted.mielczarek)
Attachment #524439 - Flags: review?(ted.mielczarek) → review+
Attached patch Patch to check in (obsolete) — Splinter Review
I'm a bit short on time to tend to the tree right now, so it'd be great if someone else checked this in.
Keywords: checkin-needed
Comment on attachment 526715 [details] [diff] [review]
Patch to check in

The "newline" parameter strikes me as gross.

What we're trying to do here is make sure any TEST-UNEXPECTED-FAIL shows up at the start of a line.  Seems cleaner to just add a "test_unexpected_fail()" function that prepends "\nTEST-UNEXPECTED-FAIL | " (or "\nTEST-UNEXPECTED-FAIL | (xpcshell/head.js) | ": we're not consistent in our usage) to whatever string it gets.
> why some but not all the TEST-UNEXPECTED-FAIL statements use _dump()?

They should all use _dump, as should any "top-level" logging statement (i.e. printing "TEST-INFO" should use it on line 488, but is currently using dump: let's fix that), but if you're just printing supplemental info for a previous _dump (like dumping out stack info) you can use dump if you don't want each line to state if it comes from the parent or child.
(In reply to comment #4)
> Comment on attachment 526715 [details] [diff] [review]
> Patch to check in
> 
> The "newline" parameter strikes me as gross.
> 
> What we're trying to do here is make sure any TEST-UNEXPECTED-FAIL shows up at
> the start of a line.  Seems cleaner to just add a "test_unexpected_fail()"
> function that prepends "\nTEST-UNEXPECTED-FAIL | " (or "\nTEST-UNEXPECTED-FAIL
> | (xpcshell/head.js) | ": we're not consistent in our usage) to whatever string
> it gets.

Yeah the newline parameter was a hack. I'll put up an updated patch when I have the chance.
Keywords: checkin-needed
Maybe an even simpler idea:  just have _dump check for 'TEST-' at start of message, and print \n first if it's a match.   That would ensure that all the TEST- results start on a newline, not just TEST-UNEXPECTED-FAILURE.
Attached patch patch v2Splinter Review
Yeah, that sounds best.
Attachment #524439 - Attachment is obsolete: true
Attachment #526715 - Attachment is obsolete: true
Attachment #528205 - Flags: review?(ted.mielczarek)
Comment on attachment 528205 [details] [diff] [review]
patch v2

Review of attachment 528205 [details] [diff] [review]:

This is fine too.
Attachment #528205 - Flags: review?(ted.mielczarek) → review+
https://hg.mozilla.org/mozilla-central/rev/8f79761f3ea6
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla6
Depends on: 656099
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: