Migrate dev/bots to null safety (#86522)
This commit is contained in:
committed by
GitHub
parent
2f3bf078c5
commit
045ba2b661
@@ -19,12 +19,12 @@ import 'utils.dart';
|
||||
/// code fails the test immediately by exiting the test process with exit code
|
||||
/// 1.
|
||||
Stream<String> runAndGetStdout(String executable, List<String> arguments, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
String? workingDirectory,
|
||||
Map<String, String>? environment,
|
||||
bool expectNonZeroExit = false,
|
||||
}) async* {
|
||||
final StreamController<String> output = StreamController<String>();
|
||||
final Future<CommandResult> command = runCommand(
|
||||
final Future<CommandResult?> command = runCommand(
|
||||
executable,
|
||||
arguments,
|
||||
workingDirectory: workingDirectory,
|
||||
@@ -52,8 +52,8 @@ class Command {
|
||||
final io.Process process;
|
||||
|
||||
final Stopwatch _time;
|
||||
final Future<List<List<int>>> _savedStdout;
|
||||
final Future<List<List<int>>> _savedStderr;
|
||||
final Future<List<List<int>>>? _savedStdout;
|
||||
final Future<List<List<int>>>? _savedStderr;
|
||||
|
||||
/// Evaluates when the [process] exits.
|
||||
///
|
||||
@@ -63,8 +63,8 @@ class Command {
|
||||
_time.stop();
|
||||
|
||||
// Saved output is null when OutputMode.print is used.
|
||||
final String flattenedStdout = _savedStdout != null ? _flattenToString(await _savedStdout) : null;
|
||||
final String flattenedStderr = _savedStderr != null ? _flattenToString(await _savedStderr) : null;
|
||||
final String? flattenedStdout = _savedStdout != null ? _flattenToString((await _savedStdout)!) : null;
|
||||
final String? flattenedStderr = _savedStderr != null ? _flattenToString((await _savedStderr)!) : null;
|
||||
return CommandResult._(exitCode, _time.elapsed, flattenedStdout, flattenedStderr);
|
||||
}
|
||||
}
|
||||
@@ -80,10 +80,10 @@ class CommandResult {
|
||||
final Duration elapsedTime;
|
||||
|
||||
/// Standard output decoded as a string using UTF8 decoder.
|
||||
final String flattenedStdout;
|
||||
final String? flattenedStdout;
|
||||
|
||||
/// Standard error output decoded as a string using UTF8 decoder.
|
||||
final String flattenedStderr;
|
||||
final String? flattenedStderr;
|
||||
}
|
||||
|
||||
/// Starts the `executable` and returns a command object representing the
|
||||
@@ -97,11 +97,11 @@ class CommandResult {
|
||||
/// `outputMode` controls where the standard output from the command process
|
||||
/// goes. See [OutputMode].
|
||||
Future<Command> startCommand(String executable, List<String> arguments, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
String? workingDirectory,
|
||||
Map<String, String>? environment,
|
||||
OutputMode outputMode = OutputMode.print,
|
||||
bool Function(String) removeLine,
|
||||
void Function(String, io.Process) outputListener,
|
||||
bool Function(String)? removeLine,
|
||||
void Function(String, io.Process)? outputListener,
|
||||
}) async {
|
||||
final String commandDescription = '${path.relative(executable, from: workingDirectory)} ${arguments.join(' ')}';
|
||||
final String relativeWorkingDir = path.relative(workingDirectory ?? io.Directory.current.path);
|
||||
@@ -113,7 +113,7 @@ Future<Command> startCommand(String executable, List<String> arguments, {
|
||||
environment: environment,
|
||||
);
|
||||
|
||||
Future<List<List<int>>> savedStdout, savedStderr;
|
||||
Future<List<List<int>>>? savedStdout, savedStderr;
|
||||
final Stream<List<int>> stdoutSource = process.stdout
|
||||
.transform<String>(const Utf8Decoder())
|
||||
.transform(const LineSplitter())
|
||||
@@ -150,27 +150,22 @@ Future<Command> startCommand(String executable, List<String> arguments, {
|
||||
/// an indefinitely running process, for example, by waiting until the process
|
||||
/// emits certain output.
|
||||
///
|
||||
/// Returns the result of the finished process, or null if `skip` is true.
|
||||
/// Returns the result of the finished process.
|
||||
///
|
||||
/// `outputMode` controls where the standard output from the command process
|
||||
/// goes. See [OutputMode].
|
||||
Future<CommandResult> runCommand(String executable, List<String> arguments, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
String? workingDirectory,
|
||||
Map<String, String>? environment,
|
||||
bool expectNonZeroExit = false,
|
||||
int expectedExitCode,
|
||||
String failureMessage,
|
||||
int? expectedExitCode,
|
||||
String? failureMessage,
|
||||
OutputMode outputMode = OutputMode.print,
|
||||
bool skip = false,
|
||||
bool Function(String) removeLine,
|
||||
void Function(String, io.Process) outputListener,
|
||||
bool Function(String)? removeLine,
|
||||
void Function(String, io.Process)? outputListener,
|
||||
}) async {
|
||||
final String commandDescription = '${path.relative(executable, from: workingDirectory)} ${arguments.join(' ')}';
|
||||
final String relativeWorkingDir = path.relative(workingDirectory ?? io.Directory.current.path);
|
||||
if (skip) {
|
||||
printProgress('SKIPPING', relativeWorkingDir, commandDescription);
|
||||
return null;
|
||||
}
|
||||
|
||||
final Command command = await startCommand(executable, arguments,
|
||||
workingDirectory: workingDirectory,
|
||||
|
||||
Reference in New Issue
Block a user