Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1006)

Side by Side Diff: pkg/dev_compiler/test/browser/language_tests.js

Issue 2789933002: Add runtime tests for ignored checks (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/dev_compiler/test/browser/runtime_tests.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 define(['dart_sdk', 'async_helper', 'expect', 'unittest', 'is', 'require'], 5 define(['dart_sdk', 'async_helper', 'expect', 'unittest', 'is', 'require'],
6 function(dart_sdk, async_helper, expect, unittest, is, require) { 6 function(dart_sdk, async_helper, expect, unittest, is, require) {
7 'use strict'; 7 'use strict';
8 8
9 async_helper = async_helper.async_helper; 9 async_helper = async_helper.async_helper;
10 let minitest = expect.minitest; 10 let minitest = expect.minitest;
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 } 853 }
854 854
855 // We run these tests in a mocha test wrapper to avoid the confusing failure 855 // We run these tests in a mocha test wrapper to avoid the confusing failure
856 // case of dart unittests being interleaved with mocha tests. 856 // case of dart unittests being interleaved with mocha tests.
857 // In practice we are really just suppressing all mocha test behavior while 857 // In practice we are really just suppressing all mocha test behavior while
858 // Dart unittests run and then re-enabling it when the dart tests complete. 858 // Dart unittests run and then re-enabling it when the dart tests complete.
859 html_config.useHtmlConfiguration(); 859 html_config.useHtmlConfiguration();
860 test('run all dart unittests', function(done) { // 'function' to allow `this.t imeout` 860 test('run all dart unittests', function(done) { // 'function' to allow `this.t imeout`
861 // Use the whitelist for all unittests - there may be an error in the framew ork 861 // Use the whitelist for all unittests - there may be an error in the framew ork
862 // itself. 862 // itself.
863 dart_sdk.dart.ignoreWhitelistedErrors(whitelist); 863 dart_sdk.dart.ignoreWhitelistedErrors(true);
864 if (unittest_tests.length == 0) return done(); 864 if (unittest_tests.length == 0) return done();
865 865
866 // TODO(vsm): We're using an old deprecated version of unittest. 866 // TODO(vsm): We're using an old deprecated version of unittest.
867 // We need to migrate all tests (in the SDK itself) off of 867 // We need to migrate all tests (in the SDK itself) off of
868 // unittest. 868 // unittest.
869 869
870 // All unittests need to be explicitly marked as such above. If 870 // All unittests need to be explicitly marked as such above. If
871 // not, the unittest framework will be run in a 'normal' test and 871 // not, the unittest framework will be run in a 'normal' test and
872 // left in an inconsistent state at this point triggering spurious 872 // left in an inconsistent state at this point triggering spurious
873 // failures. This check ensures we're not in such a state. If it fails, 873 // failures. This check ensures we're not in such a state. If it fails,
874 // we've likely added a new unittest and need to categorize it as such. 874 // we've likely added a new unittest and need to categorize it as such.
875 if (unittest.src__test_environment.environment.testCases[dart_sdk.dartx.leng th] != 0) { 875 if (unittest.src__test_environment.environment.testCases[dart_sdk.dartx.leng th] != 0) {
876 return done(new Error('Unittest framework in an invalid state')); 876 return done(new Error('Unittest framework in an invalid state'));
877 } 877 }
878 878
879 this.timeout(100000000); 879 this.timeout(100000000);
880 this.enableTimeouts(false); 880 this.enableTimeouts(false);
881 // Suppress mocha on-error handling because it will mess up unittests. 881 // Suppress mocha on-error handling because it will mess up unittests.
882 window.onerror = function(err, url, line) { 882 window.onerror = function(err, url, line) {
883 console.error(err, url, line); 883 console.error(err, url, line);
884 }; 884 };
885 window.addEventListener('message', (event) => { 885 window.addEventListener('message', (event) => {
886 if (event.data == 'unittest-suite-done') { 886 if (event.data == 'unittest-suite-done') {
887 window.console.log("Done running unittests"); 887 window.console.log("Done running unittests");
888 let output = document.body.textContent; 888 let output = document.body.textContent;
889 // Restore the Mocha onerror handler in case future tests need to run. 889 // Restore the Mocha onerror handler in case future tests need to run.
890 window.onerror = mochaOnError; 890 window.onerror = mochaOnError;
891 this.enableTimeouts(true); 891 this.enableTimeouts(true);
892 dart_sdk.dart.ignoreWhitelistedErrors(false);
892 893
893 let numErrors = countMatches(output, /\d\s+ERROR/g); 894 let numErrors = countMatches(output, /\d\s+ERROR/g);
894 let numFails = countMatches(output, /\d\s+FAIL/g); 895 let numFails = countMatches(output, /\d\s+FAIL/g);
895 if (numErrors != num_expected_unittest_errors || 896 if (numErrors != num_expected_unittest_errors ||
896 numFails != num_expected_unittest_fails) { 897 numFails != num_expected_unittest_fails) {
897 output = "Expected " + num_expected_unittest_fails + 898 output = "Expected " + num_expected_unittest_fails +
898 " fail and " + num_expected_unittest_errors + 899 " fail and " + num_expected_unittest_errors +
899 " error unittests, got " + numFails + " fail and " + 900 " error unittests, got " + numFails + " fail and " +
900 numErrors + "error tests.\n" + output; 901 numErrors + "error tests.\n" + output;
901 console.error(output); 902 console.error(output);
902 done(new Error(output)); 903 done(new Error(output));
903 } else { 904 } else {
904 console.log(output); 905 console.log(output);
905 done(); 906 done();
906 } 907 }
907 } 908 }
908 }); 909 });
909 910
910 for (let action of unittest_tests) { 911 for (let action of unittest_tests) {
911 try { 912 try {
912 action(); 913 action();
913 } catch (e) { 914 } catch (e) {
914 console.error("Caught error tying to setup test:", e); 915 console.error("Caught error tying to setup test:", e);
915 } 916 }
916 } 917 }
917 }); 918 });
918 }); 919 });
OLDNEW
« no previous file with comments | « no previous file | pkg/dev_compiler/test/browser/runtime_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698