[CFE] Add leak test of incremental suite run to weekly bot

Change-Id: I4987073c5dbfcaac9648a9502c22f791931c7148
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202768
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/front_end/test/spell_checking_list_tests.txt b/pkg/front_end/test/spell_checking_list_tests.txt
index af80d91..58478ccb 100644
--- a/pkg/front_end/test/spell_checking_list_tests.txt
+++ b/pkg/front_end/test/spell_checking_list_tests.txt
@@ -830,6 +830,7 @@
 walt
 warmup
 week
+weekly
 wherever
 whiskers
 wins
diff --git a/pkg/front_end/test/vm_service_for_leak_detection.dart b/pkg/front_end/test/vm_service_for_leak_detection.dart
index 7907d23..4329036 100644
--- a/pkg/front_end/test/vm_service_for_leak_detection.dart
+++ b/pkg/front_end/test/vm_service_for_leak_detection.dart
@@ -52,6 +52,12 @@
       "--fast",
       "--experimental",
     ]);
+  } else if (args.length > 0 && args[0] == "--weekly") {
+    heapHelper.start([
+      "--enable-asserts",
+      Platform.script.resolve("incremental_suite.dart").toString(),
+      "-DaddDebugBreaks=true",
+    ]);
   } else {
     heapHelper.start([
       "--enable-asserts",
diff --git a/pkg/front_end/test/weekly_tester.dart b/pkg/front_end/test/weekly_tester.dart
index ba30452..51a670a 100644
--- a/pkg/front_end/test/weekly_tester.dart
+++ b/pkg/front_end/test/weekly_tester.dart
@@ -28,8 +28,13 @@
     } else {
       // The tools/bots/flutter/compile_flutter.sh script passes `--path`
       // --- we'll just pass everything along.
-      startedProcesses
-          .add(await run([leakTester.toString(), ...args], "leak test"));
+      startedProcesses.add(await run(
+        [
+          leakTester.toString(),
+          ...args,
+        ],
+        "leak test",
+      ));
     }
   }
   {
@@ -55,8 +60,13 @@
         // The tools/bots/flutter/compile_flutter.sh script passes `--path`
         // --- we'll just pass everything along.
         startedProcesses.add(await run(
-            [leakTester.toString(), ...args, "--alternativeInvalidation"],
-            "leak test alternative invalidation"));
+          [
+            leakTester.toString(),
+            ...args,
+            "--alternativeInvalidation",
+          ],
+          "leak test alternative invalidation",
+        ));
       }();
     }
   }
@@ -68,8 +78,13 @@
       exitCode = 1;
       print("Couldn't find $weakSuite");
     } else {
-      startedProcesses.add(
-          await run([weakSuite.toString(), "-DsemiFuzz=true"], "weak suite"));
+      startedProcesses.add(await run(
+        [
+          weakSuite.toString(),
+          "-DsemiFuzz=true",
+        ],
+        "weak suite",
+      ));
     }
   }
 
@@ -81,7 +96,27 @@
       print("Couldn't find $strongSuite");
     } else {
       startedProcesses.add(await run(
-          [strongSuite.toString(), "-DsemiFuzz=true"], "strong suite"));
+        [
+          strongSuite.toString(),
+          "-DsemiFuzz=true",
+        ],
+        "strong suite",
+      ));
+    }
+  }
+
+  {
+    // Leak tests of incremental suite tests.
+    Uri incrementalLeakTest =
+        Platform.script.resolve("vm_service_for_leak_detection.dart");
+    if (!new File.fromUri(incrementalLeakTest).existsSync()) {
+      exitCode = 1;
+      print("Couldn't find $incrementalLeakTest");
+    } else {
+      startedProcesses.add(await run([
+        incrementalLeakTest.toString(),
+        "--weekly",
+      ], "incremental leak test"));
     }
   }
 
@@ -103,6 +138,7 @@
 List<String> observatoryLines = [];
 
 Future<WrappedProcess> run(List<String> args, String id) async {
+  Stopwatch stopwatch = new Stopwatch()..start();
   Process process = await Process.start(
       Platform.resolvedExecutable, ["--enable-asserts", ...args]);
   process.stderr
@@ -123,6 +159,11 @@
       observatoryLines.add(line);
     }
   });
+  // ignore: unawaited_futures
+  process.exitCode.then((int exitCode) {
+    stopwatch.stop();
+    print("$id finished in ${stopwatch.elapsed.toString()}");
+  });
   return new WrappedProcess(process, id);
 }