Migrate dev/bots to null safety (#86522)

This commit is contained in:
Michael Goderbauer
2021-07-19 13:59:15 -07:00
committed by GitHub
parent 2f3bf078c5
commit 045ba2b661
12 changed files with 216 additions and 238 deletions

View File

@@ -74,16 +74,16 @@ void main() {
});
});
group('ArchiveCreator for $platformName', () {
ArchiveCreator creator;
Directory tempDir;
late ArchiveCreator creator;
late Directory tempDir;
Directory flutterDir;
Directory cacheDir;
FakeProcessManager processManager;
late FakeProcessManager processManager;
final List<List<String>> args = <List<String>>[];
final List<Map<Symbol, dynamic>> namedArgs = <Map<Symbol, dynamic>>[];
String flutter;
late String flutter;
Future<Uint8List> fakeHttpReader(Uri url, {Map<String, String> headers}) {
Future<Uint8List> fakeHttpReader(Uri url, {Map<String, String>? headers}) {
return Future<Uint8List>.value(Uint8List(0));
}
@@ -118,7 +118,7 @@ void main() {
final String archiveName = path.join(tempDir.absolute.path,
'flutter_${platformName}_v1.2.3-dev${platform.isLinux ? '.tar.xz' : '.zip'}');
processManager.addCommands(convertResults(<String, List<ProcessResult>>{
processManager.addCommands(convertResults(<String, List<ProcessResult>?>{
'git clone -b dev https://chromium.googlesource.com/external/github.com/flutter/flutter': null,
'git reset --hard $testRef': null,
'git remote set-url origin https://github.com/flutter/flutter.git': null,
@@ -147,7 +147,7 @@ void main() {
final String createBase = path.join(tempDir.absolute.path, 'create_');
final String archiveName = path.join(tempDir.absolute.path,
'flutter_${platformName}_v1.2.3-dev${platform.isLinux ? '.tar.xz' : '.zip'}');
final Map<String, List<ProcessResult>> calls = <String, List<ProcessResult>>{
final Map<String, List<ProcessResult>?> calls = <String, List<ProcessResult>?>{
'git clone -b dev https://chromium.googlesource.com/external/github.com/flutter/flutter': null,
'git reset --hard $testRef': null,
'git remote set-url origin https://github.com/flutter/flutter.git': null,
@@ -197,7 +197,7 @@ void main() {
final String createBase = path.join(tempDir.absolute.path, 'create_');
final String archiveName = path.join(tempDir.absolute.path,
'flutter_${platformName}_v1.2.3-dev${platform.isLinux ? '.tar.xz' : '.zip'}');
final Map<String, List<ProcessResult>> calls = <String, List<ProcessResult>>{
final Map<String, List<ProcessResult>?> calls = <String, List<ProcessResult>?>{
'git clone -b dev https://chromium.googlesource.com/external/github.com/flutter/flutter': null,
'git reset --hard $testRef': null,
'git remote set-url origin https://github.com/flutter/flutter.git': null,
@@ -239,7 +239,7 @@ void main() {
'flutter_${platformName}_v1.2.3-dev${platform.isLinux ? '.tar.xz' : '.zip'}');
final ProcessResult codesignFailure = ProcessResult(1, 1, '', 'code object is not signed at all');
final String binPath = path.join(tempDir.path, 'flutter', 'bin', 'cache', 'dart-sdk', 'bin', 'dart');
final Map<String, List<ProcessResult>> calls = <String, List<ProcessResult>>{
final Map<String, List<ProcessResult>?> calls = <String, List<ProcessResult>?>{
'git clone -b dev https://chromium.googlesource.com/external/github.com/flutter/flutter': null,
'git reset --hard $testRef': null,
'git remote set-url origin https://github.com/flutter/flutter.git': null,
@@ -286,8 +286,8 @@ void main() {
});
group('ArchivePublisher for $platformName', () {
FakeProcessManager processManager;
Directory tempDir;
late FakeProcessManager processManager;
late Directory tempDir;
final String gsutilCall = platform.isWindows
? 'python ${path.join("D:", "depot_tools", "gsutil.py")}'
: 'gsutil.py';
@@ -346,7 +346,7 @@ void main() {
''';
File(jsonPath).writeAsStringSync(releasesJson);
File(archivePath).writeAsStringSync('archive contents');
final Map<String, List<ProcessResult>> calls = <String, List<ProcessResult>>{
final Map<String, List<ProcessResult>?> calls = <String, List<ProcessResult>?>{
// This process fails because the file does NOT already exist
'$gsutilCall -- stat $gsArchivePath': <ProcessResult>[ProcessResult(0, 1, '', '')],
'$gsutilCall -- rm $gsArchivePath': null,
@@ -442,7 +442,7 @@ void main() {
''';
File(jsonPath).writeAsStringSync(releasesJson);
File(archivePath).writeAsStringSync('archive contents');
final Map<String, List<ProcessResult>> calls = <String, List<ProcessResult>>{
final Map<String, List<ProcessResult>?> calls = <String, List<ProcessResult>?>{
// This process fails because the file does NOT already exist
'$gsutilCall -- stat $gsArchivePath': <ProcessResult>[ProcessResult(0, 1, '', '')],
'$gsutilCall -- rm $gsArchivePath': null,
@@ -552,7 +552,7 @@ void main() {
''';
File(jsonPath).writeAsStringSync(releasesJson);
File(archivePath).writeAsStringSync('archive contents');
final Map<String, List<ProcessResult>> calls = <String, List<ProcessResult>>{
final Map<String, List<ProcessResult>?> calls = <String, List<ProcessResult>?>{
'$gsutilCall -- rm $gsArchivePath': null,
'$gsutilCall -- -h Content-Type:$archiveMime cp $archivePath $gsArchivePath': null,
'$gsutilCall -- cp $gsJsonPath $jsonPath': null,
@@ -567,10 +567,10 @@ void main() {
}
}
List<FakeCommand> convertResults(Map<String, List<ProcessResult>> results) {
List<FakeCommand> convertResults(Map<String, List<ProcessResult>?> results) {
final List<FakeCommand> commands = <FakeCommand>[];
for (final String key in results.keys) {
final List<ProcessResult> candidates = results[key];
final List<ProcessResult>? candidates = results[key];
final List<String> args = key.split(' ');
if (candidates == null) {
commands.add(FakeCommand(
@@ -581,8 +581,8 @@ List<FakeCommand> convertResults(Map<String, List<ProcessResult>> results) {
commands.add(FakeCommand(
command: args,
exitCode: result.exitCode,
stderr: result.stderr?.toString(),
stdout: result.stdout?.toString(),
stderr: result.stderr.toString(),
stdout: result.stdout.toString(),
));
}
}

View File

@@ -12,10 +12,10 @@ void main() {
test('We are in a directory with a space in it', () async {
// The Flutter SDK should be in a directory with a space in it, to make sure
// our tools support that.
final String expectedName = Platform.environment['FLUTTER_SDK_PATH_WITH_SPACE'];
final String? expectedName = Platform.environment['FLUTTER_SDK_PATH_WITH_SPACE'];
expect(expectedName, 'flutter sdk');
expect(expectedName, contains(' '));
final List<String> parts = path.split(Directory.current.absolute.path);
expect(parts.reversed.take(3), <String>['bots', 'dev', expectedName]);
expect(parts.reversed.take(3), <String?>['bots', 'dev', expectedName]);
}, skip: true); // https://github.com/flutter/flutter/issues/62919
}

View File

@@ -23,7 +23,7 @@ void expectExitCode(ProcessResult result, int expectedExitCode) {
void main() {
group('verifyVersion()', () {
MemoryFileSystem fileSystem;
late MemoryFileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
@@ -97,7 +97,7 @@ void main() {
const ProcessManager processManager = LocalProcessManager();
Future<ProcessResult> runScript(
[Map<String, String> environment, List<String> otherArgs = const <String>[]]) async {
[Map<String, String>? environment, List<String> otherArgs = const <String>[]]) async {
final String dart = path.absolute(
path.join('..', '..', 'bin', 'cache', 'dart-sdk', 'bin', 'dart'));
final ProcessResult scriptProcess = processManager.runSync(<String>[