TestProcess constructor

  1. @protected
  1. Process process,
  2. String description,
  3. {Encoding encoding,
  4. bool forwardStdio: false}

Creates a TestProcess for process.

The description, encoding, and forwardStdio are the same as those to start.

This is protected, which means it should only be called by subclasses.


TestProcess(Process process, this.description,
    {Encoding encoding, bool forwardStdio = false})
    : _process = process,
      _stdoutSplitter = StreamSplitter(process.stdout
          .transform(const LineSplitter())),
      _stderrSplitter = StreamSplitter(process.stderr
          .transform(const LineSplitter())) {
  expect(_process.exitCode.then((_) => _logOutput()), completes,
      reason: 'Process `$description` never exited.');

  _stdout = StreamQueue(stdoutStream());
  _stderr = StreamQueue(stderrStream());

  // Listen eagerly so that the lines are interleaved properly between the two
  // streams.
  // Call [split] explicitly because we don't want to log overridden
  // [stdoutStream] or [stderrStream] output.
  _stdoutSplitter.split().listen((line) {
    if (forwardStdio) print(line);
    _log.add('    $line');

  _stderrSplitter.split().listen((line) {
    if (forwardStdio) print(line);
    _log.add('[e] $line');