• Ian Hickson's avatar
    Try to resolve an intermitted crash during coverage collection (#20506) · d5812085
    Ian Hickson authored
    * Try to resolve an intermitted crash during coverage collection
    
    The only theory I can come up with is that maybe the test completes
    before we finish processing the standard input, so I made the test
    harness wait for the observatory URL before considering whether the
    test has finished or not.
    
    Also, some code cleanup while I'm at it, e.g. avoiding using "onFoo"
    for the names of methods, avoiding back-to-back switch statements with
    the same values, avoiding `_` argument names, and using `?.` instead
    of `if (foo != null) foo.`.
    
    * Revert back the signature of _pipeStandardStreamsToConsole
    
    * Also remove the other additions to this method.
    Unverified
    d5812085
watcher.dart 1.53 KB
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';
import '../base/io.dart' show Process;

/// Callbacks for reporting progress while running tests.
abstract class TestWatcher {
  /// Called after a child process starts.
  ///
  /// If startPaused was true, the caller needs to resume in Observatory to
  /// start running the tests.
  void handleStartedProcess(ProcessEvent event) {}

  /// Called after the tests finish but before the process exits.
  ///
  /// The child process won't exit until this method completes.
  /// Not called if the process died.
  Future<void> handleFinishedTest(ProcessEvent event) async {}

  /// Called when the test process crashed before connecting to test harness.
  Future<void> handleTestCrashed(ProcessEvent event) async {}

  /// Called if we timed out waiting for the test process to connect to test
  /// harness.
  Future<void> handleTestTimedOut(ProcessEvent event) async {}
}

/// Describes a child process started during testing.
class ProcessEvent {
  ProcessEvent(this.childIndex, this.process, [this.observatoryUri]);

  /// The index assigned when the child process was launched.
  ///
  /// Indexes are assigned consecutively starting from zero.
  /// When debugging, there should only be one child process so this will
  /// always be zero.
  final int childIndex;

  final Process process;

  /// The observatory URL or null if not debugging.
  final Uri observatoryUri;
}