Revision: 5415
Author:   [email protected]
Date:     Tue May 21 12:08:41 2013
Log:      Remove "testNop"s and recognize skipped tests.
https://codereview.appspot.com/9617043

* Remove "testNop"s from test files with skipped tests.
* jsunit.js doesn't die if all tests are skipped.
* Meta tests for no tests or only skipped tests.

[email protected]

http://code.google.com/p/google-caja/source/detail?r=5415

Added:
 /trunk/tests/com/google/caja/plugin/meta-test-no-tests.js
 /trunk/tests/com/google/caja/plugin/meta-test-skipped-test.js
Modified:
 /trunk/tests/com/google/caja/plugin/es53-test-css-imports-guest.html
 /trunk/tests/com/google/caja/plugin/es53-test-external-script-guest.html
 /trunk/tests/com/google/caja/plugin/es53-test-inline-script.html
 /trunk/tests/com/google/caja/plugin/jsunit.js
 /trunk/tests/com/google/caja/plugin/meta-test.js

=======================================
--- /dev/null
+++ /trunk/tests/com/google/caja/plugin/meta-test-no-tests.js Tue May 21 12:08:41 2013
@@ -0,0 +1,22 @@
+// Copyright (C) 2013 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Used by meta-test.js for testing our test framework.
+//
+// Contains no tests to confirm detection of failure to register any tests.
+
+// Cajoler NullPointerException-s on an empty-but-for-comments input.
+// TODO(kpreid): Remove this when ES5/3 is dead, or fix the underlying bug.
+undefined;
+
=======================================
--- /dev/null
+++ /trunk/tests/com/google/caja/plugin/meta-test-skipped-test.js Tue May 21 12:08:41 2013
@@ -0,0 +1,20 @@
+// Copyright (C) 2013 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Used by meta-test.js for testing our test framework.
+//
+// Contains a single skipped test to confirm that a test suite with only skipped
+// tests is OK.
+
+jsunitRegisterIf(false, 'skippedTest', function() {});
=======================================
--- /trunk/tests/com/google/caja/plugin/es53-test-css-imports-guest.html Sat May 11 15:02:28 2013 +++ /trunk/tests/com/google/caja/plugin/es53-test-css-imports-guest.html Tue May 21 12:08:41 2013
@@ -65,8 +65,5 @@

    pass('testCssImports');
   });
-
-  // jsunit complains if there are zero tests
-  jsunitRegister('testNop', function testNop() { pass('testNop'); });
 </script>
 </div>
=======================================
--- /trunk/tests/com/google/caja/plugin/es53-test-external-script-guest.html Mon Apr 29 12:40:55 2013 +++ /trunk/tests/com/google/caja/plugin/es53-test-external-script-guest.html Tue May 21 12:08:41 2013
@@ -78,7 +78,4 @@
     });
     pass('testExternalScripts');
   });
-
-  // jsunit complains if there are zero tests
-  jsunitRegister('testNop', function testNop() { pass('testNop'); });
 </script>
=======================================
--- /trunk/tests/com/google/caja/plugin/es53-test-inline-script.html Wed Jan 2 12:22:56 2013 +++ /trunk/tests/com/google/caja/plugin/es53-test-inline-script.html Tue May 21 12:08:41 2013
@@ -48,7 +48,4 @@
     assertEquals('Full text', 'trailing line comment', window.result);
     pass('testTrailingLineComment');
   });
-
-  // jsunit complains if there are zero tests
-  jsunitRegister('testNop', function testNop() { pass('testNop'); });
 </script>
=======================================
--- /trunk/tests/com/google/caja/plugin/jsunit.js       Fri May 17 17:46:31 2013
+++ /trunk/tests/com/google/caja/plugin/jsunit.js       Tue May 21 12:08:41 2013
@@ -37,6 +37,7 @@
 jsunit.testCount = 0;
 jsunit.passCount = 0;
 jsunit.failCount = 0;
+jsunit.skippedCount = 0;
 jsunit.testIdStack = [];
 jsunit.baseTitle = undefined;
 jsunit.asyncPoll = 50;
@@ -174,6 +175,7 @@
     // interact with the resultContainer
     jsunitFinished(testName, 'skipped');
     delete jsunit.tests[testName];
+    jsunit.skippedCount++;
   }
 }

@@ -258,7 +260,7 @@
     }
   }

-  if (jsunit.testCount === 0) {
+  if (jsunit.testCount === 0 && jsunit.skippedCount === 0) {
     jsunit.panic('No tests registered!', true);
   }

=======================================
--- /trunk/tests/com/google/caja/plugin/meta-test.js Mon Apr 29 12:40:55 2013 +++ /trunk/tests/com/google/caja/plugin/meta-test.js Tue May 21 12:08:41 2013
@@ -172,5 +172,29 @@
   });
 });

+jsunitRegister('testNoTests', function testNoTests() {
+  var w = makeMetaTestFrame('case', 'meta-test-no-tests.js');
+  pollStatus(w, function(state, pass, fail, total) {
+    assertNotEquals('pass', state);
+    if (state === 'fail') {
+      assertEquals('pass', 0, pass);
+      assertEquals('fail', 1, fail);
+      jsunitPass('testNoTests');
+    }
+  });
+});
+
+jsunitRegister('testOnlySkippedTests', function testOnlySkippedTests() {
+  var w = makeMetaTestFrame('case', 'meta-test-skipped-test.js');
+  pollStatus(w, function(state, pass, fail, total) {
+    assertNotEquals('fail', state);
+    if (state === 'pass') {
+      assertEquals('pass', 0, pass);
+      assertEquals('fail', 0, fail);
+      jsunitPass('testOnlySkippedTests');
+    }
+  });
+});
+
 readyToTest();
 jsunitRun();

--

--- You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to