author | Kyle Huey <khuey@kylehuey.com> |
Sun, 20 Feb 2011 19:54:14 -0500 | |
changeset 67600 | 1c1c1a81419ec071451bdb3ff3343e70d86f32f8 |
parent 67599 | f99b6caaaff9afe4a4b2f9d7106586125f00690b |
child 67601 | 128c34e6c3b88b7e662ae437588c7fab157fb970 |
child 67781 | 759fca16efef2ce15447109e969f5e997a355791 |
push id | 1 |
push user | root |
push date | Tue, 26 Apr 2011 22:38:44 +0000 |
treeherder | mozilla-beta@bfdb6e623a36 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | ted |
bugs | 629734 |
milestone | 2.2a1pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/testing/xpcshell/head.js +++ b/testing/xpcshell/head.js @@ -1,8 +1,9 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et: */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ @@ -18,16 +19,17 @@ * Portions created by the Initial Developer are Copyright (C) 2005 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Darin Fisher <darin@meer.net> * Boris Zbarsky <bzbarsky@mit.edu> * Jeff Walden <jwalden+code@mit.edu> * Serge Gautherie <sgautherie.bz@free.fr> + * Kyle Huey <me@kylehuey.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your @@ -43,16 +45,17 @@ * See http://developer.mozilla.org/en/docs/Writing_xpcshell-based_unit_tests * for more information. */ var _quit = false; var _passed = true; var _tests_pending = 0; var _passedChecks = 0, _falsePassedChecks = 0; +var _todoChecks = 0; var _cleanupFunctions = []; var _pendingTimers = []; function _dump(str) { if (typeof _XPCSHELL_PROCESS == "undefined") { dump(str); } else { dump(_XPCSHELL_PROCESS + ": " + str); @@ -354,16 +357,18 @@ function _execute_test() { if (!_passed) return; var truePassedChecks = _passedChecks - _falsePassedChecks; if (truePassedChecks > 0) { _dump("TEST-PASS | (xpcshell/head.js) | " + truePassedChecks + " (+ " + _falsePassedChecks + ") check(s) passed\n"); + _dump("TEST-INFO | (xpcshell/head.js) | " + _todoChecks + + " check(s) todo\n"); } else { // ToDo: switch to TEST-UNEXPECTED-FAIL when all tests have been updated. (Bug 496443) _dump("TEST-INFO | (xpcshell/head.js) | No (+ " + _falsePassedChecks + ") checks actually run\n"); } } /** * Loads files. @@ -441,16 +446,33 @@ function do_throw(text, stack) { _dump(frame + "\n"); frame = frame.caller; } _do_quit(); throw Components.results.NS_ERROR_ABORT; } +function do_throw_todo(text, stack) { + if (!stack) + stack = Components.stack.caller; + + _passed = false; + _dump("TEST-UNEXPECTED-PASS | " + stack.filename + " | " + text + + " - See following stack:\n"); + var frame = Components.stack; + while (frame != null) { + _dump(frame + "\n"); + frame = frame.caller; + } + + _do_quit(); + throw Components.results.NS_ERROR_ABORT; +} + function do_report_unexpected_exception(ex, text) { var caller_stack = Components.stack.caller; text = text ? text + " - " : ""; _passed = false; dump("TEST-UNEXPECTED-FAIL | " + caller_stack.filename + " | " + text + "Unexpected exception " + ex + ", see following stack:\n" + ex.stack + "\n"); @@ -463,58 +485,120 @@ function do_note_exception(ex, text) { var caller_stack = Components.stack.caller; text = text ? text + " - " : ""; dump("TEST-INFO | " + caller_stack.filename + " | " + text + "Swallowed exception " + ex + ", see following stack:\n" + ex.stack + "\n"); } -function do_check_neq(left, right, stack) { +function _do_check_neq(left, right, stack, todo) { if (!stack) stack = Components.stack.caller; var text = left + " != " + right; if (left == right) { - do_throw(text, stack); + if (!todo) { + do_throw(text, stack); + } else { + ++_todoChecks; + _dump("TEST-KNOWN-FAIL | " + stack.filename + " | [" + stack.name + + " : " + stack.lineNumber + "] " + text +"\n"); + } } else { - ++_passedChecks; - _dump("TEST-PASS | " + stack.filename + " | [" + stack.name + " : " + - stack.lineNumber + "] " + text + "\n"); + if (!todo) { + ++_passedChecks; + _dump("TEST-PASS | " + stack.filename + " | [" + stack.name + " : " + + stack.lineNumber + "] " + text + "\n"); + } else { + do_throw_todo(text, stack); + } + } +} + +function do_check_neq(left, right, stack) { + if (!stack) + stack = Components.stack.caller; + + _do_check_neq(left, right, stack, false); +} + +function todo_check_neq(left, right, stack) { + if (!stack) + stack = Components.stack.caller; + + _do_check_neq(left, right, stack, true); +} + +function _do_check_eq(left, right, stack, todo) { + if (!stack) + stack = Components.stack.caller; + + var text = left + " == " + right; + if (left != right) { + if (!todo) { + do_throw(text, stack); + } else { + ++_todoChecks; + _dump("TEST-KNOWN-FAIL | " + stack.filename + " | [" + stack.name + + " : " + stack.lineNumber + "] " + text +"\n"); + } + } else { + if (!todo) { + ++_passedChecks; + _dump("TEST-PASS | " + stack.filename + " | [" + stack.name + " : " + + stack.lineNumber + "] " + text + "\n"); + } else { + do_throw_todo(text, stack); + } } } function do_check_eq(left, right, stack) { if (!stack) stack = Components.stack.caller; - var text = left + " == " + right; - if (left != right) { - do_throw(text, stack); - } else { - ++_passedChecks; - _dump("TEST-PASS | " + stack.filename + " | [" + stack.name + " : " + - stack.lineNumber + "] " + text + "\n"); - } + _do_check_eq(left, right, stack, false); +} + +function todo_check_eq(left, right, stack) { + if (!stack) + stack = Components.stack.caller; + + _do_check_eq(left, right, stack, true); } function do_check_true(condition, stack) { if (!stack) stack = Components.stack.caller; do_check_eq(condition, true, stack); } +function todo_check_true(condition, stack) { + if (!stack) + stack = Components.stack.caller; + + todo_check_eq(condition, true, stack); +} + function do_check_false(condition, stack) { if (!stack) stack = Components.stack.caller; do_check_eq(condition, false, stack); } +function todo_check_false(condition, stack) { + if (!stack) + stack = Components.stack.caller; + + todo_check_eq(condition, false, stack); +} + function do_test_pending() { ++_tests_pending; _dump("TEST-INFO | (xpcshell/head.js) | test " + _tests_pending + " pending\n"); } function do_test_finished() {