Migrate devicelab tests and test runners to null safety. (#85999)

* Migrate devicelab tests and test runners to null safety.
This commit is contained in:
Darren Austin
2021-07-23 13:37:57 -07:00
committed by GitHub
parent 930e5c20c0
commit 8fcace1d6c
12 changed files with 55 additions and 80 deletions

View File

@@ -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_devicelab/framework/ab.dart';
import 'package:flutter_devicelab/framework/task_result.dart';

View File

@@ -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:collection/collection.dart' show ListEquality, MapEquality;
import 'package:flutter_devicelab/framework/devices.dart';
@@ -13,12 +11,11 @@ import 'common.dart';
void main() {
group('device', () {
Device device;
late Device device;
setUp(() {
FakeDevice.resetLog();
device = null;
device = FakeDevice();
device = FakeDevice(deviceId: 'fakeDeviceId');
});
tearDown(() {
@@ -131,9 +128,9 @@ void expectLog(List<CommandArgs> log) {
}
CommandArgs cmd({
String command,
List<String> arguments,
Map<String, String> environment,
required String command,
List<String>? arguments,
Map<String, String>? environment,
}) {
return CommandArgs(
command: command,
@@ -146,11 +143,11 @@ typedef ExitErrorFactory = dynamic Function();
@immutable
class CommandArgs {
const CommandArgs({ this.command, this.arguments, this.environment });
const CommandArgs({ required this.command, this.arguments, this.environment });
final String command;
final List<String> arguments;
final Map<String, String> environment;
final List<String>? arguments;
final Map<String, String>? environment;
@override
String toString() => 'CommandArgs(command: $command, arguments: $arguments, environment: $environment)';
@@ -177,7 +174,7 @@ class CommandArgs {
}
class FakeDevice extends AndroidDevice {
FakeDevice({String deviceId}) : super(deviceId: deviceId);
FakeDevice({required String deviceId}) : super(deviceId: deviceId);
static String output = '';
@@ -206,7 +203,7 @@ class FakeDevice extends AndroidDevice {
}
@override
Future<String> shellEval(String command, List<String> arguments, { Map<String, String> environment, bool silent = false }) async {
Future<String> shellEval(String command, List<String> arguments, { Map<String, String>? environment, bool silent = false }) async {
commandLog.add(CommandArgs(
command: command,
arguments: arguments,
@@ -216,7 +213,7 @@ class FakeDevice extends AndroidDevice {
}
@override
Future<void> shellExec(String command, List<String> arguments, { Map<String, String> environment, bool silent = false }) async {
Future<void> shellExec(String command, List<String> arguments, { Map<String, String>? environment, bool silent = false }) async {
commandLog.add(CommandArgs(
command: command,
arguments: arguments,

View File

@@ -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:convert';
import 'dart:io';
@@ -17,14 +15,14 @@ import 'package:http/testing.dart';
import 'common.dart';
void main() {
ProcessResult _processResult;
late ProcessResult _processResult;
ProcessResult runSyncStub(String executable, List<String> args,
{Map<String, String> environment,
bool includeParentEnvironment,
bool runInShell,
Encoding stderrEncoding,
Encoding stdoutEncoding,
String workingDirectory}) =>
{Map<String, String>? environment,
bool includeParentEnvironment = true,
bool runInShell = false,
Encoding? stderrEncoding,
Encoding? stdoutEncoding,
String? workingDirectory}) =>
_processResult;
// Expected test values.
@@ -33,9 +31,9 @@ void main() {
const String serviceAccountToken = 'test_token';
group('Cocoon', () {
Client mockClient;
Cocoon cocoon;
FileSystem fs;
late Client mockClient;
late Cocoon cocoon;
late FileSystem fs;
setUp(() {
fs = MemoryFileSystem();
@@ -183,7 +181,7 @@ void main() {
});
group('AuthenticatedCocoonClient', () {
FileSystem fs;
late FileSystem fs;
setUp(() {
fs = MemoryFileSystem();

View File

@@ -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_devicelab/framework/host_agent.dart';
@@ -12,7 +10,7 @@ import 'package:platform/platform.dart';
import 'common.dart';
void main() {
FileSystem fs;
late FileSystem fs;
setUp(() {
fs = MemoryFileSystem();
hostAgent.resetDumpDirectory();
@@ -31,8 +29,8 @@ void main() {
);
final HostAgent agent = HostAgent(platform: fakePlatform, fileSystem: fs);
expect(agent.dumpDirectory.existsSync(), isTrue);
expect(agent.dumpDirectory.path, environmentDir.path);
expect(agent.dumpDirectory!.existsSync(), isTrue);
expect(agent.dumpDirectory!.path, environmentDir.path);
});
test('not set by environment', () async {

View File

@@ -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';
import 'package:path/path.dart' as path;
@@ -31,7 +29,7 @@ void main() {
Future<void> expectScriptResult(
List<String> testNames,
int expectedExitCode,
{String deviceId}
{String? deviceId}
) async {
final ProcessResult result = await runScript(testNames, <String>[
if (deviceId != null) ...<String>['-d', deviceId],

View File

@@ -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_devicelab/framework/running_processes.dart';
import 'common.dart';

View File

@@ -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_devicelab/framework/task_result.dart';
import 'common.dart';

View File

@@ -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 'package:flutter_devicelab/framework/runner.dart';
@@ -24,7 +22,7 @@ void main() {
deviceId: 'FAKE_SUCCESS',
isolateParams: isolateParams,
);
expect(result.data['benchmark'], 'data');
expect(result.data!['benchmark'], 'data');
});
test('runs build only when build arg is given', () async {
@@ -44,7 +42,7 @@ void main() {
deviceId: 'FAKE_SUCCESS',
isolateParams: isolateParams,
);
expect(result.data['benchmark'], 'data');
expect(result.data!['benchmark'], 'data');
});
test('sets environment', () async {

View File

@@ -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_devicelab/framework/utils.dart';
import 'common.dart';