TestProcess class

A wrapper for Process that provides a convenient API for testing its standard IO and interacting with it from a test.

If the test fails, this will automatically print out any stdout and stderr from the process to aid debugging.

This may be extended to provide custom implementations of stdoutStream and stderrStream. These will automatically be picked up by the stdout and stderr queues, but the debug log will still contain the original output.

Constructors

TestProcess(Process process, String description, {Encoding encoding = utf8, bool forwardStdio = false})
Creates a TestProcess for process.

Properties

description String
A human-friendly description of this process.
final
exitCode Future<int>
Returns a Future which completes to the exit code of the process, once it completes.
no setter
hashCode int
The hash code for this object.
no setterinherited
pid int
The process ID of the process.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stderr → StreamQueue<String>
A StreamQueue that emits each line of stderr from the process.
latefinal
stdin IOSink
The standard input sink for this process.
no setter
stdout → StreamQueue<String>
A StreamQueue that emits each line of stdout from the process.
latefinal

Methods

kill() Future<void>
Kills the process (with SIGKILL on POSIX operating systems), and returns a future that completes once it's dead.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldExit([Object? expectedExitCode]) Future<void>
Waits for the process to exit, and verifies that the exit code matches expectedExitCode (if given).
signal(ProcessSignal signal) → void
Sends signal to the process.
stderrStream() Stream<String>
Returns a copy of stderr as a single-subscriber stream.
stdoutStream() Stream<String>
Returns a copy of stdout as a single-subscriber stream.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

start(String executable, Iterable<String> arguments, {String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool runInShell = false, String? description, Encoding encoding = utf8, bool forwardStdio = false}) Future<TestProcess>
Starts a process.