Unverified Commit d550d497 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate some flutter_tools tests to null safety (#88850)

parent 59f3f23a
......@@ -187,7 +187,7 @@ Future<Map<String, String>?> getCodeSigningIdentityDevelopmentTeam({
final String opensslOutput = await utf8.decodeStream(opensslProcess.stdout);
// Fire and forget discard of the stderr stream so we don't hold onto resources.
// Don't care about the result.
unawaited(opensslProcess.stderr.drain<String>());
unawaited(opensslProcess.stderr.drain<String?>());
if (await opensslProcess.exitCode != 0) {
return null;
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:io' as io; // flutter_ignore: dart_io_import;
import 'package:file/file.dart';
......@@ -103,7 +101,7 @@ void main() {
const int kUserPermissionDenied = 5;
const int kFatalDeviceHardwareError = 483;
FileExceptionHandler exceptionHandler;
late FileExceptionHandler exceptionHandler;
setUp(() {
exceptionHandler = FileExceptionHandler();
......@@ -340,7 +338,7 @@ void main() {
testWithoutContext('When reading from a file or directory without permission', () {
final ErrorHandlingFileSystem fileSystem = ErrorHandlingFileSystem(
delegate: ThrowsOnCurrentDirectoryFileSystem()..errorCode = kUserPermissionDenied,
delegate: ThrowsOnCurrentDirectoryFileSystem(kUserPermissionDenied),
platform: windowsPlatform,
);
......@@ -354,7 +352,7 @@ void main() {
const int enospc = 28;
const int eacces = 13;
FileExceptionHandler exceptionHandler;
late FileExceptionHandler exceptionHandler;
setUp(() {
exceptionHandler = FileExceptionHandler();
......@@ -531,7 +529,7 @@ void main() {
testWithoutContext('When the current working directory disappears', () async {
final ErrorHandlingFileSystem fileSystem = ErrorHandlingFileSystem(
delegate: ThrowsOnCurrentDirectoryFileSystem()..errorCode = kSystemCannotFindFile,
delegate: ThrowsOnCurrentDirectoryFileSystem(kSystemCannotFindFile),
platform: linuxPlatform,
);
......@@ -560,7 +558,7 @@ void main() {
const int eperm = 1;
const int enospc = 28;
const int eacces = 13;
FileExceptionHandler exceptionHandler;
late FileExceptionHandler exceptionHandler;
setUp(() {
exceptionHandler = FileExceptionHandler();
......@@ -754,7 +752,7 @@ void main() {
testWithoutContext('When reading from current directory without permission', () {
final ErrorHandlingFileSystem fileSystem = ErrorHandlingFileSystem(
delegate: ThrowsOnCurrentDirectoryFileSystem()..errorCode = eacces,
delegate: ThrowsOnCurrentDirectoryFileSystem(eacces),
platform: linuxPlatform,
);
......@@ -781,11 +779,9 @@ void main() {
);
final Object firstPath = fs.path;
expect(firstPath, isNotNull);
fs.currentDirectory = null;
// For fs.path.absolute usage.
fileSystem.path = MemoryFileSystem.test().path;
expect(identical(firstPath, fs.path), false);
});
......@@ -1089,8 +1085,8 @@ void main() {
group('CopySync' , () {
const int eaccess = 13;
FileExceptionHandler exceptionHandler;
ErrorHandlingFileSystem fileSystem;
late FileExceptionHandler exceptionHandler;
late ErrorHandlingFileSystem fileSystem;
setUp(() {
exceptionHandler = FileExceptionHandler();
......@@ -1191,20 +1187,22 @@ class ThrowingFakeProcessManager extends Fake implements ProcessManager {
final Exception _exception;
@override
bool canRun(dynamic executable, {String workingDirectory}) {
bool canRun(dynamic executable, {String? workingDirectory}) {
throw _exception;
}
}
class ThrowsOnCurrentDirectoryFileSystem extends Fake implements FileSystem {
int errorCode;
ThrowsOnCurrentDirectoryFileSystem(this.errorCode);
final int errorCode;
@override
Directory get currentDirectory => throw FileSystemException('', '', OSError('', errorCode));
}
class FakeExistsFile extends Fake implements File {
Object error;
late Object error;
int existsCount = 0;
......@@ -1225,10 +1223,7 @@ class FakeExistsFile extends Fake implements File {
class FakeFileSystem extends Fake implements FileSystem {
@override
p.Context path;
@override
Directory get currentDirectory => null;
p.Context get path => p.Context();
@override
set currentDirectory(dynamic path) { }
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
......@@ -16,8 +14,8 @@ import '../../src/fakes.dart';
void main() {
group('process exceptions', () {
FakeProcessManager fakeProcessManager;
ProcessUtils processUtils;
late FakeProcessManager fakeProcessManager;
late ProcessUtils processUtils;
setUp(() {
fakeProcessManager = FakeProcessManager.empty();
......@@ -42,7 +40,7 @@ void main() {
group('shutdownHooks', () {
testWithoutContext('runInExpectedOrder', () async {
int i = 1;
int cleanup;
int? cleanup;
final ShutdownHooks shutdownHooks = ShutdownHooks(logger: BufferLogger.test());
......@@ -57,9 +55,9 @@ void main() {
});
group('output formatting', () {
FakeProcessManager processManager;
ProcessUtils processUtils;
BufferLogger logger;
late FakeProcessManager processManager;
late ProcessUtils processUtils;
late BufferLogger logger;
setUp(() {
processManager = FakeProcessManager.empty();
......@@ -104,8 +102,8 @@ void main() {
});
group('run', () {
FakeProcessManager fakeProcessManager;
ProcessUtils processUtils;
late FakeProcessManager fakeProcessManager;
late ProcessUtils processUtils;
setUp(() {
fakeProcessManager = FakeProcessManager.empty();
......@@ -180,9 +178,9 @@ void main() {
});
group('runSync', () {
FakeProcessManager fakeProcessManager;
ProcessUtils processUtils;
BufferLogger testLogger;
late FakeProcessManager fakeProcessManager;
late ProcessUtils processUtils;
late BufferLogger testLogger;
setUp(() {
fakeProcessManager = FakeProcessManager.empty();
......@@ -331,8 +329,8 @@ void main() {
});
group('exitsHappySync', () {
FakeProcessManager processManager;
ProcessUtils processUtils;
late FakeProcessManager processManager;
late ProcessUtils processUtils;
setUp(() {
processManager = FakeProcessManager.empty();
......@@ -388,8 +386,8 @@ void main() {
});
group('exitsHappy', () {
FakeProcessManager processManager;
ProcessUtils processUtils;
late FakeProcessManager processManager;
late ProcessUtils processUtils;
setUp(() {
processManager = FakeProcessManager.empty();
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_tools/src/build_system/build_system.dart';
import '../../src/common.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:file/memory.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
import 'dart:convert';
......@@ -25,9 +23,9 @@ const String kCertificates = '''
void main() {
group('Auto signing', () {
Config testConfig;
AnsiTerminal testTerminal;
BufferLogger logger;
late Config testConfig;
late AnsiTerminal testTerminal;
late BufferLogger logger;
setUp(() async {
logger = BufferLogger.test();
......@@ -37,7 +35,7 @@ void main() {
});
testWithoutContext('No auto-sign if Xcode project settings are not available', () async {
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
final Map<String, String>? signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
buildSettings: null,
processManager: FakeProcessManager.empty(),
logger: logger,
......@@ -48,7 +46,7 @@ void main() {
});
testWithoutContext('No discovery if development team specified in Xcode project', () async {
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
final Map<String, String>? signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
buildSettings: <String, String>{
'DEVELOPMENT_TEAM': 'abc',
},
......@@ -71,7 +69,7 @@ void main() {
),
]);
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
final Map<String, String>? signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
buildSettings: <String, String>{
'bogus': 'bogus',
},
......@@ -135,13 +133,13 @@ void main() {
]);
// Verify that certifacte value is passed into openssl command.
String stdin;
String? stdin;
controller.stream.listen((List<int> chunk) {
stdin = utf8.decode(chunk);
completer.complete();
});
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
final Map<String, String>? signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
buildSettings: <String, String>{
'bogus': 'bogus',
},
......@@ -187,13 +185,13 @@ void main() {
]);
// Verify that certifacte value is passed into openssl command.
String stdin;
String? stdin;
controller.stream.listen((List<int> chunk) {
stdin = utf8.decode(chunk);
completer.complete();
});
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
final Map<String, String>? signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
buildSettings: <String, String>{
'bogus': 'bogus',
},
......@@ -237,13 +235,13 @@ void main() {
]);
// Verify that certifacte value is passed into openssl command.
String stdin;
String? stdin;
controller.stream.listen((List<int> chunk) {
stdin = utf8.decode(chunk);
completer.complete();
});
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
final Map<String, String>? signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
buildSettings: <String, String>{
'bogus': 'bogus',
},
......@@ -295,13 +293,13 @@ void main() {
]);
// Verify that certifacte value is passed into openssl command.
String stdin;
String? stdin;
controller.stream.listen((List<int> chunk) {
stdin = utf8.decode(chunk);
completer.complete();
});
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
final Map<String, String>? signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
buildSettings: <String, String>{
'bogus': 'bogus',
},
......@@ -348,13 +346,13 @@ void main() {
]);
// Verify that certifacte value is passed into openssl command.
String stdin;
String? stdin;
controller.stream.listen((List<int> chunk) {
stdin = utf8.decode(chunk);
completer.complete();
});
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
final Map<String, String>? signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
buildSettings: <String, String>{
'bogus': 'bogus',
},
......@@ -406,13 +404,13 @@ void main() {
]);
// Verify that certifacte value is passed into openssl command.
String stdin;
String? stdin;
controller.stream.listen((List<int> chunk) {
stdin = utf8.decode(chunk);
completer.complete();
});
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
final Map<String, String>? signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
buildSettings: <String, String>{
'bogus': 'bogus',
},
......@@ -449,7 +447,7 @@ void main() {
),
]);
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
final Map<String, String>? signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
buildSettings: <String, String>{
'bogus': 'bogus',
},
......@@ -481,7 +479,7 @@ void main() {
),
]);
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
final Map<String, String>? signingConfigs = await getCodeSigningIdentityDevelopmentTeam(
buildSettings: <String, String>{
'bogus': 'bogus',
},
......@@ -495,7 +493,7 @@ void main() {
});
}
Stream<String> mockTerminalStdInStream;
late Stream<String> mockTerminalStdInStream;
class TestTerminal extends AnsiTerminal {
TestTerminal() : super(stdio: globals.stdio, platform: globals.platform);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/macos/macos_workflow.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/project.dart';
......
......@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/custom_devices/custom_device_config.dart';
void writeCustomDevicesConfigFile(
Directory dir, {
List<CustomDeviceConfig> configs,
List<CustomDeviceConfig>? configs,
dynamic json
}) {
dir.createSync(recursive: true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment