test: Skip desugar with DESUGAR=false when running tests

Allow one to skip desugar when running the tests, for example:

   $> ANDROID_COMPILE_WITH_JACK=false DESUGAR=false DX=<your-dx-tool> art/test.py

Why this might be useful: If building with javac and a dexer tool that
already processes invoke-dynamic lambdas, then desugar is redundant.

Bug: 36902714
Change-Id: I39aadca4985e2aafe4b4b24ff3dc9d7a364bbad7
diff --git a/test/etc/default-build b/test/etc/default-build
index 9e2a6e2..ba413ec 100755
--- a/test/etc/default-build
+++ b/test/etc/default-build
@@ -60,6 +60,11 @@
   HAS_SRC_DEX2OAT_UNRESOLVED=false
 fi
 
+# DESUGAR=false run-test... will disable desugar.
+if [[ "$DESUGAR" == false ]]; then
+  USE_DESUGAR=false
+fi
+
 # Allow overriding ZIP_COMPRESSION_METHOD with e.g. 'store'
 ZIP_COMPRESSION_METHOD="deflate"
 # Align every ZIP file made by calling $ZIPALIGN command?
@@ -207,7 +212,7 @@
     desugar_args="$desugar_args --show-commands"
   fi
 
-  "${ANDROID_BUILD_TOP}/art/tools/desugar.sh" --core-only $desugar_args "$@"
+  "$DESUGAR" --core-only $desugar_args "$@"
 }
 
 # Make a "dex" file given a directory of classes in $1.
diff --git a/test/run-test b/test/run-test
index ba1f992..1b6df16 100755
--- a/test/run-test
+++ b/test/run-test
@@ -91,6 +91,11 @@
 
 export JACK="$JACK -g -cp $JACK_CLASSPATH"
 
+# Allow changing DESUGAR script to something else, or to disable it with DESUGAR=false.
+if [ -z "$DESUGAR"]; then
+  export DESUGAR="$ANDROID_BUILD_TOP/art/tools/desugar.sh"
+fi
+
 # Zipalign is not on the PATH in some configs, auto-detect it.
 if [ -z "$ZIPALIGN" ]; then
   if which zipalign >/dev/null; then