| 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/test_runner.dart"; | 8 import "../../../tools/testing/dart/test_runner.dart"; |
| 9 import "../../../tools/testing/dart/test_suite.dart"; | 9 import "../../../tools/testing/dart/test_suite.dart"; |
| 10 import "../../../tools/testing/dart/test_progress.dart" as progress; | 10 import "../../../tools/testing/dart/test_progress.dart" as progress; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 class CustomTestSuite extends TestSuite { | 45 class CustomTestSuite extends TestSuite { |
| 46 CustomTestSuite() : super({}, "CustomTestSuite"); | 46 CustomTestSuite() : super({}, "CustomTestSuite"); |
| 47 | 47 |
| 48 void forEachTest(TestCaseEvent onTest, Map testCache, [onDone]) { | 48 void forEachTest(TestCaseEvent onTest, Map testCache, [onDone]) { |
| 49 void enqueueTestCase(testCase) { | 49 void enqueueTestCase(testCase) { |
| 50 TestController.numTests++; | 50 TestController.numTests++; |
| 51 onTest(testCase); | 51 onTest(testCase); |
| 52 } | 52 } |
| 53 | 53 |
| 54 var testCaseCrash = _makeCrashTestCase("crash", [CRASH]); | 54 var testCaseCrash = _makeCrashTestCase("crash", [Expectation.CRASH]); |
| 55 var testCasePass = _makeNormalTestCase("pass", [PASS]); | 55 var testCasePass = _makeNormalTestCase("pass", [Expectation.PASS]); |
| 56 var testCaseFail = _makeNormalTestCase("fail", [FAIL]); | 56 var testCaseFail = _makeNormalTestCase("fail", [Expectation.FAIL]); |
| 57 var testCaseTimeout = _makeNormalTestCase("timeout", [TIMEOUT]); | 57 var testCaseTimeout = _makeNormalTestCase("timeout", [Expectation.TIMEOUT]); |
| 58 var testCaseFailUnexpected = | 58 var testCaseFailUnexpected = |
| 59 _makeNormalTestCase("fail-unexpected", [PASS]); | 59 _makeNormalTestCase("fail-unexpected", [Expectation.PASS]); |
| 60 | 60 |
| 61 enqueueTestCase(testCaseCrash); | 61 enqueueTestCase(testCaseCrash); |
| 62 enqueueTestCase(testCasePass); | 62 enqueueTestCase(testCasePass); |
| 63 enqueueTestCase(testCaseFail); | 63 enqueueTestCase(testCaseFail); |
| 64 enqueueTestCase(testCaseTimeout); | 64 enqueueTestCase(testCaseTimeout); |
| 65 enqueueTestCase(testCaseFailUnexpected); | 65 enqueueTestCase(testCaseFailUnexpected); |
| 66 | 66 |
| 67 if (onDone != null) { | 67 if (onDone != null) { |
| 68 onDone(); | 68 onDone(); |
| 69 } | 69 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 87 // delays. | 87 // delays. |
| 88 return _makeTestCase(name, LONG_TIMEOUT, crashCommand, expectations); | 88 return _makeTestCase(name, LONG_TIMEOUT, crashCommand, expectations); |
| 89 } | 89 } |
| 90 | 90 |
| 91 _makeTestCase(name, timeout, command, expectations) { | 91 _makeTestCase(name, timeout, command, expectations) { |
| 92 var configuration = new TestOptionsParser() | 92 var configuration = new TestOptionsParser() |
| 93 .parse(['--timeout', '$timeout'])[0]; | 93 .parse(['--timeout', '$timeout'])[0]; |
| 94 return new TestCase(name, | 94 return new TestCase(name, |
| 95 [command], | 95 [command], |
| 96 configuration, | 96 configuration, |
| 97 new Set<String>.from(expectations)); | 97 new Set<Expectation>.from(expectations)); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 void testProcessQueue() { | 101 void testProcessQueue() { |
| 102 var maxProcesses = 2; | 102 var maxProcesses = 2; |
| 103 var maxBrowserProcesses = maxProcesses; | 103 var maxBrowserProcesses = maxProcesses; |
| 104 new ProcessQueue({'noBatch' : true}, maxProcesses, maxBrowserProcesses, | 104 new ProcessQueue({'noBatch' : true}, maxProcesses, maxBrowserProcesses, |
| 105 new DateTime.now(), [new CustomTestSuite()], | 105 new DateTime.now(), [new CustomTestSuite()], |
| 106 [new EventListener()], TestController.finished); | 106 [new EventListener()], TestController.finished); |
| 107 } | 107 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 129 break; | 129 break; |
| 130 case 'timeout': | 130 case 'timeout': |
| 131 // Run for 10 seconds, then exit. This tests a 2 second timeout. | 131 // Run for 10 seconds, then exit. This tests a 2 second timeout. |
| 132 new Timer(new Duration(seconds: 10), (){ }); | 132 new Timer(new Duration(seconds: 10), (){ }); |
| 133 break; | 133 break; |
| 134 default: | 134 default: |
| 135 throw "Unknown option ${arguments[0]} passed to test_runner_test"; | 135 throw "Unknown option ${arguments[0]} passed to test_runner_test"; |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 } | 138 } |
| OLD | NEW |