| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 'throw_half_surrogate_pair_test_01_multi': fail, | 371 'throw_half_surrogate_pair_test_01_multi': fail, |
| 372 // TODO(rnystrom): Times out because it tests a huge number of | 372 // TODO(rnystrom): Times out because it tests a huge number of |
| 373 // combinations of URLs (4 * 5 * 5 * 8 * 6 * 6 * 4 = 115200). | 373 // combinations of URLs (4 * 5 * 5 * 8 * 6 * 6 * 4 = 115200). |
| 374 'uri_parse_test': skip_timeout, | 374 'uri_parse_test': skip_timeout, |
| 375 | 375 |
| 376 'list_insert_test': fail, | 376 'list_insert_test': fail, |
| 377 'list_removeat_test': fail, | 377 'list_removeat_test': fail, |
| 378 'set_test': fail, // runtime strong mode reject | 378 'set_test': fail, // runtime strong mode reject |
| 379 }, | 379 }, |
| 380 | 380 |
| 381 'corelib/regexp': { |
| 382 'default_arguments_test': fail |
| 383 }, |
| 384 |
| 381 'lib/convert': { | 385 'lib/convert': { |
| 382 'encoding_test': skip_timeout, | 386 'encoding_test': skip_timeout, |
| 383 | 387 |
| 384 // TODO(jmesserly): this is in an inconsistent state between our old and | 388 // TODO(jmesserly): this is in an inconsistent state between our old and |
| 385 // newer SDKs. | 389 // newer SDKs. |
| 386 'html_escape_test': ['skip'], | 390 'html_escape_test': ['skip'], |
| 387 | 391 |
| 388 // TODO(rnystrom): If this test is enabled, karma gets confused and | 392 // TODO(rnystrom): If this test is enabled, karma gets confused and |
| 389 // disconnects randomly. | 393 // disconnects randomly. |
| 390 'json_lib_test': skip_fail, | 394 'json_lib_test': skip_fail, |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 'typevariable_mirror_metadata_test': fail, | 729 'typevariable_mirror_metadata_test': fail, |
| 726 'unnamed_library_test': fail, | 730 'unnamed_library_test': fail, |
| 727 'variable_is_const_test_none_multi': fail, | 731 'variable_is_const_test_none_multi': fail, |
| 728 }, | 732 }, |
| 729 }; | 733 }; |
| 730 | 734 |
| 731 function countMatches(text, regex) { | 735 function countMatches(text, regex) { |
| 732 let matches = text.match(regex); | 736 let matches = text.match(regex); |
| 733 return matches ? matches.length : 0; | 737 return matches ? matches.length : 0; |
| 734 } | 738 } |
| 739 function libraryName(name) { |
| 740 return name.replace(/-/g, '$45'); |
| 741 } |
| 735 | 742 |
| 736 let unittest_tests = []; | 743 let unittest_tests = []; |
| 737 | 744 |
| 738 let languageTestPattern = | 745 let languageTestPattern = |
| 739 new RegExp('gen/codegen_output/(.*)/([^/]*_test[^/]*)'); | 746 new RegExp('gen/codegen_output/(.*)/([^/]*_test[^/]*)'); |
| 740 html_config.useHtmlConfiguration(); | 747 html_config.useHtmlConfiguration(); |
| 741 // We need to let Dart unittest control when tests are run not mocha. | 748 // We need to let Dart unittest control when tests are run not mocha. |
| 742 // mocha.allowUncaught(true); | 749 // mocha.allowUncaught(true); |
| 743 let dartUnittestsLeft = 0; | |
| 744 for (let testFile of allTestFiles) { | 750 for (let testFile of allTestFiles) { |
| 745 let match = languageTestPattern.exec(testFile); | 751 let match = languageTestPattern.exec(testFile); |
| 746 if (match != null) { | 752 if (match != null) { |
| 747 let status_group = match[1] | 753 let status_group = match[1]; |
| 748 let name = match[2]; | 754 let name = match[2]; |
| 749 let module = match[0]; | 755 let module = match[0]; |
| 750 | 756 |
| 751 let status = all_status[status_group]; | 757 let status = all_status[status_group]; |
| 752 if (status == null) throw "No status for '" + status_group + "'"; | 758 if (status == null) throw "No status for '" + status_group + "'"; |
| 753 | 759 |
| 754 let expectation = status[name]; | 760 let expectation = status[name]; |
| 755 if (expectation == null) expectation = []; | 761 if (expectation == null) expectation = []; |
| 756 if (typeof expectation == 'string') expectation = [expectation]; | 762 if (typeof expectation == 'string') expectation = [expectation]; |
| 757 let has = (tag) => expectation.indexOf(tag) >= 0; | 763 let has = (tag) => expectation.indexOf(tag) >= 0; |
| 758 | 764 |
| 759 if (has('helper')) { | 765 if (has('helper')) { |
| 760 // These are not top-level tests. They are used by other tests. | 766 // These are not top-level tests. They are used by other tests. |
| 761 continue; | 767 continue; |
| 762 } | 768 } |
| 763 | 769 |
| 764 if (has('skip')) { | 770 if (has('skip')) { |
| 765 let why = 'for unknown reason'; | 771 let why = 'for unknown reason'; |
| 766 if (has('timeout')) why = 'known timeout'; | 772 if (has('timeout')) why = 'known timeout'; |
| 767 if (has('fail')) why = 'known failure'; | 773 if (has('fail')) why = 'known failure'; |
| 768 console.debug('Skipping ' + why + ': ' + name); | 774 console.debug('Skipping ' + why + ': ' + name); |
| 769 continue; | 775 continue; |
| 770 } | 776 } |
| 771 | 777 |
| 772 // A few tests are special because they use package:unittest. | 778 // A few tests are special because they use package:unittest. |
| 773 // We run them below. | 779 // We run them below. |
| 774 if (has('unittest')) { | 780 if (has('unittest')) { |
| 775 unittest_tests.push(() => { | 781 unittest_tests.push(() => { |
| 776 console.log('Running unittest test ' + testFile); | 782 console.log('Running unittest test ' + testFile); |
| 777 require(module)[name].main(); | 783 require(module)[libraryName(name)].main(); |
| 778 }); | 784 }); |
| 779 continue; | 785 continue; |
| 780 } | 786 } |
| 781 | 787 |
| 782 let protect = (f) => { // Returns the exception, or `null`. | 788 let protect = (f) => { // Returns the exception, or `null`. |
| 783 try { | 789 try { |
| 784 f(); | 790 f(); |
| 785 return null; | 791 return null; |
| 786 } catch (e) { | 792 } catch (e) { |
| 787 return e; | 793 return e; |
| 788 } | 794 } |
| 789 }; | 795 }; |
| 790 | 796 |
| 791 test(name, function(done) { // 'function' to allow `this.timeout`. | 797 test(name, function(done) { // 'function' to allow `this.timeout`. |
| 792 async_helper.asyncTestInitialize(done); | 798 async_helper.asyncTestInitialize(done); |
| 793 console.debug('Running test: ' + name); | 799 console.debug('Running test: ' + name); |
| 794 | 800 |
| 795 let mainLibrary = require(module)[name]; | 801 let mainLibrary = require(module)[libraryName(name)]; |
| 796 let negative = /negative_test/.test(name); | 802 let negative = /negative_test/.test(name); |
| 797 if (has('slow')) this.timeout(10000); | 803 if (has('slow')) this.timeout(10000); |
| 798 if (has('fail')) { | 804 if (has('fail')) { |
| 799 let e = protect(mainLibrary.main); | 805 let e = protect(mainLibrary.main); |
| 800 if (negative) { | 806 if (negative) { |
| 801 if (e != null) { | 807 if (e != null) { |
| 802 throw new Error( | 808 throw new Error( |
| 803 "negative test marked as 'fail' " + | 809 "negative test marked as 'fail' " + |
| 804 "but passed by throwing:\n" + e); | 810 "but passed by throwing:\n" + e); |
| 805 } | 811 } |
| 806 } else { | 812 } else { |
| 807 if (e == null) { | 813 if (e == null) { |
| 808 throw new Error("test marked as 'fail' but passed"); | 814 throw new Error("test marked as 'fail' but passed"); |
| 809 } | 815 } |
| 810 } | 816 } |
| 811 } else { | 817 } else { |
| 812 if (negative) { | 818 if (negative) { |
| 813 assert.throws(mainLibrary.main); | 819 assert.throws(mainLibrary.main); |
| 814 } else { | 820 } else { |
| 815 mainLibrary.main(); | 821 mainLibrary.main(); |
| 816 } | 822 } |
| 817 } | 823 } |
| 818 | 824 |
| 819 if (!async_helper.asyncTestStarted) done(); | 825 if (!async_helper.asyncTestStarted) done(); |
| 820 }); | 826 }); |
| 821 } | 827 } |
| 822 } | 828 } |
| 823 | 829 |
| 830 // TODO(jmesserly): unitttest tests are currently broken |
| 831 // https://github.com/dart-lang/dev_compiler/issues/631 |
| 832 return; |
| 833 |
| 824 let mochaOnError; | 834 let mochaOnError; |
| 825 // We run these tests in a mocha test wrapper to avoid the confusing failure | 835 // We run these tests in a mocha test wrapper to avoid the confusing failure |
| 826 // case of dart unittests being interleaved with mocha tests. | 836 // case of dart unittests being interleaved with mocha tests. |
| 827 // In practice we are really just suppressing all mocha test behavior while | 837 // In practice we are really just suppressing all mocha test behavior while |
| 828 // Dart unittests run and then re-enabling it when the dart tests complete. | 838 // Dart unittests run and then re-enabling it when the dart tests complete. |
| 829 test('run all dart unittests', function(done) { // 'function' to allow `this.t
imeout` | 839 test('run all dart unittests', function(done) { // 'function' to allow `this.t
imeout` |
| 830 if (unittest_tests.length == 0) return done(); | 840 if (unittest_tests.length == 0) return done(); |
| 831 | 841 |
| 832 this.timeout(100000000); | 842 this.timeout(100000000); |
| 833 this.enableTimeouts(false); | 843 this.enableTimeouts(false); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 863 | 873 |
| 864 for (let action of unittest_tests) { | 874 for (let action of unittest_tests) { |
| 865 try { | 875 try { |
| 866 action(); | 876 action(); |
| 867 } catch (e) { | 877 } catch (e) { |
| 868 console.error("Caught error tying to setup test:", e); | 878 console.error("Caught error tying to setup test:", e); |
| 869 } | 879 } |
| 870 } | 880 } |
| 871 }); | 881 }); |
| 872 }); | 882 }); |
| OLD | NEW |