| OLD | NEW |
| 1 // Copyright (c) 2012, 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 "dart:utf"; | 8 import "dart:utf"; |
| 9 import "../../../tools/testing/dart/test_runner.dart"; | 9 import "../../../tools/testing/dart/test_runner.dart"; |
| 10 import "../../../tools/testing/dart/test_suite.dart"; | 10 import "../../../tools/testing/dart/test_suite.dart"; |
| 11 import "../../../tools/testing/dart/status_file_parser.dart"; | 11 import "../../../tools/testing/dart/status_file_parser.dart"; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 TestCase _makeNormalTestCase(name, expectations) { | 66 TestCase _makeNormalTestCase(name, expectations) { |
| 67 var command = new Command(new Options().executable, | 67 var command = new Command(new Options().executable, |
| 68 [new Options().script, name]); | 68 [new Options().script, name]); |
| 69 return _makeTestCase(name, DEFAULT_TIMEOUT, command, expectations); | 69 return _makeTestCase(name, DEFAULT_TIMEOUT, command, expectations); |
| 70 } | 70 } |
| 71 | 71 |
| 72 _makeCrashTestCase(name, expectations) { | 72 _makeCrashTestCase(name, expectations) { |
| 73 var crashCommand = new Command(getProcessTestFileName(), | 73 var crashCommand = new Command(getProcessTestFileName(), |
| 74 ["0", "0", "1", "1"]); | 74 ["0", "0", "1", "1"]); |
| 75 // The crash test sometimes times out. Run it with a large timeout | 75 // The crash test sometimes times out. Run it with a large timeout |
| 76 // to help diagnose the delay. | 76 // to help diagnose the delay. |
| 77 // The test loads a new executable, which may sometimes take a long time. | 77 // The test loads a new executable, which may sometimes take a long time. |
| 78 // It involves a wait on the VM event loop, and possible system | 78 // It involves a wait on the VM event loop, and possible system |
| 79 // delays. | 79 // delays. |
| 80 return _makeTestCase(name, LONG_TIMEOUT, crashCommand, expectations); | 80 return _makeTestCase(name, LONG_TIMEOUT, crashCommand, expectations); |
| 81 } | 81 } |
| 82 | 82 |
| 83 _makeTestCase(name, timeout, command, expectations) { | 83 _makeTestCase(name, timeout, command, expectations) { |
| 84 var configuration = new TestOptionsParser() | 84 var configuration = new TestOptionsParser() |
| 85 .parse(['--timeout', '$timeout'])[0]; | 85 .parse(['--timeout', '$timeout'])[0]; |
| 86 return new TestCase(name, | 86 return new TestCase(name, |
| 87 [command], | 87 [command], |
| 88 configuration, | 88 configuration, |
| 89 TestController.processCompletedTest, | 89 TestController.processCompletedTest, |
| 90 new Set<String>.from(expectations)); | 90 new Set<String>.from(expectations)); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 void testProcessQueue() { | 94 void testProcessQueue() { |
| 95 var maxProcesses = 2; | 95 var maxProcesses = 2; |
| 96 var maxBrowserProcesses = maxProcesses; | 96 var maxBrowserProcesses = maxProcesses; |
| 97 new ProcessQueue(maxProcesses, maxBrowserProcesses, | 97 new ProcessQueue(maxProcesses, maxBrowserProcesses, |
| 98 new Date.now(), [new CustomTestSuite()], [], TestController.finished); | 98 new DateTime.now(), [new CustomTestSuite()], [], TestController.finished); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void main() { | 101 void main() { |
| 102 // Run the test_runner_test if there are no command-line options. | 102 // Run the test_runner_test if there are no command-line options. |
| 103 // Otherwise, run one of the component tests that always pass, | 103 // Otherwise, run one of the component tests that always pass, |
| 104 // fail, or timeout. | 104 // fail, or timeout. |
| 105 var arguments = new Options().arguments; | 105 var arguments = new Options().arguments; |
| 106 if (arguments.isEmpty) { | 106 if (arguments.isEmpty) { |
| 107 testProcessQueue(); | 107 testProcessQueue(); |
| 108 } else { | 108 } else { |
| 109 switch (arguments[0]) { | 109 switch (arguments[0]) { |
| 110 case 'pass': | 110 case 'pass': |
| 111 return; | 111 return; |
| 112 case 'fail-unexpected': | 112 case 'fail-unexpected': |
| 113 case 'fail': | 113 case 'fail': |
| 114 Expect.fail("This test always fails, to test the test scripts."); | 114 Expect.fail("This test always fails, to test the test scripts."); |
| 115 break; | 115 break; |
| 116 case 'timeout': | 116 case 'timeout': |
| 117 // Run for 10 seconds, then exit. This tests a 2 second timeout. | 117 // Run for 10 seconds, then exit. This tests a 2 second timeout. |
| 118 new Timer(new Duration(seconds: 10), (){ }); | 118 new Timer(new Duration(seconds: 10), (){ }); |
| 119 break; | 119 break; |
| 120 default: | 120 default: |
| 121 throw "Unknown option ${arguments[0]} passed to test_runner_test"; | 121 throw "Unknown option ${arguments[0]} passed to test_runner_test"; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 } | 124 } |
| OLD | NEW |