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

Side by Side Diff: tools/testing/dart/test_suite.dart

Issue 239003002: Reduce test.dart memory usage. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added cleared check. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * Classes and methods for enumerating and preparing tests. 6 * Classes and methods for enumerating and preparing tests.
7 * 7 *
8 * This library includes: 8 * This library includes:
9 * 9 *
10 * - Creating tests by listing all the Dart files in certain directories, 10 * - Creating tests by listing all the Dart files in certain directories,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 * A simple function that tests [arg] and returns `true` or `false`. 43 * A simple function that tests [arg] and returns `true` or `false`.
44 */ 44 */
45 typedef bool Predicate<T>(T arg); 45 typedef bool Predicate<T>(T arg);
46 46
47 typedef void CreateTest(Path filePath, 47 typedef void CreateTest(Path filePath,
48 bool hasCompileError, 48 bool hasCompileError,
49 bool hasRuntimeError, 49 bool hasRuntimeError,
50 {bool isNegativeIfChecked, 50 {bool isNegativeIfChecked,
51 bool hasCompileErrorIfChecked, 51 bool hasCompileErrorIfChecked,
52 bool hasStaticWarning, 52 bool hasStaticWarning,
53 Set<String> multitestOutcome,
54 String multitestKey, 53 String multitestKey,
55 Path originTestPath}); 54 Path originTestPath});
56 55
57 typedef void VoidFunction(); 56 typedef void VoidFunction();
58 57
59 /** 58 /**
60 * Calls [function] asynchronously. Returns a future that completes with the 59 * Calls [function] asynchronously. Returns a future that completes with the
61 * result of the function. If the function is `null`, returns a future that 60 * result of the function. If the function is `null`, returns a future that
62 * completes immediately with `null`. 61 * completes immediately with `null`.
63 */ 62 */
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 /** 113 /**
115 * A TestSuite represents a collection of tests. It creates a [TestCase] 114 * A TestSuite represents a collection of tests. It creates a [TestCase]
116 * object for each test to be run, and passes the test cases to a callback. 115 * object for each test to be run, and passes the test cases to a callback.
117 * 116 *
118 * Most TestSuites represent a directory or directory tree containing tests, 117 * Most TestSuites represent a directory or directory tree containing tests,
119 * and a status file containing the expected results when these tests are run. 118 * and a status file containing the expected results when these tests are run.
120 */ 119 */
121 abstract class TestSuite { 120 abstract class TestSuite {
122 final Map configuration; 121 final Map configuration;
123 final String suiteName; 122 final String suiteName;
123 // This function is set by subclasses before enqueueing starts.
124 Function doTest;
125
124 126
125 TestSuite(this.configuration, this.suiteName); 127 TestSuite(this.configuration, this.suiteName);
126 128
127 Map<String, String> get environmentOverrides { 129 Map<String, String> get environmentOverrides {
128 return { 130 return {
129 'DART_CONFIGURATION' : TestUtils.configurationDir(configuration), 131 'DART_CONFIGURATION' : TestUtils.configurationDir(configuration),
130 }; 132 };
131 } 133 }
132 134
133 /** 135 /**
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 /** 240 /**
239 * Call the callback function onTest with a [TestCase] argument for each 241 * Call the callback function onTest with a [TestCase] argument for each
240 * test in the suite. When all tests have been processed, call [onDone]. 242 * test in the suite. When all tests have been processed, call [onDone].
241 * 243 *
242 * The [testCache] argument provides a persistent store that can be used to 244 * The [testCache] argument provides a persistent store that can be used to
243 * cache information about the test suite, so that directories do not need 245 * cache information about the test suite, so that directories do not need
244 * to be listed each time. 246 * to be listed each time.
245 */ 247 */
246 void forEachTest(TestCaseEvent onTest, Map testCache, [VoidFunction onDone]); 248 void forEachTest(TestCaseEvent onTest, Map testCache, [VoidFunction onDone]);
247 249
248
249 // This function is set by subclasses before enqueueing starts.
250 Function doTest;
251
252 // This function will be called for every TestCase of this test suite. 250 // This function will be called for every TestCase of this test suite.
253 // It will 251 // It will
254 // - handle sharding 252 // - handle sharding
255 // - update SummaryReport 253 // - update SummaryReport
256 // - handle SKIP/SKIP_BY_DESIGN markers 254 // - handle SKIP/SKIP_BY_DESIGN markers
257 // - test if the selector matches 255 // - test if the selector matches
258 // and will enqueue the test (if necessary). 256 // and will enqueue the test (if necessary).
259 void enqueueNewTestCase(TestCase testCase) { 257 void enqueueNewTestCase(TestCase testCase) {
260 var expectations = testCase.expectedOutcomes; 258 var expectations = testCase.expectedOutcomes;
261 259
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 566
569 class TestInformation { 567 class TestInformation {
570 Path originTestPath; 568 Path originTestPath;
571 Path filePath; 569 Path filePath;
572 Map optionsFromFile; 570 Map optionsFromFile;
573 bool hasCompileError; 571 bool hasCompileError;
574 bool hasRuntimeError; 572 bool hasRuntimeError;
575 bool isNegativeIfChecked; 573 bool isNegativeIfChecked;
576 bool hasCompileErrorIfChecked; 574 bool hasCompileErrorIfChecked;
577 bool hasStaticWarning; 575 bool hasStaticWarning;
578 Set<String> multitestOutcome;
579 String multitestKey; 576 String multitestKey;
580 577
581 TestInformation(this.filePath, this.optionsFromFile, 578 TestInformation(this.filePath, this.optionsFromFile,
582 this.hasCompileError, this.hasRuntimeError, 579 this.hasCompileError, this.hasRuntimeError,
583 this.isNegativeIfChecked, this.hasCompileErrorIfChecked, 580 this.isNegativeIfChecked, this.hasCompileErrorIfChecked,
584 this.hasStaticWarning, 581 this.hasStaticWarning,
585 this.multitestOutcome,
586 {this.multitestKey, this.originTestPath}) { 582 {this.multitestKey, this.originTestPath}) {
587 assert(filePath.isAbsolute); 583 assert(filePath.isAbsolute);
588 if (originTestPath == null) originTestPath = filePath; 584 if (originTestPath == null) originTestPath = filePath;
589 } 585 }
590 } 586 }
591 587
592 /** 588 /**
593 * A standard [TestSuite] implementation that searches for tests in a 589 * A standard [TestSuite] implementation that searches for tests in a
594 * directory, and creates [TestCase]s that compile and/or run them. 590 * directory, and creates [TestCase]s that compile and/or run them.
595 */ 591 */
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 return enqueueTests(); 694 return enqueueTests();
699 } else { 695 } else {
700 // We rely on enqueueing completing asynchronously. 696 // We rely on enqueueing completing asynchronously.
701 return asynchronously(() { 697 return asynchronously(() {
702 for (var info in testCache[suiteName]) { 698 for (var info in testCache[suiteName]) {
703 enqueueTestCaseFromTestInformation(info); 699 enqueueTestCaseFromTestInformation(info);
704 } 700 }
705 }); 701 });
706 } 702 }
707 }).then((_) { 703 }).then((_) {
704 testExpectations = null;
705 cachedTests = null;
706 doTest = null;
708 if (onDone != null) onDone(); 707 if (onDone != null) onDone();
709 }); 708 });
710 } 709 }
711 710
712 /** 711 /**
713 * If Content shell/Dartium is required, and not yet updated, waits for 712 * If Content shell/Dartium is required, and not yet updated, waits for
714 * the update then completes. Otherwise completes immediately. 713 * the update then completes. Otherwise completes immediately.
715 */ 714 */
716 Future updateDartium() { 715 Future updateDartium() {
717 var completer = new Completer(); 716 var completer = new Completer();
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 environmentOverrides)); 1017 environmentOverrides));
1019 } 1018 }
1020 1019
1021 CreateTest makeTestCaseCreator(Map optionsFromFile) { 1020 CreateTest makeTestCaseCreator(Map optionsFromFile) {
1022 return (Path filePath, 1021 return (Path filePath,
1023 bool hasCompileError, 1022 bool hasCompileError,
1024 bool hasRuntimeError, 1023 bool hasRuntimeError,
1025 {bool isNegativeIfChecked: false, 1024 {bool isNegativeIfChecked: false,
1026 bool hasCompileErrorIfChecked: false, 1025 bool hasCompileErrorIfChecked: false,
1027 bool hasStaticWarning: false, 1026 bool hasStaticWarning: false,
1028 Set<String> multitestOutcome: null,
1029 String multitestKey, 1027 String multitestKey,
1030 Path originTestPath}) { 1028 Path originTestPath}) {
1031 // Cache the test information for each test case. 1029 // Cache the test information for each test case.
1032 var info = new TestInformation(filePath, 1030 var info = new TestInformation(filePath,
1033 optionsFromFile, 1031 optionsFromFile,
1034 hasCompileError, 1032 hasCompileError,
1035 hasRuntimeError, 1033 hasRuntimeError,
1036 isNegativeIfChecked, 1034 isNegativeIfChecked,
1037 hasCompileErrorIfChecked, 1035 hasCompileErrorIfChecked,
1038 hasStaticWarning, 1036 hasStaticWarning,
1039 multitestOutcome,
1040 multitestKey: multitestKey, 1037 multitestKey: multitestKey,
1041 originTestPath: originTestPath); 1038 originTestPath: originTestPath);
1042 cachedTests.add(info); 1039 cachedTests.add(info);
1043 enqueueTestCaseFromTestInformation(info); 1040 enqueueTestCaseFromTestInformation(info);
1044 }; 1041 };
1045 } 1042 }
1046 1043
1047 /** 1044 /**
1048 * _createUrlPathFromFile takes a [file], which is either located in the dart 1045 * _createUrlPathFromFile takes a [file], which is either located in the dart
1049 * or in the build directory, and will return a String representing 1046 * or in the build directory, and will return a String representing
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 * $pass tests are expected to pass 2219 * $pass tests are expected to pass
2223 * $failOk tests are expected to fail that we won't fix 2220 * $failOk tests are expected to fail that we won't fix
2224 * $fail tests are expected to fail that we should fix 2221 * $fail tests are expected to fail that we should fix
2225 * $crash tests are expected to crash that we should fix 2222 * $crash tests are expected to crash that we should fix
2226 * $timeout tests are allowed to timeout 2223 * $timeout tests are allowed to timeout
2227 * $compileErrorSkip tests are skipped on browsers due to compile-time error 2224 * $compileErrorSkip tests are skipped on browsers due to compile-time error
2228 """; 2225 """;
2229 print(report); 2226 print(report);
2230 } 2227 }
2231 } 2228 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698