Make some tweaks to how we detect generated files

I've seen occasional flakiness in our testing of this feature, but
couldn't pinpoint the reason for it. However, decreasing the frequency
how often we check for changes of the `command.log` and looking at a
larger chunk of the file seems to help (based on running th tests
multiple times).


Bug: http://b/184120864
Change-Id: Ie28a6e5aa71e7d86e0afc47906051ee1c05ed44c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194786
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Michal Terepeta <michalt@google.com>
diff --git a/pkg/analyzer/lib/src/workspace/bazel_watcher.dart b/pkg/analyzer/lib/src/workspace/bazel_watcher.dart
index 1109c63..81d20db 100644
--- a/pkg/analyzer/lib/src/workspace/bazel_watcher.dart
+++ b/pkg/analyzer/lib/src/workspace/bazel_watcher.dart
@@ -433,7 +433,10 @@
 /// target of a symlink.
 class _BazelInvocationWatcher implements PollTrigger {
   /// Determines how often do we check for `command.log` changes.
-  static const _pollInterval = Duration(seconds: 1);
+  ///
+  /// Note that on some systems the granularity is about 1s, so let's set this
+  /// to some greater value just to be safe we don't miss any updates.
+  static const _pollInterval = Duration(seconds: 2);
 
   /// To confirm that a build finished, we check for these messages in the
   /// `command.log`.
@@ -461,8 +464,8 @@
   void cancel() => _timer.cancel();
 
   bool _buildFinished(String contents) {
-    // Only look at the last 100 characters.
-    var offset = max(0, contents.length - 100);
+    // Only look at the last 1024 characters.
+    var offset = max(0, contents.length - 1024);
     return _buildCompletedMsgs.any((msg) => contents.contains(msg, offset));
   }