anchor.diff:    }
   }
   
  +bool shouldRetryCommand(CommandOutput output) {
  +  var command = output.command;
  +
  +  if (!output.successful) {
  +    List<String> stdout, stderr;
  +
  +    decodeOutput() {
  +      if (stdout == null && stderr == null) {
  +        stdout = decodeUtf8(output.stderr).split("\n");
  +        stderr = decodeUtf8(output.stderr).split("\n");
  +      }
  +    }
  +
  +    if (io.Platform.operatingSystem == 'linux') {
  +      decodeOutput();
  +      // No matter which command we ran: If we get failures due to the
  +      // "xvfb-run" issue 7564, try re-running the test.
  +      bool containsFailureMsg(String line) {
  +        return line.contains(MESSAGE_CANNOT_OPEN_DISPLAY) ||
  +               line.contains(MESSAGE_FAILED_TO_RUN_COMMAND);
  +      }
  +      if (stdout.any(containsFailureMsg) || stderr.any(containsFailureMsg)) {
  +        return true;
  +      }
  +    }
  +
  +    if (command is BrowserTestCommand) {
  +      // We do not re-run tests on the new browser controller, since it should
  +      // not be as flaky as selenium.
  +      return false;
  +    } else if (command is SeleniumTestCommand) {
  +      // Selenium tests can be flaky. Try re-running.
  +      return true;
  +    } else if (command is ContentShellCommand) {
  +      // FIXME(kustermann): Remove this condition once we figured out why
  +      // content_shell is sometimes not able to fetch resources from the
  +      // HttpServer on windows.
  +      // TODO(kustermann): Don't blindly re-run DRT tests on windows but rather
  +      // check if the stderr/stdout indicates that we actually have this issue.
  +      return io.Platform.operatingSystem == 'windows';
  +    }
  +  }
  +  return false;
  +}
   
   /*
    * [TestCaseCompleter] will listen for
  
positive.code:         expectedOutputPath.toString() == other.expectedOutputPath.toString();
    }
  
    // FIXME(kustermann): Remove this once we're stable
    int get numRetries => 2;
  }
  
  class BrowserTestCommand extends Command {
  
negative.code: 
      Future<CommandOutput> runCommand(int retriesLeft) {
        return _runCommand(command, timeout).then((CommandOutput output) {
          if (retriesLeft > 0 && shouldRetryCommand(output)) {
            DebugLogger.warning("Rerunning Command: ($retriesLeft "
                                "attempt(s) remains) [cmd: $command]");
            return runCommand(retriesLeft - 1);
  