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

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

Issue 2991073002: remove unittest as a test status, instead record this at test build time (Closed)
Patch Set: cleanup import Created 3 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
« no previous file with comments | « no previous file | pkg/dev_compiler/test/codegen_test.dart » ('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;
11 let mochaOnError = window.onerror; 11 let mochaOnError = window.onerror;
12 dart_sdk.dart.trapRuntimeErrors(false); 12 dart_sdk.dart.trapRuntimeErrors(false);
13 dart_sdk.dart.ignoreWhitelistedErrors(false); 13 dart_sdk.dart.ignoreWhitelistedErrors(false);
14 dart_sdk.dart.failForWeakModeIsChecks(false); 14 dart_sdk.dart.failForWeakModeIsChecks(false);
15 dart_sdk._isolate_helper.startRootIsolate(function() {}, []); 15 dart_sdk._isolate_helper.startRootIsolate(function() {}, []);
16 // Make it easier to debug test failures and required for formatter test that 16 // Make it easier to debug test failures and required for formatter test that
17 // assumes custom formatters are enabled. 17 // assumes custom formatters are enabled.
18 dart_sdk._debugger.registerDevtoolsFormatter(); 18 dart_sdk._debugger.registerDevtoolsFormatter();
19 19
20 let html_config = unittest.html_config; 20 let html_config = unittest.html_config;
21 // Test attributes are a list of strings, or a string for a single 21 // Test attributes are a list of strings, or a string for a single
22 // attribute. Valid attributes are: 22 // attribute. Valid attributes are:
23 // 23 //
24 // 'pass' - test passes (default) 24 // 'pass' - test passes (default)
25 // 'skip' - don't run the test 25 // 'skip' - don't run the test
26 // 'fail' - test fails 26 // 'fail' - test fails
27 // 'timeout' - test times out 27 // 'timeout' - test times out
28 // 'slow' - use 5s timeout instead of default 2s. 28 // 'slow' - use 5s timeout instead of default 2s.
29 // 'helper' - not a test, used by other tests.
30 // 'unittest' - run separately as a unittest test.
31 // 'whitelist' - run with whitelisted type errors allowed 29 // 'whitelist' - run with whitelisted type errors allowed
32 // 30 //
33 // Common combinations: 31 // Common combinations:
34 const pass = 'pass'; 32 const pass = 'pass';
35 const fail = 'fail'; 33 const fail = 'fail';
36 const skip_timeout = ['skip', 'timeout']; 34 const skip_timeout = ['skip', 'timeout'];
37 35
38 // Browsers 36 // Browsers
39 const firefox_fail = is.firefox() ? fail : pass; 37 const firefox_fail = is.firefox() ? fail : pass;
40 const chrome_fail = is.chrome() ? fail : pass; 38 const chrome_fail = is.chrome() ? fail : pass;
41 39
42 // These are typically tests with asynchronous exceptions that our 40 // These are typically tests with asynchronous exceptions that our
43 // test framework doesn't always catch. 41 // test framework doesn't always catch.
44 const flaky = 'skip'; 42 const flaky = 'skip';
45 const whitelist = 'whitelist'; 43 const whitelist = 'whitelist';
46 44
47 // Tests marked with this are still using the deprecated unittest package 45 // Tests marked with this are still using the deprecated unittest package
48 // because they rely on its support for futures and asynchronous tests, which 46 // because they rely on its support for futures and asynchronous tests, which
49 // expect and minitest do not handle. 47 // expect and minitest do not handle.
50 // TODO(rnystrom): Move all of these away from using the async test API so 48 // TODO(rnystrom): Move all of these away from using the async test API so
51 // they can stop using unittest. 49 // they can stop using unittest.
52 const async_unittest = ['unittest', 'skip', 'fail']; 50 const async_unittest = ['skip', 'fail'];
53 51
54 // The number of expected unittest errors should be zero but unfortunately 52 // The number of expected unittest errors should be zero but unfortunately
55 // there are a lot of broken html unittests. 53 // there are a lot of broken html unittests.
56 let num_expected_unittest_fails = 4; 54 let num_expected_unittest_fails = 4;
57 let num_expected_unittest_errors = 0; 55 let num_expected_unittest_errors = 0;
58 56
59 // TODO(jmesserly): separate StrongModeError from other errors. 57 // TODO(jmesserly): separate StrongModeError from other errors.
60 let all_status = { 58 let all_status = {
61 'language': { 59 'language': {
62 'async_await_test_none_multi': 'unittest',
63 'async_await_test_02_multi': 'unittest',
64
65 // Flaky on travis (https://github.com/dart-lang/sdk/issues/27224) 60 // Flaky on travis (https://github.com/dart-lang/sdk/issues/27224)
66 'async_await_test_03_multi': async_unittest, 61 'async_await_test_03_multi': async_unittest,
67 62
68 'async_star_pause_test': fail, 63 'async_star_pause_test': fail,
69 'async_star_await_pauses_test': skip_timeout, 64 'async_star_await_pauses_test': skip_timeout,
70 65
71 // TODO(jmesserly): figure out why this test is hanging. 66 // TODO(jmesserly): figure out why this test is hanging.
72 'async_star_cancel_and_throw_in_finally_test': skip_timeout, 67 'async_star_cancel_and_throw_in_finally_test': skip_timeout,
73 68
74 'async_star_cancel_while_paused_test': fail, 69 'async_star_cancel_while_paused_test': fail,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 'external_test_21_multi': fail, 198 'external_test_21_multi': fail,
204 'external_test_24_multi': fail, 199 'external_test_24_multi': fail,
205 'multiline_newline_test_04_multi': fail, 200 'multiline_newline_test_04_multi': fail,
206 'multiline_newline_test_05_multi': fail, 201 'multiline_newline_test_05_multi': fail,
207 'multiline_newline_test_06_multi': fail, 202 'multiline_newline_test_06_multi': fail,
208 'multiline_newline_test_none_multi': fail, 203 'multiline_newline_test_none_multi': fail,
209 204
210 // https://github.com/dart-lang/sdk/issues/26124 205 // https://github.com/dart-lang/sdk/issues/26124
211 'prefix10_negative_test': fail, 206 'prefix10_negative_test': fail,
212 207
213 'library_prefixes_test1': 'helper', 208 'library_prefixes_test1': 'skip', // not a test
214 'library_prefixes_test2': 'helper', 209 'library_prefixes_test2': 'skip', // not a test
215 'top_level_prefixed_library_test': 'helper', 210 'top_level_prefixed_library_test': 'skip', // not a test
216 211
217 }, 212 },
218 213
219 'language/covariant_override': {}, 214 'language/covariant_override': {},
220 215
221 'codegen': {}, 216 'codegen': {},
222 217
223 'corelib': { 218 'corelib': {
224 'apply2_test': fail, 219 'apply2_test': fail,
225 'apply3_test': fail, 220 'apply3_test': fail,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 'utf8_test': whitelist, 383 'utf8_test': whitelist,
389 }, 384 },
390 385
391 'lib/html': { 386 'lib/html': {
392 'async_spawnuri_test': async_unittest, 387 'async_spawnuri_test': async_unittest,
393 'async_test': async_unittest, 388 'async_test': async_unittest,
394 389
395 // was https://github.com/dart-lang/sdk/issues/27578, needs triage 390 // was https://github.com/dart-lang/sdk/issues/27578, needs triage
396 'audiocontext_test': is.chrome('<=54') ? fail : pass, 391 'audiocontext_test': is.chrome('<=54') ? fail : pass,
397 392
398 'canvas_test': ['unittest'],
399 'canvasrenderingcontext2d_test': ['unittest'],
400 'cross_domain_iframe_test': async_unittest, 393 'cross_domain_iframe_test': async_unittest,
401 'cssstyledeclaration_test': async_unittest, 394 'cssstyledeclaration_test': async_unittest,
402 'css_test': async_unittest, 395 'css_test': async_unittest,
403 396
404 // This is failing with a range error, I'm guessing because it's looking 397 // This is failing with a range error, I'm guessing because it's looking
405 // for a stylesheet and the page has none. 398 // for a stylesheet and the page has none.
406 'css_rule_list_test': 'fail', 399 'css_rule_list_test': 'fail',
407 400
408 'custom_element_method_clash_test': async_unittest, 401 'custom_element_method_clash_test': async_unittest,
409 'custom_element_name_clash_test': async_unittest, 402 'custom_element_name_clash_test': async_unittest,
410 'custom_elements_23127_test': async_unittest, 403 'custom_elements_23127_test': async_unittest,
411 'custom_elements_test': async_unittest, 404 'custom_elements_test': async_unittest,
412 405
413 // Please do not mark this test as fail. If your change breaks this test, 406 // Please do not mark this test as fail. If your change breaks this test,
414 // please look at the test for instructions on how to generate a new 407 // please look at the test for instructions on how to generate a new
415 // golden file. 408 // golden file.
416 'debugger_test': firefox_fail, 409 'debugger_test': firefox_fail,
417 'element_animate_test': 'unittest',
418 410
419 // https://github.com/dart-lang/sdk/issues/27579. 411 // https://github.com/dart-lang/sdk/issues/27579.
420 'element_classes_test': 'fail', 412 'element_classes_test': 'fail',
421 'element_classes_svg_test': 'fail', 413 'element_classes_svg_test': 'fail',
422 414
423 // Failure: 'Expected 56 to be in the inclusive range [111, 160].'. 415 // Failure: 'Expected 56 to be in the inclusive range [111, 160].'.
424 'element_offset_test': 'fail', 416 'element_offset_test': 'fail',
425 417
426 'element_test': async_unittest, 418 'element_test': async_unittest,
427 // This may no longer be a valid test? 419 // This may no longer be a valid test?
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 682 }
691 if (match != null) { 683 if (match != null) {
692 let status = all_status[status_group]; 684 let status = all_status[status_group];
693 if (status == null) throw "No status for '" + status_group + "'"; 685 if (status == null) throw "No status for '" + status_group + "'";
694 686
695 let expectation = status[name]; 687 let expectation = status[name];
696 if (expectation == null) expectation = []; 688 if (expectation == null) expectation = [];
697 if (typeof expectation == 'string') expectation = [expectation]; 689 if (typeof expectation == 'string') expectation = [expectation];
698 let has = (tag) => expectation.indexOf(tag) >= 0; 690 let has = (tag) => expectation.indexOf(tag) >= 0;
699 691
700 if (has('helper')) {
701 // These are not top-level tests. They are used by other tests.
702 continue;
703 }
704
705 if (has('skip')) { 692 if (has('skip')) {
706 let why = 'for unknown reason'; 693 let why = 'for unknown reason';
707 if (has('timeout')) why = 'known timeout'; 694 if (has('timeout')) why = 'known timeout';
708 if (has('fail')) why = 'known failure'; 695 if (has('fail')) why = 'known failure';
709 console.debug('Skipping ' + why + ': ' + name); 696 console.debug('Skipping ' + why + ': ' + name);
710 continue; 697 continue;
711 } 698 }
712 699
713 // A few tests are special because they use package:unittest. 700 // A few tests are special because they use package:unittest.
714 // We run them below. 701 // We run them below.
715 if (has('unittest')) { 702 let mainLibrary = require(module)[libraryName(name)];
703 if (mainLibrary._usesUnittestPackage) {
716 unittest_tests.push(() => { 704 unittest_tests.push(() => {
717 console.log('Running unittest test ' + testFile); 705 console.log('Running unittest test ' + testFile);
718 require(module)[libraryName(name)].main(); 706 mainLibrary.main();
719 }); 707 });
720 continue; 708 continue;
721 } 709 }
722 710
723 let protect = (f) => { // Returns the exception, or `null`.
724 try {
725 return f();
726 } catch (e) {
727 return e;
728 }
729 };
730
731 var fullName = status_group + '/' + name; 711 var fullName = status_group + '/' + name;
732 test(fullName, function(done) { // 'function' to allow `this.timeout`. 712 test(fullName, function(done) { // 'function' to allow `this.timeout`.
733 console.debug('Running test: ' + fullName); 713 console.debug('Running test: ' + fullName);
734 714
735 // Many tests are async. Currently, tests can indicate this in 715 // Many tests are async. Currently, tests can indicate this in
736 // two different ways. First, `main` can call (in Dart) 716 // two different ways. First, `main` can call (in Dart)
737 // `async_helper.asyncStart`. We can check if this happened by 717 // `async_helper.asyncStart`. We can check if this happened by
738 // querying `async_helper.asyncTestStarted` afterward and waiting for 718 // querying `async_helper.asyncTestStarted` afterward and waiting for
739 // the callback if so. Second, `main` can return a `Future`. If so, 719 // the callback if so. Second, `main` can return a `Future`. If so,
740 // we wait for that to complete. If neither is true, we assume the 720 // we wait for that to complete. If neither is true, we assume the
(...skipping 22 matching lines...) Expand all
763 // 4. Via `async_helper` without an error. In this case, the 743 // 4. Via `async_helper` without an error. In this case, the
764 // `async_helper` library triggers `finish` via its callback. 744 // `async_helper` library triggers `finish` via its callback.
765 // 5. Asynchronously with an error. In this case, `window.onerror` 745 // 5. Asynchronously with an error. In this case, `window.onerror`
766 // triggers `finish` with the error. 746 // triggers `finish` with the error.
767 // 6. Hangs. In this case, we rely on the underlying mocha framework 747 // 6. Hangs. In this case, we rely on the underlying mocha framework
768 // timeout. 748 // timeout.
769 // 749 //
770 // TODO(vsm): This currently doesn't handle tests that trigger multiple 750 // TODO(vsm): This currently doesn't handle tests that trigger multiple
771 // asynchronous exceptions. 751 // asynchronous exceptions.
772 752
773 let mainLibrary = require(module)[libraryName(name)];
774 let negative = /negative_test/.test(name) || 753 let negative = /negative_test/.test(name) ||
775 mainLibrary._expectRuntimeError; 754 mainLibrary._expectRuntimeError;
776 let fail = has('fail'); 755 let fail = has('fail');
777 756
778 let whitelist = has('whitelist'); 757 let whitelist = has('whitelist');
779 dart_sdk.dart.ignoreWhitelistedErrors(whitelist); 758 dart_sdk.dart.ignoreWhitelistedErrors(whitelist);
780 759
781 function finish(error) { 760 function finish(error) {
782 // If the test left any lingering detritus in the DOM, blow it away 761 // If the test left any lingering detritus in the DOM, blow it away
783 // so it doesn't interfere with later tests. 762 // so it doesn't interfere with later tests.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 885
907 for (let action of unittest_tests) { 886 for (let action of unittest_tests) {
908 try { 887 try {
909 action(); 888 action();
910 } catch (e) { 889 } catch (e) {
911 console.error("Caught error tying to setup test:", e); 890 console.error("Caught error tying to setup test:", e);
912 } 891 }
913 } 892 }
914 }); 893 });
915 }); 894 });
OLDNEW
« no previous file with comments | « no previous file | pkg/dev_compiler/test/codegen_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698