Revision: 4296
Author: jasvir
Date: Fri Oct  8 14:27:42 2010
Log: Cache successful tests so they don't have to be rerun at submission
http://codereview.appspot.com/2360044

If a test is successful, this change stores the output of svn diff in ant-lib. If no further changes are made before myvn submit, then tests do not get rerun.

[email protected]

http://code.google.com/p/google-caja/source/detail?r=4296

Modified:
 /trunk/build.xml
 /trunk/tools/myvn

=======================================
--- /trunk/build.xml    Fri Sep  3 17:29:26 2010
+++ /trunk/build.xml    Fri Oct  8 14:27:42 2010
@@ -244,6 +244,13 @@
       <report format="frames" todir="${reports}/tests"
        styledir="${third_party}/ant/etc"/>
     </junitreport>
+    <condition property="runtests.success">
+      <and>
+        <isfalse value="runtests.error"/>
+        <isfalse value="runtests.failure"/>
+      </and>
+    </condition>
+    <antcall target="CacheTestSuccess"/>
     <fail message=
"One or more tests failed. For details, see ${reports}/tests/index.html"
      if="runtests.error"/>
@@ -252,6 +259,17 @@
      if="runtests.failure"/>
   </target>

+  <target name="CacheTestSuccess" >
+ <!-- Snapshot the change being tested to reduce rerunning tests on submit -->
+    <exec output="${lib}/runtests.success.patch"
+        executable="svn"
+        failonerror="false"
+        failifexecutionfails="false"
+        dir=".">
+      <arg value="diff"/>
+    </exec>
+  </target>
+
   <target name="runbrowserstub" depends="AllTests">
     <java failonerror="false" fork="true"
      classname="com.google.caja.plugin.BrowserTestCaseStub">
=======================================
--- /trunk/tools/myvn   Mon Dec 14 16:32:10 2009
+++ /trunk/tools/myvn   Fri Oct  8 14:27:42 2010
@@ -276,8 +276,16 @@
 }

 function runAntTests() {
-  echo Running tests before submission
-  ant runtests
+  local current_diff="ant-lib/runtests.current.patch"
+  local success_diff="ant-lib/runtests.success.patch"
+  rm -rf "$current_diff"
+  "$svn" diff > "$current_diff"
+  if diff "$current_diff" "$success_diff" >& /dev/null; then
+    echo No changes since the last successful test
+  else
+    echo Running tests before submission
+    ant runtests
+  fi
 }

 myvn "$@"

Reply via email to