Bug 1421992 - Remove obsolete do_check_* implementations, r=Gijs.
authorFlorian Quèze <florian@queze.net>
Thu, 21 Dec 2017 11:08:21 +0100
changeset 448875 294d79abd65f7a32be03f6cbbcd3a9e29e9aa814
parent 448874 59b1ac8778fc3681da47740dde698070175456a4
child 448876 5580c205d9c418fc5e66c517ca0f4152c78b697f
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1421992
milestone59.0a1
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
Bug 1421992 - Remove obsolete do_check_* implementations, r=Gijs.
testing/xpcshell/head.js
testing/xpcshell/selftest.py
tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js
--- a/testing/xpcshell/head.js
+++ b/testing/xpcshell/head.js
@@ -812,34 +812,16 @@ function do_note_exception(ex, text) {
   let filename = Components.stack.caller.filename;
   _testLogger.info(text + "Swallowed exception " + _exception_message(ex),
                    {
                      source_file: filename,
                      stack: _format_stack(ex.stack)
                    });
 }
 
-function _do_check_neq(left, right, stack, todo) {
-  Assert.notEqual(left, right);
-}
-
-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_report_result(passed, text, stack, todo) {
   while (stack.filename.includes("head.js") && stack.caller) {
     stack = stack.caller;
   }
 
   let name = _gRunningTest ? _gRunningTest.name : stack.name;
   let message;
   if (name) {
@@ -885,59 +867,40 @@ function _do_check_eq(left, right, stack
   if (!stack)
     stack = Components.stack.caller;
 
   var text = _wrap_with_quotes_if_necessary(left) + " == " +
              _wrap_with_quotes_if_necessary(right);
   do_report_result(left == right, text, stack, todo);
 }
 
-function do_check_eq(left, right, stack) {
-  Assert.equal(left, right);
-}
-
 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) {
-  Assert.ok(condition, 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) {
-  Assert.ok(!condition, stack);
-}
-
 function todo_check_false(condition, stack) {
   if (!stack)
     stack = Components.stack.caller;
 
   todo_check_eq(condition, false, stack);
 }
 
-function do_check_null(condition, stack) {
-  Assert.equal(condition, null);
-}
-
 function todo_check_null(condition, stack = Components.stack.caller) {
   todo_check_eq(condition, null, stack);
 }
-function do_check_matches(pattern, value) {
-  Assert.deepEqual(pattern, value);
-}
 
 // Check that |func| throws an nsIException that has
 // |Components.results[resultName]| as the value of its 'result' property.
 function do_check_throws_nsIException(func, resultName,
                                       stack = Components.stack.caller, todo = false) {
   let expected = Components.results[resultName];
   if (typeof expected !== "number") {
     do_throw("do_check_throws_nsIException requires a Components.results" +
--- a/testing/xpcshell/selftest.py
+++ b/testing/xpcshell/selftest.py
@@ -35,50 +35,50 @@ if mozinfo.isMac:
 else:
     xpcshellBin = os.path.join(objdir, "dist", "bin", "xpcshell")
     if sys.platform == "win32":
         xpcshellBin += ".exe"
 
 TEST_PASS_STRING = "TEST-PASS"
 TEST_FAIL_STRING = "TEST-UNEXPECTED-FAIL"
 
-SIMPLE_PASSING_TEST = "function run_test() { do_check_true(true); }"
-SIMPLE_FAILING_TEST = "function run_test() { do_check_true(false); }"
+SIMPLE_PASSING_TEST = "function run_test() { Assert.ok(true); }"
+SIMPLE_FAILING_TEST = "function run_test() { Assert.ok(false); }"
 
 SIMPLE_UNCAUGHT_REJECTION_TEST = '''
 function run_test() {
   Promise.reject(new Error("Test rejection."));
-  do_check_true(true);
+  Assert.ok(true);
 }
 '''
 
 SIMPLE_UNCAUGHT_REJECTION_JSM_TEST = '''
 Components.utils.import("resource://gre/modules/Promise.jsm");
 
 Promise.reject(new Error("Test rejection."));
 
 function run_test() {
-  do_check_true(true);
+  Assert.ok(true);
 }
 '''
 
 ADD_TEST_SIMPLE = '''
 function run_test() { run_next_test(); }
 
 add_test(function test_simple() {
-  do_check_true(true);
+  Assert.ok(true);
   run_next_test();
 });
 '''
 
 ADD_TEST_FAILING = '''
 function run_test() { run_next_test(); }
 
 add_test(function test_failing() {
-  do_check_true(false);
+  Assert.ok(false);
   run_next_test();
 });
 '''
 
 ADD_TEST_UNCAUGHT_REJECTION = '''
 function run_test() { run_next_test(); }
 
 add_test(function test_uncaught_rejection() {
@@ -147,17 +147,17 @@ add_test(function test_loop () {
   do_test_pending()
 });
 '''
 
 PASSING_TEST_UNICODE = '''
 function run_test () { run_next_test(); }
 
 add_test(function test_unicode_print () {
-  do_check_eq("\u201c\u201d", "\u201c\u201d");
+  Assert.equal("\u201c\u201d", "\u201c\u201d");
   run_next_test();
 });
 '''
 
 ADD_TASK_SINGLE = '''
 Components.utils.import("resource://gre/modules/Promise.jsm");
 
 function run_test() { run_next_test(); }
@@ -195,17 +195,17 @@ add_task(function* test_failing() {
 ADD_TASK_FAILURE_INSIDE = '''
 Components.utils.import("resource://gre/modules/Promise.jsm");
 
 function run_test() { run_next_test(); }
 
 add_task(function* test() {
   let result = yield Promise.resolve(false);
 
-  do_check_true(result);
+  Assert.ok(result);
 });
 '''
 
 ADD_TASK_RUN_NEXT_TEST = '''
 function run_test() { run_next_test(); }
 
 add_task(function () {
   Assert.ok(true);
@@ -329,17 +329,17 @@ ASYNC_CLEANUP = '''
 function run_test() {
   Components.utils.import("resource://gre/modules/Promise.jsm", this);
 
   // The list of checkpoints in the order we encounter them.
   let checkpoints = [];
 
   // Cleanup tasks, in reverse order
   do_register_cleanup(function cleanup_checkout() {
-    do_check_eq(checkpoints.join(""), "123456");
+    Assert.equal(checkpoints.join(""), "123456");
     do_print("At this stage, the test has succeeded");
     do_throw("Throwing an error to force displaying the log");
   });
 
   do_register_cleanup(function sync_cleanup_2() {
     checkpoints.push(6);
   });
 
@@ -374,56 +374,56 @@ function run_test() {
   });
 
 }
 '''
 
 # A test to check that add_test() tests run without run_test()
 NO_RUN_TEST_ADD_TEST = '''
 add_test(function no_run_test_add_test() {
-  do_check_true(true);
+  Assert.ok(true);
   run_next_test();
 });
 '''
 
 # A test to check that add_task() tests run without run_test()
 NO_RUN_TEST_ADD_TASK = '''
 add_task(function no_run_test_add_task() {
-  do_check_true(true);
+  Assert.ok(true);
 });
 '''
 
 # A test to check that both add_task() and add_test() work without run_test()
 NO_RUN_TEST_ADD_TEST_ADD_TASK = '''
 add_test(function no_run_test_add_test() {
-  do_check_true(true);
+  Assert.ok(true);
   run_next_test();
 });
 
 add_task(function no_run_test_add_task() {
-  do_check_true(true);
+  Assert.ok(true);
 });
 '''
 
 # A test to check that an empty test file without run_test(),
 # add_test() or add_task() works.
 NO_RUN_TEST_EMPTY_TEST = '''
 // This is an empty test file.
 '''
 
 NO_RUN_TEST_ADD_TEST_FAIL = '''
 add_test(function no_run_test_add_test_fail() {
-  do_check_true(false);
+  Assert.ok(false);
   run_next_test();
 });
 '''
 
 NO_RUN_TEST_ADD_TASK_FAIL = '''
 add_task(function no_run_test_add_task_fail() {
-  do_check_true(false);
+  Assert.ok(false);
 });
 '''
 
 NO_RUN_TEST_ADD_TASK_MULTIPLE = '''
 Components.utils.import("resource://gre/modules/Promise.jsm");
 
 add_task(function* test_task() {
   yield Promise.resolve(true);
@@ -431,18 +431,18 @@ add_task(function* test_task() {
 
 add_task(function* test_2() {
   yield Promise.resolve(true);
 });
 '''
 
 LOAD_MOZINFO = '''
 function run_test() {
-  do_check_neq(typeof mozinfo, undefined);
-  do_check_neq(typeof mozinfo.os, undefined);
+  Assert.notEqual(typeof mozinfo, undefined);
+  Assert.notEqual(typeof mozinfo.os, undefined);
 }
 '''
 
 CHILD_MOZINFO = '''
 function run_test () { run_next_test(); }
 
 add_test(function test_child_mozinfo () {
   run_test_in_child("test_mozinfo.js");
@@ -680,17 +680,17 @@ tail =
     def testSkipForAddTest(self):
         """
         Check that add_test is skipped if |skip_if| condition is true
         """
         self.writeFile("test_skip.js", """
 add_test({
   skip_if: () => true,
 }, function test_should_be_skipped() {
-  do_check_true(false);
+  Assert.ok(false);
   run_next_test();
 });
 """)
         self.writeManifest(["test_skip.js"])
         self.assertTestResult(True, verbose=True)
         self.assertEquals(1, self.x.testCount)
         self.assertEquals(1, self.x.passCount)
         self.assertEquals(0, self.x.failCount)
@@ -702,17 +702,17 @@ add_test({
     def testNotSkipForAddTask(self):
         """
         Check that add_task is not skipped if |skip_if| condition is false
         """
         self.writeFile("test_not_skip.js", """
 add_task({
   skip_if: () => false,
 }, function test_should_not_be_skipped() {
-  do_check_true(true);
+  Assert.ok(true);
 });
 """)
         self.writeManifest(["test_not_skip.js"])
         self.assertTestResult(True, verbose=True)
         self.assertEquals(1, self.x.testCount)
         self.assertEquals(1, self.x.passCount)
         self.assertEquals(0, self.x.failCount)
         self.assertEquals(0, self.x.todoCount)
@@ -723,17 +723,17 @@ add_task({
     def testSkipForAddTask(self):
         """
         Check that add_task is skipped if |skip_if| condition is true
         """
         self.writeFile("test_skip.js", """
 add_task({
   skip_if: () => true,
 }, function test_should_be_skipped() {
-  do_check_true(false);
+  Assert.ok(false);
 });
 """)
         self.writeManifest(["test_skip.js"])
         self.assertTestResult(True, verbose=True)
         self.assertEquals(1, self.x.testCount)
         self.assertEquals(1, self.x.passCount)
         self.assertEquals(0, self.x.failCount)
         self.assertEquals(0, self.x.todoCount)
@@ -744,17 +744,17 @@ add_task({
     def testNotSkipForAddTest(self):
         """
         Check that add_test is not skipped if |skip_if| condition is false
         """
         self.writeFile("test_not_skip.js", """
 add_test({
   skip_if: () => false,
 }, function test_should_not_be_skipped() {
-  do_check_true(true);
+  Assert.ok(true);
   run_next_test();
 });
 """)
         self.writeManifest(["test_not_skip.js"])
         self.assertTestResult(True, verbose=True)
         self.assertEquals(1, self.x.testCount)
         self.assertEquals(1, self.x.passCount)
         self.assertEquals(0, self.x.failCount)
@@ -938,17 +938,17 @@ add_test({
         Make sure a meaningful filename and line number is logged
         by a passing test.
         """
         self.writeFile("test_add_test_simple.js", ADD_TEST_SIMPLE)
         self.writeManifest(["test_add_test_simple.js"])
 
         self.assertTestResult(True, verbose=True)
         self.assertInLog("true == true")
-        self.assertNotInLog("[do_check_true :")
+        self.assertNotInLog("[Assert.ok :")
         self.assertInLog("[test_simple : 5]")
 
     def testAddTestFailing(self):
         """
         Ensure add_test() with a failing test is reported.
         """
         self.writeFile("test_add_test_failing.js", ADD_TEST_FAILING)
         self.writeManifest(["test_add_test_failing.js"])
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js
@@ -6,23 +6,17 @@ module.exports = {
   "globals": {
     "Assert": false,
     "PromiseDebugging": false,
     "_TEST_FILE": false,
     "add_task": false,
     "add_test": false,
     "deepEqual": false,
     "do_await_remote_message": false,
-    "do_check_eq": false,
-    "do_check_false": false,
     "do_check_instanceof": false,
-    "do_check_matches": false,
-    "do_check_neq": false,
-    "do_check_null": false,
-    "do_check_true": false,
     "do_execute_soon": false,
     "do_get_cwd": false,
     "do_get_file": false,
     "do_get_idle": false,
     "do_get_profile": false,
     "do_get_tempdir": false,
     "do_load_child_test_harness": false,
     "do_load_manifest": false,