Author: [email protected]
Date: Mon Jul 13 14:17:58 2009
New Revision: 5726

Added:
     
trunk/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerDisableAssertions.java
Modified:
    trunk/dev/core/src/com/google/gwt/dev/GWTShell.java
    trunk/dev/core/src/com/google/gwt/dev/HostedModeBase.java
    trunk/dev/core/src/com/google/gwt/dev/Precompile.java
     
trunk/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerEnableAssertions.java
    trunk/dev/core/test/com/google/gwt/dev/GWTShellTest.java
    trunk/user/src/com/google/gwt/junit/JUnitShell.java

Log:
Adding -da flag to disable assertions, and flipping the default for tests
to have assertions on unless -da is used.

Patch by: flin
Review by: fabbott



Modified: trunk/dev/core/src/com/google/gwt/dev/GWTShell.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/GWTShell.java (original)
+++ trunk/dev/core/src/com/google/gwt/dev/GWTShell.java Mon Jul 13 14:17:58  
2009
@@ -90,7 +90,7 @@
    /**
     * Concrete class to implement all shell options.
     */
-  static class ShellOptionsImpl extends HostedModeBaseOptionsImpl  
implements
+  protected static class ShellOptionsImpl extends  
HostedModeBaseOptionsImpl implements
        HostedModeBaseOptions, WorkDirs, LegacyCompilerOptions {
      private int localWorkers;
      private File outDir;

Modified: trunk/dev/core/src/com/google/gwt/dev/HostedModeBase.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/HostedModeBase.java   (original)
+++ trunk/dev/core/src/com/google/gwt/dev/HostedModeBase.java   Mon Jul 13  
14:17:58 2009
@@ -32,6 +32,7 @@
  import com.google.gwt.dev.shell.ShellModuleSpaceHost;
  import com.google.gwt.dev.util.Util;
  import com.google.gwt.dev.util.arg.ArgHandlerDisableAggressiveOptimization;
+import com.google.gwt.dev.util.arg.ArgHandlerDisableAssertions;
  import com.google.gwt.dev.util.arg.ArgHandlerDisableCastChecking;
  import com.google.gwt.dev.util.arg.ArgHandlerDisableClassMetadata;
  import com.google.gwt.dev.util.arg.ArgHandlerDraftCompile;
@@ -321,6 +322,7 @@
        registerHandler(new ArgHandlerGenDir(options));
        registerHandler(new ArgHandlerScriptStyle(options));
        registerHandler(new ArgHandlerEnableAssertions(options));
+      registerHandler(new ArgHandlerDisableAssertions(options));
        registerHandler(new  
ArgHandlerDisableAggressiveOptimization(options));
        registerHandler(new ArgHandlerDisableClassMetadata(options));
        registerHandler(new ArgHandlerDisableCastChecking(options));

Modified: trunk/dev/core/src/com/google/gwt/dev/Precompile.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/Precompile.java       (original)
+++ trunk/dev/core/src/com/google/gwt/dev/Precompile.java       Mon Jul 13  
14:17:58 2009
@@ -43,6 +43,7 @@
  import com.google.gwt.dev.util.PerfLogger;
  import com.google.gwt.dev.util.Util;
  import com.google.gwt.dev.util.arg.ArgHandlerDisableAggressiveOptimization;
+import com.google.gwt.dev.util.arg.ArgHandlerDisableAssertions;
  import com.google.gwt.dev.util.arg.ArgHandlerDisableCastChecking;
  import com.google.gwt.dev.util.arg.ArgHandlerDisableClassMetadata;
  import com.google.gwt.dev.util.arg.ArgHandlerDisableRunAsync;
@@ -94,6 +95,7 @@
        registerHandler(new ArgHandlerGenDir(options));
        registerHandler(new ArgHandlerScriptStyle(options));
        registerHandler(new ArgHandlerEnableAssertions(options));
+      registerHandler(new ArgHandlerDisableAssertions(options));
        registerHandler(new  
ArgHandlerDisableAggressiveOptimization(options));
        registerHandler(new ArgHandlerDisableClassMetadata(options));
        registerHandler(new ArgHandlerDisableCastChecking(options));

Added:  
trunk/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerDisableAssertions.java
==============================================================================
--- (empty file)
+++  
trunk/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerDisableAssertions.java 
 
Mon Jul 13 14:17:58 2009
@@ -0,0 +1,47 @@
+/*
+ * 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.dev.util.arg;
+
+import com.google.gwt.util.tools.ArgHandlerFlag;
+
+/**
+ * Handler for -da arg to disable assertions in compiled code.
+ */
+public final class ArgHandlerDisableAssertions extends ArgHandlerFlag {
+
+  private final OptionEnableAssertions option;
+
+  public ArgHandlerDisableAssertions(OptionEnableAssertions option) {
+    this.option = option;
+  }
+
+  @Override
+  public String getPurpose() {
+    return "Debugging: disables checking assertion statements in the  
compiled output.";
+  }
+
+  @Override
+  public String getTag() {
+    return "-da";
+  }
+
+  @Override
+  public boolean setFlag() {
+    option.setEnableAssertions(false);
+    return true;
+  }
+
+}

Modified:  
trunk/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerEnableAssertions.java
==============================================================================
---  
trunk/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerEnableAssertions.java  
 
(original)
+++  
trunk/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerEnableAssertions.java  
 
Mon Jul 13 14:17:58 2009
@@ -30,7 +30,7 @@

    @Override
    public String getPurpose() {
-    return "Debugging: causes the compiled output to check assert  
statements.";
+    return "Debugging: enables checking assertion statements in the  
compiled output.";
    }

    @Override

Modified: trunk/dev/core/test/com/google/gwt/dev/GWTShellTest.java
==============================================================================
--- trunk/dev/core/test/com/google/gwt/dev/GWTShellTest.java    (original)
+++ trunk/dev/core/test/com/google/gwt/dev/GWTShellTest.java    Mon Jul 13  
14:17:58 2009
@@ -76,6 +76,16 @@
      assertEquals("foo", options.getStartupURLs().get(1));
    }

+  public void testAssertionsArgs() {
+    // Assertion is enabled by default in web mode, i.e. -ea flag.
+    assertProcessSuccess(argProcessor, "-ea");
+    assertTrue(options.isEnableAssertions());
+    assertProcessSuccess(argProcessor, "-da");
+    assertFalse(options.isEnableAssertions());
+    assertProcessSuccess(argProcessor, "-ea");
+    assertTrue(options.isEnableAssertions());
+  }
+
    public void testDefaultArgs() {
      assertProcessSuccess(argProcessor);


Modified: trunk/user/src/com/google/gwt/junit/JUnitShell.java
==============================================================================
--- trunk/user/src/com/google/gwt/junit/JUnitShell.java (original)
+++ trunk/user/src/com/google/gwt/junit/JUnitShell.java Mon Jul 13 14:17:58  
2009
@@ -1,12 +1,12 @@
  /*
   * Copyright 2008 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
@@ -52,26 +52,26 @@
  /**
   * This class is responsible for hosting JUnit test case execution. There  
are
   * three main pieces to the JUnit system.
- *
+ *
   * <ul>
   * <li>Test environment</li>
   * <li>Client classes</li>
   * <li>Server classes</li>
   * </ul>
- *
+ *
   * <p>
   * The test environment consists of this class and the non-translatable  
version
   * of {...@link com.google.gwt.junit.client.GWTTestCase}. These two classes
   * integrate directly into the real JUnit test process.
   * </p>
- *
+ *
   * <p>
   * The client classes consist of the translatable version of {...@link
   * com.google.gwt.junit.client.GWTTestCase}, translatable JUnit classes,  
and the
   * user's own {...@link com.google.gwt.junit.client.GWTTestCase}-derived  
class.
   * The client communicates to the server via RPC.
   * </p>
- *
+ *
   * <p>
   * The server consists of {...@link  
com.google.gwt.junit.server.JUnitHostImpl}, an
   * RPC servlet which communicates back to the test environment through a
@@ -351,7 +351,7 @@
    /**
     * Called by {...@link com.google.gwt.junit.server.JUnitHostImpl} to get an
     * interface into the test process.
-   *
+   *
     * @return The {...@link JUnitMessageQueue} interface that belongs to the
     *         singleton {...@link JUnitShell}, or <code>null</code> if no such
     *         singleton exists.
@@ -522,6 +522,9 @@
      if (System.getProperty(PROP_JUNIT_HYBRID_MODE) != null) {
        runStyle = new RunStyleLocalWeb(this);
      }
+    // If no explicit disable argument presented,
+    // Enables assertions by default in all tests
+    options.setEnableAssertions(true);
    }

    @Override

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

Reply via email to