| 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 library browser; | 4 library browser; |
| 5 | 5 |
| 6 import "dart:async"; | 6 import "dart:async"; |
| 7 import "dart:convert" show LineSplitter, UTF8; | 7 import "dart:convert" show LineSplitter, UTF8; |
| 8 import "dart:core"; | 8 import "dart:core"; |
| 9 import "dart:io"; | 9 import "dart:io"; |
| 10 | 10 |
| (...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 status.currentTest.timeoutTimer = | 991 status.currentTest.timeoutTimer = |
| 992 createTimeoutTimer(status.currentTest, status); | 992 createTimeoutTimer(status.currentTest, status); |
| 993 status.currentTest.delayUntilTestStarted = | 993 status.currentTest.delayUntilTestStarted = |
| 994 status.currentTest.stopwatch.elapsed; | 994 status.currentTest.stopwatch.elapsed; |
| 995 } | 995 } |
| 996 } | 996 } |
| 997 | 997 |
| 998 void handleTimeout(BrowserTestingStatus status) { | 998 void handleTimeout(BrowserTestingStatus status) { |
| 999 // We simply kill the browser and starts up a new one! | 999 // We simply kill the browser and starts up a new one! |
| 1000 // We could be smarter here, but it does not seems like it is worth it. | 1000 // We could be smarter here, but it does not seems like it is worth it. |
| 1001 if (status.timeout) { |
| 1002 DebugLogger.error( |
| 1003 "Got test timeout for an already restarting browser"); |
| 1004 return; |
| 1005 } |
| 1001 status.timeout = true; | 1006 status.timeout = true; |
| 1002 timedOut.add(status.currentTest.url); | 1007 timedOut.add(status.currentTest.url); |
| 1003 var id = status.browser.id; | 1008 var id = status.browser.id; |
| 1004 | 1009 |
| 1005 status.currentTest.stopwatch.stop(); | 1010 status.currentTest.stopwatch.stop(); |
| 1006 status.browser.close().then((_) { | 1011 status.browser.close().then((_) { |
| 1007 var lastKnownMessage = | 1012 var lastKnownMessage = |
| 1008 'Dom could not be fetched, since the test timed out.'; | 1013 'Dom could not be fetched, since the test timed out.'; |
| 1009 if (status.currentTest.lastKnownMessage.length > 0) { | 1014 if (status.currentTest.lastKnownMessage.length > 0) { |
| 1010 lastKnownMessage = status.currentTest.lastKnownMessage; | 1015 lastKnownMessage = status.currentTest.lastKnownMessage; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 // We are currently terminating this browser, don't start a new test. | 1092 // We are currently terminating this browser, don't start a new test. |
| 1088 if (status.timeout) return null; | 1093 if (status.timeout) return null; |
| 1089 | 1094 |
| 1090 // Restart content_shell and dartium on Android if they have been | 1095 // Restart content_shell and dartium on Android if they have been |
| 1091 // running for longer than RESTART_BROWSER_INTERVAL. The tests have | 1096 // running for longer than RESTART_BROWSER_INTERVAL. The tests have |
| 1092 // had flaky timeouts, and this may help. | 1097 // had flaky timeouts, and this may help. |
| 1093 if ((browserName == 'ContentShellOnAndroid' || | 1098 if ((browserName == 'ContentShellOnAndroid' || |
| 1094 browserName == 'DartiumOnAndroid' ) && | 1099 browserName == 'DartiumOnAndroid' ) && |
| 1095 status.timeSinceRestart.elapsed > RESTART_BROWSER_INTERVAL) { | 1100 status.timeSinceRestart.elapsed > RESTART_BROWSER_INTERVAL) { |
| 1096 var id = status.browser.id; | 1101 var id = status.browser.id; |
| 1102 // Reset stopwatch so we don't trigger again before restarting. |
| 1103 status.timeout = true; |
| 1097 status.browser.close().then((_) { | 1104 status.browser.close().then((_) { |
| 1098 // We don't want to start a new browser if we are terminating. | 1105 // We don't want to start a new browser if we are terminating. |
| 1099 if (underTermination) return; | 1106 if (underTermination) return; |
| 1100 restartBrowser(id); | 1107 restartBrowser(id); |
| 1101 }); | 1108 }); |
| 1102 // Don't send a test to the browser we are restarting. | 1109 // Don't send a test to the browser we are restarting. |
| 1103 return null; | 1110 return null; |
| 1104 } | 1111 } |
| 1105 | 1112 |
| 1106 BrowserTest test = testQueue.removeLast(); | 1113 BrowserTest test = testQueue.removeLast(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1136 } | 1143 } |
| 1137 | 1144 |
| 1138 Timer createNextTestTimer(BrowserTestingStatus status) { | 1145 Timer createNextTestTimer(BrowserTestingStatus status) { |
| 1139 return new Timer(BrowserTestRunner.NEXT_TEST_TIMEOUT, | 1146 return new Timer(BrowserTestRunner.NEXT_TEST_TIMEOUT, |
| 1140 () { handleNextTestTimeout(status); }); | 1147 () { handleNextTestTimeout(status); }); |
| 1141 } | 1148 } |
| 1142 | 1149 |
| 1143 void handleNextTestTimeout(status) { | 1150 void handleNextTestTimeout(status) { |
| 1144 DebugLogger.warning( | 1151 DebugLogger.warning( |
| 1145 "Browser timed out before getting next test. Restarting"); | 1152 "Browser timed out before getting next test. Restarting"); |
| 1153 if (status.timeout) return; |
| 1146 numBrowserGetTestTimeouts++; | 1154 numBrowserGetTestTimeouts++; |
| 1147 if (numBrowserGetTestTimeouts >= MAX_NEXT_TEST_TIMEOUTS) { | 1155 if (numBrowserGetTestTimeouts >= MAX_NEXT_TEST_TIMEOUTS) { |
| 1148 DebugLogger.error( | 1156 DebugLogger.error( |
| 1149 "Too many browser timeouts before getting next test. Terminating"); | 1157 "Too many browser timeouts before getting next test. Terminating"); |
| 1150 terminate().then((_) => exit(1)); | 1158 terminate().then((_) => exit(1)); |
| 1151 } else { | 1159 } else { |
| 1160 status.timeout = true; |
| 1152 status.browser.close().then((_) => restartBrowser(status.browser.id)); | 1161 status.browser.close().then((_) => restartBrowser(status.browser.id)); |
| 1153 } | 1162 } |
| 1154 } | 1163 } |
| 1155 | 1164 |
| 1156 void queueTest(BrowserTest test) { | 1165 void queueTest(BrowserTest test) { |
| 1157 testQueue.add(test); | 1166 testQueue.add(test); |
| 1158 } | 1167 } |
| 1159 | 1168 |
| 1160 void printDoubleReportingTests() { | 1169 void printDoubleReportingTests() { |
| 1161 if (doubleReportingOutputs.length == 0) return; | 1170 if (doubleReportingOutputs.length == 0) return; |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 Dart test driver, number of tests: <div id="number"></div><br> | 1586 Dart test driver, number of tests: <div id="number"></div><br> |
| 1578 Currently executing: <div id="currently_executing"></div><br> | 1587 Currently executing: <div id="currently_executing"></div><br> |
| 1579 Unhandled error: <div id="unhandled_error"></div> | 1588 Unhandled error: <div id="unhandled_error"></div> |
| 1580 <iframe id="embedded_iframe"></iframe> | 1589 <iframe id="embedded_iframe"></iframe> |
| 1581 </body> | 1590 </body> |
| 1582 </html> | 1591 </html> |
| 1583 """; | 1592 """; |
| 1584 return driverContent; | 1593 return driverContent; |
| 1585 } | 1594 } |
| 1586 } | 1595 } |
| OLD | NEW |