JUnitShell will wait indefinitely for a remote web test to start because BrowserManagerServer might queue the test for a while.
Patch by: jlabanca
Review by: jat
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6456 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/junit/JUnitShell.java b/user/src/com/google/gwt/junit/JUnitShell.java
index 99a42e3..b020a14 100644
--- a/user/src/com/google/gwt/junit/JUnitShell.java
+++ b/user/src/com/google/gwt/junit/JUnitShell.java
@@ -688,15 +688,22 @@
*/
protected boolean notDone() {
int activeClients = messageQueue.getNumClientsRetrievedTest(currentTestInfo);
- if (firstLaunch && runStyle instanceof RunStyleManual) {
- String[] newClients = messageQueue.getNewClients();
- int printIndex = activeClients - newClients.length + 1;
- for (String newClient : newClients) {
- System.out.println(printIndex + " - " + newClient);
- ++printIndex;
+ if (firstLaunch && runStyle.isStartDelayed()) {
+ // Pretty print the list of clients for manual tests.
+ if (runStyle instanceof RunStyleManual) {
+ String[] newClients = messageQueue.getNewClients();
+ int printIndex = activeClients - newClients.length + 1;
+ for (String newClient : newClients) {
+ System.out.println(printIndex + " - " + newClient);
+ ++printIndex;
+ }
}
- if (activeClients != this.numClients) {
- // Wait forever for first contact; user-driven.
+
+ if (runStyle.wasInterrupted()) {
+ // Exit early if the test is interrupted.
+ throw new TimeoutException("A remote browser died a mysterious death.");
+ } else if (activeClients != this.numClients) {
+ // Wait forever for first contact.
return true;
}
}
diff --git a/user/src/com/google/gwt/junit/RunStyle.java b/user/src/com/google/gwt/junit/RunStyle.java
index d054429..088cd94 100644
--- a/user/src/com/google/gwt/junit/RunStyle.java
+++ b/user/src/com/google/gwt/junit/RunStyle.java
@@ -51,6 +51,15 @@
}
/**
+ * Check whether or not tests start immediately or if they can be delayed.
+ *
+ * @return <code>true</code> if the test can be delayed
+ */
+ public boolean isStartDelayed() {
+ return false;
+ }
+
+ /**
* Requests initial launch of the browser. This should only be called once per
* instance of RunStyle.
*
diff --git a/user/src/com/google/gwt/junit/RunStyleManual.java b/user/src/com/google/gwt/junit/RunStyleManual.java
index 07e974a..5486a8f 100644
--- a/user/src/com/google/gwt/junit/RunStyleManual.java
+++ b/user/src/com/google/gwt/junit/RunStyleManual.java
@@ -46,6 +46,14 @@
return true;
}
+ /**
+ * Manual tests are started by users in user time.
+ */
+ @Override
+ public boolean isStartDelayed() {
+ return true;
+ }
+
@Override
public void launchModule(String moduleName) throws UnableToCompleteException {
if (numClients == 1) {
diff --git a/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java b/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
index 795762d..43dfd43 100644
--- a/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
+++ b/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
@@ -201,6 +201,14 @@
return true;
}
+ /**
+ * Remote web tests can be queued for extended periods.
+ */
+ @Override
+ public boolean isStartDelayed() {
+ return true;
+ }
+
@Override
public synchronized void launchModule(String moduleName)
throws UnableToCompleteException {