watcher.dart 1.53 KB
Newer Older
1 2 3 4 5 6 7 8
// 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.
9
abstract class TestWatcher {
10 11 12 13
  /// Called after a child process starts.
  ///
  /// If startPaused was true, the caller needs to resume in Observatory to
  /// start running the tests.
14
  void handleStartedProcess(ProcessEvent event) { }
15 16 17 18 19

  /// 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.
20
  Future<void> handleFinishedTest(ProcessEvent event) async { }
21 22

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

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

/// Describes a child process started during testing.
class ProcessEvent {
32
  ProcessEvent(this.childIndex, this.process, [this.observatoryUri]);
33 34 35 36 37 38 39 40 41 42

  /// 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;

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