| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import "dart:io"; | 5 import "dart:io"; |
| 6 import "dart:async"; | 6 import "dart:async"; |
| 7 import "../../../tools/testing/dart/configuration.dart"; | 7 import "../../../tools/testing/dart/configuration.dart"; |
| 8 import "../../../tools/testing/dart/expectation.dart"; | 8 import "../../../tools/testing/dart/expectation.dart"; |
| 9 import "../../../tools/testing/dart/options.dart"; | 9 import "../../../tools/testing/dart/options.dart"; |
| 10 import "../../../tools/testing/dart/test_runner.dart"; | 10 import "../../../tools/testing/dart/test_runner.dart"; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 throw "bad completion count. " | 62 throw "bad completion count. " |
| 63 "expected: $numTests, actual: $numCompletedTests"; | 63 "expected: $numTests, actual: $numCompletedTests"; |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 class CustomTestSuite extends TestSuite { | 68 class CustomTestSuite extends TestSuite { |
| 69 CustomTestSuite(Configuration configuration) | 69 CustomTestSuite(Configuration configuration) |
| 70 : super(configuration, "CustomTestSuite"); | 70 : super(configuration, "CustomTestSuite"); |
| 71 | 71 |
| 72 Future forEachTest(TestCaseEvent onTest, Map testCache, [onDone]) { | 72 Future forEachTest(TestCaseEvent onTest, Map testCache, [onDone]) async { |
| 73 void enqueueTestCase(testCase) { | 73 void enqueueTestCase(testCase) { |
| 74 TestController.numTests++; | 74 TestController.numTests++; |
| 75 onTest(testCase); | 75 onTest(testCase); |
| 76 } | 76 } |
| 77 | 77 |
| 78 var testCaseCrash = _makeCrashTestCase("crash", [Expectation.crash]); | 78 var testCaseCrash = _makeCrashTestCase("crash", [Expectation.crash]); |
| 79 var testCasePass = _makeNormalTestCase("pass", [Expectation.pass]); | 79 var testCasePass = _makeNormalTestCase("pass", [Expectation.pass]); |
| 80 var testCaseFail = _makeNormalTestCase("fail", [Expectation.fail]); | 80 var testCaseFail = _makeNormalTestCase("fail", [Expectation.fail]); |
| 81 var testCaseTimeout = _makeNormalTestCase("timeout", [Expectation.timeout]); | 81 var testCaseTimeout = _makeNormalTestCase("timeout", [Expectation.timeout]); |
| 82 var testCaseFailUnexpected = | 82 var testCaseFailUnexpected = |
| 83 _makeNormalTestCase("fail-unexpected", [Expectation.pass]); | 83 _makeNormalTestCase("fail-unexpected", [Expectation.pass]); |
| 84 | 84 |
| 85 enqueueTestCase(testCaseCrash); | 85 enqueueTestCase(testCaseCrash); |
| 86 enqueueTestCase(testCasePass); | 86 enqueueTestCase(testCasePass); |
| 87 enqueueTestCase(testCaseFail); | 87 enqueueTestCase(testCaseFail); |
| 88 enqueueTestCase(testCaseTimeout); | 88 enqueueTestCase(testCaseTimeout); |
| 89 enqueueTestCase(testCaseFailUnexpected); | 89 enqueueTestCase(testCaseFailUnexpected); |
| 90 | 90 |
| 91 if (onDone != null) { | 91 if (onDone != null) { |
| 92 onDone(); | 92 onDone(); |
| 93 } | 93 } |
| 94 | |
| 95 return null; | |
| 96 } | 94 } |
| 97 | 95 |
| 98 TestCase _makeNormalTestCase(name, expectations) { | 96 TestCase _makeNormalTestCase(name, expectations) { |
| 99 var args = packageOptions(); | 97 var args = packageOptions(); |
| 100 args.addAll([Platform.script.toFilePath(), name]); | 98 args.addAll([Platform.script.toFilePath(), name]); |
| 101 var command = CommandBuilder.instance | 99 var command = CommandBuilder.instance |
| 102 .getProcessCommand('custom', Platform.executable, args, {}); | 100 .getProcessCommand('custom', Platform.executable, args, {}); |
| 103 return _makeTestCase(name, DEFAULT_TIMEOUT, command, expectations); | 101 return _makeTestCase(name, DEFAULT_TIMEOUT, command, expectations); |
| 104 } | 102 } |
| 105 | 103 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 break; | 157 break; |
| 160 case 'timeout': | 158 case 'timeout': |
| 161 // This process should be killed by the test after DEFAULT_TIMEOUT | 159 // This process should be killed by the test after DEFAULT_TIMEOUT |
| 162 new Timer(new Duration(hours: 42), () {}); | 160 new Timer(new Duration(hours: 42), () {}); |
| 163 break; | 161 break; |
| 164 default: | 162 default: |
| 165 throw "Unknown option ${arguments[0]} passed to test_runner_test"; | 163 throw "Unknown option ${arguments[0]} passed to test_runner_test"; |
| 166 } | 164 } |
| 167 } | 165 } |
| 168 } | 166 } |
| OLD | NEW |