Chromium Code Reviews| OLD | NEW |
|---|---|
| 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', 'unittest', 'require'], | 5 define(['dart_sdk', 'async_helper', 'unittest', 'require'], |
| 6 function(dart_sdk, async_helper, unittest, require) { | 6 function(dart_sdk, async_helper, unittest, require) { |
| 7 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 async_helper = async_helper.async_helper; | 9 async_helper = async_helper.async_helper; |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 // there are a lot of broken html unittests. | 29 // there are a lot of broken html unittests. |
| 30 let num_expected_unittest_fails = 3; | 30 let num_expected_unittest_fails = 3; |
| 31 let num_expected_unittest_errors = 2; | 31 let num_expected_unittest_errors = 2; |
| 32 | 32 |
| 33 // TODO(jmesserly): separate StrongModeError from other errors. | 33 // TODO(jmesserly): separate StrongModeError from other errors. |
| 34 let all_status = { | 34 let all_status = { |
| 35 'language': { | 35 'language': { |
| 36 'assert_with_type_test_or_cast_test': skip_fail, | 36 'assert_with_type_test_or_cast_test': skip_fail, |
| 37 'assertion_test': skip_fail, | 37 'assertion_test': skip_fail, |
| 38 'async_await_test_none_multi': 'unittest', | 38 'async_await_test_none_multi': 'unittest', |
| 39 'async_await_test_02_multi': 'unittest', | |
| 39 'async_await_test_03_multi': skip_fail, // Flaky on travis (#634) | 40 'async_await_test_03_multi': skip_fail, // Flaky on travis (#634) |
| 40 'async_star_await_pauses_test': skip_fail, | 41 'async_star_await_pauses_test': skip_fail, |
| 41 | 42 |
| 42 // TODO(jmesserly): figure out why this test is hanging. | 43 // TODO(jmesserly): figure out why this test is hanging. |
| 43 'async_star_cancel_and_throw_in_finally_test': skip_timeout, | 44 'async_star_cancel_and_throw_in_finally_test': skip_timeout, |
| 44 | 45 |
| 45 'async_star_cancel_while_paused_test': skip_fail, | 46 'async_star_cancel_while_paused_test': skip_fail, |
| 46 'async_star_regression_fisk_test': skip_fail, | 47 'async_star_regression_fisk_test': skip_fail, |
| 47 | 48 |
| 48 // TODO(vsm): Re-enable. | 49 // TODO(vsm): Re-enable. |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 'default_arguments_test': fail | 384 'default_arguments_test': fail |
| 384 }, | 385 }, |
| 385 | 386 |
| 386 'lib/convert': { | 387 'lib/convert': { |
| 387 'encoding_test': skip_timeout, | 388 'encoding_test': skip_timeout, |
| 388 | 389 |
| 389 // TODO(jmesserly): this is in an inconsistent state between our old and | 390 // TODO(jmesserly): this is in an inconsistent state between our old and |
| 390 // newer SDKs. | 391 // newer SDKs. |
| 391 'html_escape_test': ['skip'], | 392 'html_escape_test': ['skip'], |
| 392 | 393 |
| 393 // TODO(rnystrom): If this test is enabled, karma gets confused and | 394 'json_lib_test': 'unittest', |
| 394 // disconnects randomly. | |
| 395 'json_lib_test': skip_fail, | |
| 396 | 395 |
| 397 'json_utf8_chunk_test': skip_timeout, | 396 'json_utf8_chunk_test': skip_timeout, |
| 398 'latin1_test': skip_timeout, | 397 'latin1_test': skip_timeout, |
| 399 | 398 |
| 400 'streamed_conversion_json_encode1_test': skip_timeout, | 399 'streamed_conversion_json_encode1_test': skip_timeout, |
| 401 'streamed_conversion_json_utf8_decode_test': skip_timeout, | 400 'streamed_conversion_json_utf8_decode_test': skip_timeout, |
| 402 'streamed_conversion_json_utf8_encode_test': skip_timeout, | 401 'streamed_conversion_json_utf8_encode_test': skip_timeout, |
| 403 'streamed_conversion_utf8_decode_test': skip_timeout, | 402 'streamed_conversion_utf8_decode_test': skip_timeout, |
| 404 'streamed_conversion_utf8_encode_test': skip_timeout, | 403 'streamed_conversion_utf8_encode_test': skip_timeout, |
| 405 'utf85_test': skip_timeout, | 404 'utf85_test': skip_timeout, |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 736 return matches ? matches.length : 0; | 735 return matches ? matches.length : 0; |
| 737 } | 736 } |
| 738 function libraryName(name) { | 737 function libraryName(name) { |
| 739 return name.replace(/-/g, '$45'); | 738 return name.replace(/-/g, '$45'); |
| 740 } | 739 } |
| 741 | 740 |
| 742 let unittest_tests = []; | 741 let unittest_tests = []; |
| 743 | 742 |
| 744 let languageTestPattern = | 743 let languageTestPattern = |
| 745 new RegExp('gen/codegen_output/(.*)/([^/]*_test[^/]*)'); | 744 new RegExp('gen/codegen_output/(.*)/([^/]*_test[^/]*)'); |
| 746 html_config.useHtmlConfiguration(); | |
| 747 // We need to let Dart unittest control when tests are run not mocha. | 745 // We need to let Dart unittest control when tests are run not mocha. |
| 748 // mocha.allowUncaught(true); | 746 // mocha.allowUncaught(true); |
| 749 for (let testFile of allTestFiles) { | 747 for (let testFile of allTestFiles) { |
| 750 let match = languageTestPattern.exec(testFile); | 748 let match = languageTestPattern.exec(testFile); |
| 751 if (match != null) { | 749 if (match != null) { |
| 752 let status_group = match[1]; | 750 let status_group = match[1]; |
| 753 let name = match[2]; | 751 let name = match[2]; |
| 754 let module = match[0]; | 752 let module = match[0]; |
| 755 | 753 |
| 756 let status = all_status[status_group]; | 754 let status = all_status[status_group]; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 819 } else { | 817 } else { |
| 820 mainLibrary.main(); | 818 mainLibrary.main(); |
| 821 } | 819 } |
| 822 } | 820 } |
| 823 | 821 |
| 824 if (!async_helper.asyncTestStarted) done(); | 822 if (!async_helper.asyncTestStarted) done(); |
| 825 }); | 823 }); |
| 826 } | 824 } |
| 827 } | 825 } |
| 828 | 826 |
| 829 // TODO(jmesserly): unitttest tests are currently broken | |
| 830 // https://github.com/dart-lang/dev_compiler/issues/631 | |
| 831 return; | |
| 832 | |
| 833 let mochaOnError; | 827 let mochaOnError; |
| 834 // We run these tests in a mocha test wrapper to avoid the confusing failure | 828 // We run these tests in a mocha test wrapper to avoid the confusing failure |
| 835 // case of dart unittests being interleaved with mocha tests. | 829 // case of dart unittests being interleaved with mocha tests. |
| 836 // In practice we are really just suppressing all mocha test behavior while | 830 // In practice we are really just suppressing all mocha test behavior while |
| 837 // Dart unittests run and then re-enabling it when the dart tests complete. | 831 // Dart unittests run and then re-enabling it when the dart tests complete. |
| 832 html_config.useHtmlConfiguration(); | |
| 838 test('run all dart unittests', function(done) { // 'function' to allow `this.t imeout` | 833 test('run all dart unittests', function(done) { // 'function' to allow `this.t imeout` |
| 839 if (unittest_tests.length == 0) return done(); | 834 if (unittest_tests.length == 0) return done(); |
| 840 | 835 |
| 836 // TODO(vsm): We're using an old deprecated version of unittest. | |
| 837 // We need to migrate all tests (in the SDK itself) off of | |
| 838 // unittest. | |
| 839 | |
| 840 // All unittests need to be explicitly marked as such above. If | |
| 841 // not, the unittest framework will be run in a 'normal' test and | |
| 842 // left in an inconsistent state at this point triggering spurious | |
| 843 // failures. This check ensures we're not in such a state. If it fails, | |
| 844 // we've likely added a new unittest and need to categorize it as such. | |
| 845 if (unittest.src__test_environment.environment.testCases[dart_sdk.dartx.leng th] != 0) { | |
|
Bob Nystrom
2016/09/16 17:04:35
Nit: long line.
| |
| 846 return done(new Error('Unittest framework in an invalid state')); | |
| 847 } | |
| 848 | |
| 841 this.timeout(100000000); | 849 this.timeout(100000000); |
| 842 this.enableTimeouts(false); | 850 this.enableTimeouts(false); |
| 843 // Suppress mocha on-error handling because it will mess up unittests. | 851 // Suppress mocha on-error handling because it will mess up unittests. |
| 844 mochaOnError = window.onerror; | 852 mochaOnError = window.onerror; |
| 845 window.onerror = function(err, url, line) { | 853 window.onerror = function(err, url, line) { |
| 846 console.error(err, url, line); | 854 console.error(err, url, line); |
| 847 }; | 855 }; |
| 848 window.addEventListener('message', (event) => { | 856 window.addEventListener('message', (event) => { |
| 849 if (event.data == 'unittest-suite-done') { | 857 if (event.data == 'unittest-suite-done') { |
| 850 window.console.log("Done running unittests"); | 858 window.console.log("Done running unittests"); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 872 | 880 |
| 873 for (let action of unittest_tests) { | 881 for (let action of unittest_tests) { |
| 874 try { | 882 try { |
| 875 action(); | 883 action(); |
| 876 } catch (e) { | 884 } catch (e) { |
| 877 console.error("Caught error tying to setup test:", e); | 885 console.error("Caught error tying to setup test:", e); |
| 878 } | 886 } |
| 879 } | 887 } |
| 880 }); | 888 }); |
| 881 }); | 889 }); |
| OLD | NEW |