Chromium Code Reviews| 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:isolate"; | 6 import "dart:isolate"; |
| 7 import "dart:async"; | 7 import "dart:async"; |
| 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/status_file.dart"; | 10 import "../../../tools/testing/dart/status_file.dart"; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 if (numTests != numCompletedTests) { | 62 if (numTests != numCompletedTests) { |
| 63 throw "bad completion count. " | 63 throw "bad completion count. " |
| 64 "expected: $numTests, actual: $numCompletedTests"; | 64 "expected: $numTests, actual: $numCompletedTests"; |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 class CustomTestSuite extends TestSuite { | 69 class CustomTestSuite extends TestSuite { |
| 70 CustomTestSuite(Map configuration) : super(configuration, "CustomTestSuite"); | 70 CustomTestSuite(Map configuration) : super(configuration, "CustomTestSuite"); |
| 71 | 71 |
| 72 void forEachTest(TestCaseEvent onTest, Map testCache, [onDone]) { | 72 Future forEachTest(TestCaseEvent onTest, Map testCache, [onDone]) { |
| 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; | |
|
Paul Berry
2017/05/30 22:26:29
It's not obvious why this is ok. Can we add a com
| |
| 94 } | 96 } |
| 95 | 97 |
| 96 TestCase _makeNormalTestCase(name, expectations) { | 98 TestCase _makeNormalTestCase(name, expectations) { |
| 97 var args = packageOptions(); | 99 var args = packageOptions(); |
| 98 args.addAll([Platform.script.toFilePath(), name]); | 100 args.addAll([Platform.script.toFilePath(), name]); |
| 99 var command = CommandBuilder.instance | 101 var command = CommandBuilder.instance |
| 100 .getProcessCommand('custom', Platform.executable, args, {}); | 102 .getProcessCommand('custom', Platform.executable, args, {}); |
| 101 return _makeTestCase(name, DEFAULT_TIMEOUT, command, expectations); | 103 return _makeTestCase(name, DEFAULT_TIMEOUT, command, expectations); |
| 102 } | 104 } |
| 103 | 105 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 break; | 159 break; |
| 158 case 'timeout': | 160 case 'timeout': |
| 159 // This process should be killed by the test after DEFAULT_TIMEOUT | 161 // This process should be killed by the test after DEFAULT_TIMEOUT |
| 160 new Timer(new Duration(hours: 42), () {}); | 162 new Timer(new Duration(hours: 42), () {}); |
| 161 break; | 163 break; |
| 162 default: | 164 default: |
| 163 throw "Unknown option ${arguments[0]} passed to test_runner_test"; | 165 throw "Unknown option ${arguments[0]} passed to test_runner_test"; |
| 164 } | 166 } |
| 165 } | 167 } |
| 166 } | 168 } |
| OLD | NEW |