Only call clean commands when archiving internal tests

Change-Id: I0c8bb67fd33f65edb8b42cccb8e4e0a389627d0c
diff --git a/tools/internal_test.py b/tools/internal_test.py
index 2ca50f3..b1396d0 100755
--- a/tools/internal_test.py
+++ b/tools/internal_test.py
@@ -109,10 +109,13 @@
       '--max-memory=%s' % int(record['oom-threshold'] * 0.85)
   ]
 
-# TODO(b/210982978): Enable testing of min xmx again
-TEST_COMMANDS = [
+CLEAN_COMMANDS = [
     # Make sure we have a clean build to not be polluted by old test files
     ['tools/gradle.py', 'clean', '--new-gradle'],
+]
+
+# TODO(b/210982978): Enable testing of min xmx again
+TEST_COMMANDS = [
     # Run test.py internal testing.
     ['tools/test.py', '--only_internal', '--slow_tests',
      '--java_max_memory_size=8G'],
@@ -354,12 +357,13 @@
     return exitcode
 
 def run_once(archive):
-  failed = False
   git_hash = utils.get_HEAD_sha1()
   log('Running once with hash %s' % git_hash)
   env = os.environ.copy()
   # Bot does not have a lot of memory.
   env['R8_GRADLE_CORES_PER_FORK'] = '5'
+  if archive:
+    [execute(cmd, archive, env) for cmd in CLEAN_COMMANDS]
   failed = any([execute(cmd, archive, env) for cmd in TEST_COMMANDS])
   # Gradle daemon occasionally leaks memory, stop it.
   gradle.RunGradle(['--stop'], new_gradle=True)