[Fixit] Warn for Batch Annotations on not instumentation tests

Batch annotations don't do anything for non-instrumentation tests.
Add a warning to remove them if added unnecessarily.

Example where this was caught manually:
https://chromium-review.googlesource.com/c/chromium/src/+/3704237

It is easy enough to extend the existing CheckBatchAnnotation
PRESUBMIT to handle this.

Bug: 1337314
Change-Id: I4861f3825329f6313b2f06b9a101ee5c4e26c031
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3708730
Reviewed-by: Andrew Grieve <[email protected]>
Reviewed-by: Michael Thiessen <[email protected]>
Commit-Queue: Calder Kitagawa <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1015361}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 36e66f0..99c0f518 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -6026,7 +6026,8 @@
     test_class_declaration = input_api.re.compile(r'^\s*public\sclass.*Test')
     uiautomator_test = input_api.re.compile(r'[uU]i[aA]utomator')
 
-    errors = []
+    missing_annotation_errors = []
+    extra_annotation_errors = []
 
     def _FilterFile(affected_file):
         return input_api.FilterSourceFile(
@@ -6054,16 +6055,26 @@
         if (is_instrumentation_test and
             not batch_matched and
             not do_not_batch_matched):
-          errors.append(str(f.LocalPath()))
+          missing_annotation_errors.append(str(f.LocalPath()))
+        if (not is_instrumentation_test and
+            (batch_matched or
+             do_not_batch_matched)):
+          extra_annotation_errors.append(str(f.LocalPath()))
 
     results = []
 
-    if errors:
+    if missing_annotation_errors:
         results.append(
             output_api.PresubmitPromptWarning(
                 """
 Instrumentation tests should use either @Batch or @DoNotBatch. If tests are not
 safe to run in batch, please use @DoNotBatch with reasons.
-""", errors))
+""", missing_annotation_errors))
+    if extra_annotation_errors:
+        results.append(
+            output_api.PresubmitPromptWarning(
+                """
+Robolectric tests do not need a @Batch or @DoNotBatch annotations.
+""", extra_annotation_errors))
 
     return results