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

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

Issue 2249233002: fix #626, add AMD module format and make it default (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: fix sunflower Created 4 years, 4 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
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 (function() { 5 define(['dart_sdk', 'async_helper', 'unittest', 'require'],
6 function(dart_sdk, async_helper, unittest, require) {
6 'use strict'; 7 'use strict';
7 8
8 let dart_sdk = dart_library.import('dart_sdk'); 9 async_helper = async_helper.async_helper;
10
9 dart_sdk._isolate_helper.startRootIsolate(function() {}, []); 11 dart_sdk._isolate_helper.startRootIsolate(function() {}, []);
10 let async_helper = dart_library.import('async_helper').async_helper;
11 let unittest = dart_library.import('unittest');
12 let html_config = unittest.html_config; 12 let html_config = unittest.html_config;
13 // Test attributes are a list of strings, or a string for a single 13 // Test attributes are a list of strings, or a string for a single
14 // attribute. Valid attributes are: 14 // attribute. Valid attributes are:
15 // 15 //
16 // 'notyetstrong' - test is not yet strong mode safe 16 // 'notyetstrong' - test is not yet strong mode safe
17 // 'skip' - don't run the test 17 // 'skip' - don't run the test
18 // 'fail' - test fails 18 // 'fail' - test fails
19 // 'timeout' - test times out 19 // 'timeout' - test times out
20 // 'slow' - use 5s timeout instead of default 2s. 20 // 'slow' - use 5s timeout instead of default 2s.
21 // 'helper' - not a test, used by other tests. 21 // 'helper' - not a test, used by other tests.
(...skipping 2497 matching lines...) Expand 10 before | Expand all | Expand 10 after
2519 'chunked_conversion_utf84_test': skip_timeout, 2519 'chunked_conversion_utf84_test': skip_timeout,
2520 'chunked_conversion_utf88_test': skip_timeout, 2520 'chunked_conversion_utf88_test': skip_timeout,
2521 'chunked_conversion_utf8_test': skip_timeout, 2521 'chunked_conversion_utf8_test': skip_timeout,
2522 2522
2523 'chunked_conversion1_test': notyetstrong, 2523 'chunked_conversion1_test': notyetstrong,
2524 2524
2525 'encoding_test': skip_timeout, 2525 'encoding_test': skip_timeout,
2526 2526
2527 // TODO(jmesserly): this is in an inconsistent state between our old and 2527 // TODO(jmesserly): this is in an inconsistent state between our old and
2528 // newer SDKs. 2528 // newer SDKs.
2529 'html_escape_test': skip_fail,
2530
2531 // TODO(jmesserly): seems to fail or pass based on SDK version?
2532 'html_escape_test': ['skip'], 2529 'html_escape_test': ['skip'],
2533 2530
2534 // TODO(rnystrom): If this test is enabled, karma gets confused and 2531 // TODO(rnystrom): If this test is enabled, karma gets confused and
2535 // disconnects randomly. 2532 // disconnects randomly.
2536 'json_lib_test': skip_fail, 2533 'json_lib_test': skip_fail,
2537 2534
2538 'json_utf8_chunk_test': skip_timeout, 2535 'json_utf8_chunk_test': skip_timeout,
2539 2536
2540 // TODO(rnystrom): Strong mode cast failure. 2537 // TODO(rnystrom): Strong mode cast failure.
2541 'line_splitter_test': fail, 2538 'line_splitter_test': fail,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2736 }, 2733 },
2737 }; 2734 };
2738 2735
2739 function countMatches(text, regex) { 2736 function countMatches(text, regex) {
2740 let matches = text.match(regex); 2737 let matches = text.match(regex);
2741 return matches ? matches.length : 0; 2738 return matches ? matches.length : 0;
2742 } 2739 }
2743 2740
2744 let unittest_tests = []; 2741 let unittest_tests = [];
2745 2742
2746 let languageTestPattern = new RegExp('(.*)/([^/]*_test[^/]*)'); 2743 let languageTestPattern =
2744 new RegExp('gen/codegen_output/(.*)/([^/]*_test[^/]*)');
2747 html_config.useHtmlConfiguration(); 2745 html_config.useHtmlConfiguration();
2748 // We need to let Dart unittest control when tests are run not mocha. 2746 // We need to let Dart unittest control when tests are run not mocha.
2749 // mocha.allowUncaught(true); 2747 // mocha.allowUncaught(true);
2750 let dartUnittestsLeft = 0; 2748 let dartUnittestsLeft = 0;
2751 for (let testFile of dart_library.libraries()) { 2749 for (let testFile of allTestFiles) {
2752 let match = languageTestPattern.exec(testFile); 2750 let match = languageTestPattern.exec(testFile);
2753 if (match != null) { 2751 if (match != null) {
2754 let status_group = match[1] 2752 let status_group = match[1]
2755 let name = match[2]; 2753 let name = match[2];
2756 let module = match[0]; 2754 let module = match[0];
2757 2755
2758 let status = all_status[status_group]; 2756 let status = all_status[status_group];
2759 if (status == null) throw "No status for '" + status_group + "'"; 2757 if (status == null) throw "No status for '" + status_group + "'";
2760 2758
2761 let expectation = status[name]; 2759 let expectation = status[name];
2762 if (expectation == null) expectation = []; 2760 if (expectation == null) expectation = [];
2763 if (typeof expectation == 'string') expectation = [expectation]; 2761 if (typeof expectation == 'string') expectation = [expectation];
2764 function has(tag) { 2762 let has = (tag) => expectation.indexOf(tag) >= 0;
2765 return expectation.indexOf(tag) >= 0;
2766 }
2767 2763
2768 if (has('helper')) { 2764 if (has('helper')) {
2769 // These are not top-level tests. They are used by other tests. 2765 // These are not top-level tests. They are used by other tests.
2770 continue; 2766 continue;
2771 } 2767 }
2772 2768
2773 if (has('skip')) { 2769 if (has('skip')) {
2774 let why = 'for unknown reason'; 2770 let why = 'for unknown reason';
2775 if (has('timeout')) why = 'known timeout'; 2771 if (has('timeout')) why = 'known timeout';
2776 if (has('fail')) why = 'known failure'; 2772 if (has('fail')) why = 'known failure';
2777 console.debug('Skipping ' + why + ': ' + name); 2773 console.debug('Skipping ' + why + ': ' + name);
2778 continue; 2774 continue;
2779 } 2775 }
2780 2776
2781 // A few tests are special because they use package:unittest. 2777 // A few tests are special because they use package:unittest.
2782 // We run them below. 2778 // We run them below.
2783 if (has('unittest')) { 2779 if (has('unittest')) {
2784 unittest_tests.push(() => { 2780 unittest_tests.push(() => {
2785 console.log('Running unittest test ' + testFile); 2781 console.log('Running unittest test ' + testFile);
2786 dart_library.import(module)[name].main(); 2782 require(module)[name].main();
2787 }); 2783 });
2788 continue; 2784 continue;
2789 } 2785 }
2790 2786
2791 function protect(f) { // Returns the exception, or `null`. 2787 let protect = (f) => { // Returns the exception, or `null`.
2792 try { 2788 try {
2793 f(); 2789 f();
2794 return null; 2790 return null;
2795 } catch (e) { 2791 } catch (e) {
2796 return e; 2792 return e;
2797 } 2793 }
2798 } 2794 };
2799 2795
2800 test(name, function(done) { // 'function' to allow `this.timeout`. 2796 test(name, function(done) { // 'function' to allow `this.timeout`.
2801 async_helper.asyncTestInitialize(done); 2797 async_helper.asyncTestInitialize(done);
2802 console.debug('Running test: ' + name); 2798 console.debug('Running test: ' + name);
2803 2799
2804 let mainLibrary = dart_library.import(module)[name]; 2800 let mainLibrary = require(module)[name];
2805 let negative = /negative_test/.test(name); 2801 let negative = /negative_test/.test(name);
2806 if (has('slow')) this.timeout(10000); 2802 if (has('slow')) this.timeout(10000);
2807 if (has('notyetstrong')) { 2803 if (has('notyetstrong')) {
2808 let e = protect(mainLibrary.main); 2804 let e = protect(mainLibrary.main);
2809 if (e == null) { 2805 if (e == null) {
2810 throw new Error( 2806 throw new Error(
2811 "test marked as 'notyetstrong' due to " + 2807 "test marked as 'notyetstrong' due to " +
2812 "strong mode errors, but passed"); 2808 "strong mode errors, but passed");
2813 } else if (!(e instanceof Error) || 2809 } else if (!(e instanceof Error) ||
2814 !e.message.startsWith("DDC Compilation Error:")) { 2810 !e.message.startsWith("DDC Compilation Error:")) {
(...skipping 26 matching lines...) Expand all
2841 }); 2837 });
2842 } 2838 }
2843 } 2839 }
2844 2840
2845 let mochaOnError; 2841 let mochaOnError;
2846 // We run these tests in a mocha test wrapper to avoid the confusing failure 2842 // We run these tests in a mocha test wrapper to avoid the confusing failure
2847 // case of dart unittests being interleaved with mocha tests. 2843 // case of dart unittests being interleaved with mocha tests.
2848 // In practice we are really just suppressing all mocha test behavior while 2844 // In practice we are really just suppressing all mocha test behavior while
2849 // Dart unittests run and then re-enabling it when the dart tests complete. 2845 // Dart unittests run and then re-enabling it when the dart tests complete.
2850 test('run all dart unittests', function(done) { // 'function' to allow `this.t imeout` 2846 test('run all dart unittests', function(done) { // 'function' to allow `this.t imeout`
2847 if (unittest_tests.length == 0) return done();
2848
2851 this.timeout(100000000); 2849 this.timeout(100000000);
2852 this.enableTimeouts(false); 2850 this.enableTimeouts(false);
2853 // Suppress mocha on-error handling because it will mess up unittests. 2851 // Suppress mocha on-error handling because it will mess up unittests.
2854 mochaOnError = window.onerror; 2852 mochaOnError = window.onerror;
2855 window.onerror = function(err, url, line) { 2853 window.onerror = function(err, url, line) {
2856 console.error(err, url, line); 2854 console.error(err, url, line);
2857 }; 2855 };
2858 window.addEventListener('message', (event) => { 2856 window.addEventListener('message', (event) => {
2859 if (event.data == 'unittest-suite-done') { 2857 if (event.data == 'unittest-suite-done') {
2860 window.console.log("Done running unittests"); 2858 window.console.log("Done running unittests");
(...skipping 20 matching lines...) Expand all
2881 }); 2879 });
2882 2880
2883 for (let action of unittest_tests) { 2881 for (let action of unittest_tests) {
2884 try { 2882 try {
2885 action(); 2883 action();
2886 } catch (e) { 2884 } catch (e) {
2887 console.error("Caught error tying to setup test:", e); 2885 console.error("Caught error tying to setup test:", e);
2888 } 2886 }
2889 } 2887 }
2890 }); 2888 });
2891 })(); 2889 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698