Revision: 6157
Author: [email protected]
Date: Thu Sep 17 13:59:15 2009
Log: Fixes a bug in CompileStrategy where it would throw an  
IllegalArgumentException if tests are run out of module order.

Patch by: jlabanca
Review by: jgw


http://code.google.com/p/google-web-toolkit/source/detail?r=6157

Added:
  /trunk/user/test/com/google/gwt/junit/JUnitTest.gwt.xml
  /trunk/user/test/com/google/gwt/junit/JUnitTest2.gwt.xml
  /trunk/user/test/com/google/gwt/junit/TestSuiteTest.java
  /trunk/user/test/com/google/gwt/junit/client/ModuleOneTest.java
  /trunk/user/test/com/google/gwt/junit/client/ModuleOneTest2.java
  /trunk/user/test/com/google/gwt/junit/client/ModuleTwoTest.java
Modified:
  /trunk/user/src/com/google/gwt/junit/CompileStrategy.java

=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/junit/JUnitTest.gwt.xml     Thu Sep 17  
13:59:15 2009
@@ -0,0 +1,17 @@
+<!--                                                                         
-->
+<!-- Copyright 2009 Google  
Inc.                                             -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License");  
you    -->
+<!-- may not use this file except in compliance with the License. You  
may   -->
+<!-- may obtain a copy of the License  
at                                    -->
+<!--                                                                         
-->
+<!--  
http://www.apache.org/licenses/LICENSE-2.0                             -->
+<!--                                                                         
-->
+<!-- Unless required by applicable law or agreed to in writing,  
software    -->
+<!-- distributed under the License is distributed on an "AS IS"  
BASIS,      -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express  
or        -->
+<!-- implied. License for the specific language governing permissions  
and   -->
+<!-- limitations under the  
License.                                         -->
+
+<module>
+  <inherits name="com.google.gwt.user.User"/>
+</module>
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/junit/JUnitTest2.gwt.xml    Thu Sep 17  
13:59:15 2009
@@ -0,0 +1,17 @@
+<!--                                                                         
-->
+<!-- Copyright 2009 Google  
Inc.                                             -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License");  
you    -->
+<!-- may not use this file except in compliance with the License. You  
may   -->
+<!-- may obtain a copy of the License  
at                                    -->
+<!--                                                                         
-->
+<!--  
http://www.apache.org/licenses/LICENSE-2.0                             -->
+<!--                                                                         
-->
+<!-- Unless required by applicable law or agreed to in writing,  
software    -->
+<!-- distributed under the License is distributed on an "AS IS"  
BASIS,      -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express  
or        -->
+<!-- implied. License for the specific language governing permissions  
and   -->
+<!-- limitations under the  
License.                                         -->
+
+<module>
+  <inherits name="com.google.gwt.user.User"/>
+</module>
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/junit/TestSuiteTest.java    Thu Sep 17  
13:59:15 2009
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may  
not
+ * use this file except in compliance with the License. You may obtain a  
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations  
under
+ * the License.
+ */
+package com.google.gwt.junit;
+
+import com.google.gwt.junit.client.ModuleOneTest;
+import com.google.gwt.junit.client.ModuleOneTest2;
+import com.google.gwt.junit.client.ModuleTwoTest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests that a normal test suite will run even if modules are out of  
order.
+ */
+public class TestSuiteTest {
+
+  public static Test suite() {
+    // This is intentionally not a GWTTestSuite.
+    TestSuite suite = new TestSuite();
+
+    suite.addTestSuite(ModuleOneTest.class);
+    suite.addTestSuite(ModuleTwoTest.class);
+    suite.addTestSuite(ModuleOneTest2.class);
+
+    return suite;
+  }
+}
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/junit/client/ModuleOneTest.java     Thu Sep 
 
17 13:59:15 2009
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may  
not
+ * use this file except in compliance with the License. You may obtain a  
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations  
under
+ * the License.
+ */
+package com.google.gwt.junit.client;
+
+/**
+ * A test in the first module.
+ */
+public class ModuleOneTest extends GWTTestCase {
+  @Override
+  public String getModuleName() {
+    return "com.google.gwt.junit.JUnitTest";
+  }
+
+  public void testTrue() {
+    assertTrue(true);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/junit/client/ModuleOneTest2.java    Thu  
Sep 17 13:59:15 2009
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may  
not
+ * use this file except in compliance with the License. You may obtain a  
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations  
under
+ * the License.
+ */
+package com.google.gwt.junit.client;
+
+/**
+ * Another test in the first module.
+ */
+public class ModuleOneTest2 extends GWTTestCase {
+  @Override
+  public String getModuleName() {
+    return "com.google.gwt.junit.JUnitTest";
+  }
+
+  public void testTrue() {
+    assertTrue(true);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/junit/client/ModuleTwoTest.java     Thu Sep 
 
17 13:59:15 2009
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may  
not
+ * use this file except in compliance with the License. You may obtain a  
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations  
under
+ * the License.
+ */
+package com.google.gwt.junit.client;
+
+/**
+ * A test in the second module.
+ */
+public class ModuleTwoTest extends GWTTestCase {
+  @Override
+  public String getModuleName() {
+    return "com.google.gwt.junit.JUnitTest2";
+  }
+
+  public void testTrue() {
+    assertTrue(true);
+  }
+}
=======================================
--- /trunk/user/src/com/google/gwt/junit/CompileStrategy.java   Tue Sep 15  
11:52:45 2009
+++ /trunk/user/src/com/google/gwt/junit/CompileStrategy.java   Thu Sep 17  
13:59:15 2009
@@ -20,6 +20,7 @@
  import com.google.gwt.dev.cfg.ConfigurationProperty;
  import com.google.gwt.dev.cfg.ModuleDef;
  import com.google.gwt.dev.cfg.ModuleDefLoader;
+import com.google.gwt.dev.util.collect.HashSet;
  import com.google.gwt.junit.JUnitShell.Strategy;
  import com.google.gwt.junit.client.GWTTestCase;
  import com.google.gwt.junit.client.GWTTestCase.TestModuleInfo;
@@ -30,6 +31,7 @@
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
+import java.util.Set;

  /**
   * An interface that specifies how modules should be compiled.
@@ -37,9 +39,10 @@
  public abstract class CompileStrategy {

    /**
-   * The number of modules that have been compiled.
+   * The list of modules that have already been compiled. We use this to  
avoid
+   * adding test batches that have already been added.
     */
-  private int compiledModuleCount;
+  private Set<String> compiledModuleNames = new HashSet<String>();

    /**
     * Let the compile strategy compile another module. This is called while
@@ -101,11 +104,14 @@

      runStyle.maybeCompileModule(syntheticModuleName);

-    // Add all test blocks for the module.
-    compiledModuleCount++;
-    boolean isFinalModule = compiledModuleCount ==  
GWTTestCase.getModuleCount();
-    List<TestInfo[]> testBlocks =  
batchingStrategy.getTestBlocks(syntheticModuleName);
-    JUnitShell.getMessageQueue().addTestBlocks(testBlocks, isFinalModule);
+    // Add all test blocks for the module if we haven't seen this module  
before.
+    if (!compiledModuleNames.contains(syntheticModuleName)) {
+      compiledModuleNames.add(syntheticModuleName);
+      boolean isFinalModule = compiledModuleNames.size() ==  
GWTTestCase.getModuleCount();
+      List<TestInfo[]> testBlocks =  
batchingStrategy.getTestBlocks(syntheticModuleName);
+      JUnitShell.getMessageQueue().addTestBlocks(testBlocks,  
isFinalModule);
+    }
+
      return moduleDef;
    }
  }

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to