Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -14,14 +14,10 @@ void main() {
|
||||
late List<Uri> uriConnections;
|
||||
|
||||
setUp(() {
|
||||
final List<Map<String, dynamic>> flutterViewCannedResponses =
|
||||
<Map<String, dynamic>>[
|
||||
final List<Map<String, dynamic>> flutterViewCannedResponses = <Map<String, dynamic>>[
|
||||
<String, dynamic>{
|
||||
'views': <Map<String, dynamic>>[
|
||||
<String, dynamic>{
|
||||
'type': 'FlutterView',
|
||||
'id': 'flutterView0',
|
||||
},
|
||||
<String, dynamic>{'type': 'FlutterView', 'id': 'flutterView0'},
|
||||
],
|
||||
},
|
||||
<String, dynamic>{
|
||||
@@ -59,10 +55,7 @@ void main() {
|
||||
forwardedPorts = <FakePortForwarder>[];
|
||||
fakeVmServices = <FakeVmService>[];
|
||||
uriConnections = <Uri>[];
|
||||
Future<vms.VmService> fakeVmConnectionFunction(
|
||||
Uri uri, {
|
||||
Duration? timeout,
|
||||
}) {
|
||||
Future<vms.VmService> fakeVmConnectionFunction(Uri uri, {Duration? timeout}) {
|
||||
return Future<vms.VmService>(() async {
|
||||
final FakeVmService service = FakeVmService();
|
||||
fakeVmServices.add(service);
|
||||
@@ -138,7 +131,7 @@ void main() {
|
||||
' },',
|
||||
' "version": 1',
|
||||
' }',
|
||||
' ]'
|
||||
' ]',
|
||||
];
|
||||
fakeRunner.address = 'fe80::8eae:4cff:fef4:9247';
|
||||
fakeRunner.interface = 'eno1';
|
||||
@@ -151,8 +144,7 @@ void main() {
|
||||
|
||||
// VMs should be accessed via localhost ports given by
|
||||
// [fakePortForwardingFunction].
|
||||
expect(uriConnections[0],
|
||||
Uri(scheme: 'ws', host: '[::1]', port: 0, path: '/ws'));
|
||||
expect(uriConnections[0], Uri(scheme: 'ws', host: '[::1]', port: 0, path: '/ws'));
|
||||
|
||||
final List<FlutterView> views = await connection.getFlutterViews();
|
||||
expect(views, isNot(null));
|
||||
@@ -224,7 +216,7 @@ void main() {
|
||||
' },',
|
||||
' "version": 1',
|
||||
' }',
|
||||
' ]'
|
||||
' ]',
|
||||
];
|
||||
fakeRunner.address = 'fe80::8eae:4cff:fef4:9247';
|
||||
fakeRunner.interface = 'eno1';
|
||||
@@ -236,8 +228,10 @@ void main() {
|
||||
|
||||
// VMs should be accessed via the alternate address given by
|
||||
// [fakePortForwardingFunction].
|
||||
expect(uriConnections[0],
|
||||
Uri(scheme: 'ws', host: '[fe80::1:2%25eno2]', port: 0, path: '/ws'));
|
||||
expect(
|
||||
uriConnections[0],
|
||||
Uri(scheme: 'ws', host: '[fe80::1:2%25eno2]', port: 0, path: '/ws'),
|
||||
);
|
||||
|
||||
final List<FlutterView> views = await connection.getFlutterViews();
|
||||
expect(views, isNot(null));
|
||||
@@ -308,7 +302,7 @@ void main() {
|
||||
' },',
|
||||
' "version": 1',
|
||||
' }',
|
||||
' ]'
|
||||
' ]',
|
||||
];
|
||||
fakeRunner.address = '196.168.1.4';
|
||||
|
||||
@@ -319,8 +313,7 @@ void main() {
|
||||
expect(forwardedPorts[0].remotePort, 12345);
|
||||
|
||||
// VMs should be accessed via the ipv4 loopback.
|
||||
expect(uriConnections[0],
|
||||
Uri(scheme: 'ws', host: '127.0.0.1', port: 0, path: '/ws'));
|
||||
expect(uriConnections[0], Uri(scheme: 'ws', host: '127.0.0.1', port: 0, path: '/ws'));
|
||||
|
||||
final List<FlutterView> views = await connection.getFlutterViews();
|
||||
expect(views, isNot(null));
|
||||
@@ -341,8 +334,7 @@ void main() {
|
||||
}
|
||||
|
||||
// Should fail as no env variable has been passed.
|
||||
expect(failingFunction,
|
||||
throwsA(isA<FuchsiaRemoteConnectionError>()));
|
||||
expect(failingFunction, throwsA(isA<FuchsiaRemoteConnectionError>()));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -394,7 +386,11 @@ class FakeVmService extends Fake implements vms.VmService {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<vms.Response> callMethod(String method, {String? isolateId, Map<String, dynamic>? args}) async {
|
||||
Future<vms.Response> callMethod(
|
||||
String method, {
|
||||
String? isolateId,
|
||||
Map<String, dynamic>? args,
|
||||
}) async {
|
||||
if (method == '_flutter.listViews') {
|
||||
return flutterListViews!;
|
||||
}
|
||||
|
||||
@@ -17,16 +17,12 @@ void main() {
|
||||
|
||||
test('disconnect closes peer', () async {
|
||||
final FakeVmService service = FakeVmService();
|
||||
Future<vms.VmService> fakeServiceFunction(
|
||||
Uri uri, {
|
||||
Duration? timeout,
|
||||
}) {
|
||||
Future<vms.VmService> fakeServiceFunction(Uri uri, {Duration? timeout}) {
|
||||
return Future<vms.VmService>(() => service);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = fakeServiceFunction;
|
||||
final DartVm vm =
|
||||
await DartVm.connect(Uri.parse('http://this.whatever/ws'));
|
||||
final DartVm vm = await DartVm.connect(Uri.parse('http://this.whatever/ws'));
|
||||
expect(vm, isNot(null));
|
||||
await vm.stop();
|
||||
expect(service.disposed, true);
|
||||
@@ -47,10 +43,7 @@ void main() {
|
||||
test('basic flutter view parsing', () async {
|
||||
final Map<String, dynamic> flutterViewCannedResponses = <String, dynamic>{
|
||||
'views': <Map<String, dynamic>>[
|
||||
<String, dynamic>{
|
||||
'type': 'FlutterView',
|
||||
'id': 'flutterView0',
|
||||
},
|
||||
<String, dynamic>{'type': 'FlutterView', 'id': 'flutterView0'},
|
||||
<String, dynamic>{
|
||||
'type': 'FlutterView',
|
||||
'id': 'flutterView1',
|
||||
@@ -76,18 +69,13 @@ void main() {
|
||||
],
|
||||
};
|
||||
|
||||
Future<vms.VmService> fakeVmConnectionFunction(
|
||||
Uri uri, {
|
||||
Duration? timeout,
|
||||
}) {
|
||||
fakeService.flutterListViews =
|
||||
vms.Response.parse(flutterViewCannedResponses);
|
||||
Future<vms.VmService> fakeVmConnectionFunction(Uri uri, {Duration? timeout}) {
|
||||
fakeService.flutterListViews = vms.Response.parse(flutterViewCannedResponses);
|
||||
return Future<vms.VmService>(() => fakeService);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = fakeVmConnectionFunction;
|
||||
final DartVm vm =
|
||||
await DartVm.connect(Uri.parse('http://whatever.com/ws'));
|
||||
final DartVm vm = await DartVm.connect(Uri.parse('http://whatever.com/ws'));
|
||||
expect(vm, isNot(null));
|
||||
final List<FlutterView> views = await vm.getAllFlutterViews();
|
||||
expect(views.length, 3);
|
||||
@@ -105,10 +93,7 @@ void main() {
|
||||
test('basic flutter view parsing with casting checks', () async {
|
||||
final Map<String, dynamic> flutterViewCannedResponses = <String, dynamic>{
|
||||
'views': <dynamic>[
|
||||
<String, dynamic>{
|
||||
'type': 'FlutterView',
|
||||
'id': 'flutterView0',
|
||||
},
|
||||
<String, dynamic>{'type': 'FlutterView', 'id': 'flutterView0'},
|
||||
<String, dynamic>{
|
||||
'type': 'FlutterView',
|
||||
'id': 'flutterView1',
|
||||
@@ -134,18 +119,13 @@ void main() {
|
||||
],
|
||||
};
|
||||
|
||||
Future<vms.VmService> fakeVmConnectionFunction(
|
||||
Uri uri, {
|
||||
Duration? timeout,
|
||||
}) {
|
||||
fakeService.flutterListViews =
|
||||
vms.Response.parse(flutterViewCannedResponses);
|
||||
Future<vms.VmService> fakeVmConnectionFunction(Uri uri, {Duration? timeout}) {
|
||||
fakeService.flutterListViews = vms.Response.parse(flutterViewCannedResponses);
|
||||
return Future<vms.VmService>(() => fakeService);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = fakeVmConnectionFunction;
|
||||
final DartVm vm =
|
||||
await DartVm.connect(Uri.parse('http://whatever.com/ws'));
|
||||
final DartVm vm = await DartVm.connect(Uri.parse('http://whatever.com/ws'));
|
||||
expect(vm, isNot(null));
|
||||
final List<FlutterView> views = await vm.getAllFlutterViews();
|
||||
expect(views.length, 3);
|
||||
@@ -161,8 +141,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('invalid flutter view missing ID', () async {
|
||||
final Map<String, dynamic> flutterViewCannedResponseMissingId =
|
||||
<String, dynamic>{
|
||||
final Map<String, dynamic> flutterViewCannedResponseMissingId = <String, dynamic>{
|
||||
'views': <Map<String, dynamic>>[
|
||||
// Valid flutter view.
|
||||
<String, dynamic>{
|
||||
@@ -178,24 +157,17 @@ void main() {
|
||||
},
|
||||
|
||||
// Missing ID.
|
||||
<String, dynamic>{
|
||||
'type': 'FlutterView',
|
||||
},
|
||||
<String, dynamic>{'type': 'FlutterView'},
|
||||
],
|
||||
};
|
||||
|
||||
Future<vms.VmService> fakeVmConnectionFunction(
|
||||
Uri uri, {
|
||||
Duration? timeout,
|
||||
}) {
|
||||
fakeService.flutterListViews =
|
||||
vms.Response.parse(flutterViewCannedResponseMissingId);
|
||||
Future<vms.VmService> fakeVmConnectionFunction(Uri uri, {Duration? timeout}) {
|
||||
fakeService.flutterListViews = vms.Response.parse(flutterViewCannedResponseMissingId);
|
||||
return Future<vms.VmService>(() => fakeService);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = fakeVmConnectionFunction;
|
||||
final DartVm vm =
|
||||
await DartVm.connect(Uri.parse('http://whatever.com/ws'));
|
||||
final DartVm vm = await DartVm.connect(Uri.parse('http://whatever.com/ws'));
|
||||
expect(vm, isNot(null));
|
||||
Future<void> failingFunction() async {
|
||||
await vm.getAllFlutterViews();
|
||||
@@ -237,29 +209,24 @@ void main() {
|
||||
})!,
|
||||
];
|
||||
|
||||
Future<vms.VmService> fakeVmConnectionFunction(
|
||||
Uri uri, {
|
||||
Duration? timeout,
|
||||
}) {
|
||||
Future<vms.VmService> fakeVmConnectionFunction(Uri uri, {Duration? timeout}) {
|
||||
fakeService.vm = FakeVM(isolates: isolates);
|
||||
return Future<vms.VmService>(() => fakeService);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = fakeVmConnectionFunction;
|
||||
final DartVm vm =
|
||||
await DartVm.connect(Uri.parse('http://whatever.com/ws'));
|
||||
final DartVm vm = await DartVm.connect(Uri.parse('http://whatever.com/ws'));
|
||||
expect(vm, isNot(null));
|
||||
final List<IsolateRef> matchingFlutterIsolates =
|
||||
await vm.getMainIsolatesByPattern('flutterBinary.cm');
|
||||
final List<IsolateRef> matchingFlutterIsolates = await vm.getMainIsolatesByPattern(
|
||||
'flutterBinary.cm',
|
||||
);
|
||||
expect(matchingFlutterIsolates.length, 1);
|
||||
final List<IsolateRef> allIsolates =
|
||||
await vm.getMainIsolatesByPattern('');
|
||||
final List<IsolateRef> allIsolates = await vm.getMainIsolatesByPattern('');
|
||||
expect(allIsolates.length, 4);
|
||||
});
|
||||
|
||||
test('invalid flutter view missing ID', () async {
|
||||
final Map<String, dynamic> flutterViewCannedResponseMissingIsolateName =
|
||||
<String, dynamic>{
|
||||
final Map<String, dynamic> flutterViewCannedResponseMissingIsolateName = <String, dynamic>{
|
||||
'views': <Map<String, dynamic>>[
|
||||
// Missing isolate name.
|
||||
<String, dynamic>{
|
||||
@@ -275,18 +242,15 @@ void main() {
|
||||
],
|
||||
};
|
||||
|
||||
Future<vms.VmService> fakeVmConnectionFunction(
|
||||
Uri uri, {
|
||||
Duration? timeout,
|
||||
}) {
|
||||
fakeService.flutterListViews =
|
||||
vms.Response.parse(flutterViewCannedResponseMissingIsolateName);
|
||||
Future<vms.VmService> fakeVmConnectionFunction(Uri uri, {Duration? timeout}) {
|
||||
fakeService.flutterListViews = vms.Response.parse(
|
||||
flutterViewCannedResponseMissingIsolateName,
|
||||
);
|
||||
return Future<vms.VmService>(() => fakeService);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = fakeVmConnectionFunction;
|
||||
final DartVm vm =
|
||||
await DartVm.connect(Uri.parse('http://whatever.com/ws'));
|
||||
final DartVm vm = await DartVm.connect(Uri.parse('http://whatever.com/ws'));
|
||||
expect(vm, isNot(null));
|
||||
Future<void> failingFunction() async {
|
||||
await vm.getAllFlutterViews();
|
||||
@@ -312,8 +276,11 @@ class FakeVmService extends Fake implements vms.VmService {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<vms.Response> callMethod(String method,
|
||||
{String? isolateId, Map<String, dynamic>? args}) async {
|
||||
Future<vms.Response> callMethod(
|
||||
String method, {
|
||||
String? isolateId,
|
||||
Map<String, dynamic>? args,
|
||||
}) async {
|
||||
if (method == '_flutter.listViews') {
|
||||
return flutterListViews!;
|
||||
}
|
||||
@@ -325,9 +292,7 @@ class FakeVmService extends Fake implements vms.VmService {
|
||||
}
|
||||
|
||||
class FakeVM extends Fake implements vms.VM {
|
||||
FakeVM({
|
||||
this.isolates = const <vms.IsolateRef>[],
|
||||
});
|
||||
FakeVM({this.isolates = const <vms.IsolateRef>[]});
|
||||
|
||||
@override
|
||||
List<vms.IsolateRef>? isolates;
|
||||
|
||||
@@ -24,8 +24,9 @@ void main() {
|
||||
test('throws exception from injection constructor with invalid addr', () async {
|
||||
SshCommandRunner newCommandRunner() {
|
||||
return SshCommandRunner.withProcessManager(
|
||||
const LocalProcessManager(),
|
||||
address: '192.168.1.1.1');
|
||||
const LocalProcessManager(),
|
||||
address: '192.168.1.1.1',
|
||||
);
|
||||
}
|
||||
|
||||
expect(newCommandRunner, throwsArgumentError);
|
||||
@@ -50,16 +51,13 @@ void main() {
|
||||
sshConfigPath: '/whatever',
|
||||
);
|
||||
fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null);
|
||||
await runner.run('ls /whatever');
|
||||
await runner.run('ls /whatever');
|
||||
expect(fakeProcessManager.runCommands.single, contains('$ipV6Addr%$interface'));
|
||||
});
|
||||
|
||||
test('verify no percentage symbol is added when no ipv6 interface', () async {
|
||||
const String ipV6Addr = 'fe80::8eae:4cff:fef4:9247';
|
||||
runner = SshCommandRunner.withProcessManager(
|
||||
fakeProcessManager,
|
||||
address: ipV6Addr,
|
||||
);
|
||||
runner = SshCommandRunner.withProcessManager(fakeProcessManager, address: ipV6Addr);
|
||||
fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null);
|
||||
await runner.run('ls /whatever');
|
||||
expect(fakeProcessManager.runCommands.single, contains(ipV6Addr));
|
||||
@@ -67,25 +65,19 @@ void main() {
|
||||
|
||||
test('verify commands are split into multiple lines', () async {
|
||||
const String addr = '192.168.1.1';
|
||||
runner = SshCommandRunner.withProcessManager(fakeProcessManager,
|
||||
address: addr);
|
||||
fakeProcessManager.fakeResult = ProcessResult(
|
||||
23,
|
||||
0,
|
||||
'''
|
||||
runner = SshCommandRunner.withProcessManager(fakeProcessManager, address: addr);
|
||||
fakeProcessManager.fakeResult = ProcessResult(23, 0, '''
|
||||
this
|
||||
has
|
||||
four
|
||||
lines''',
|
||||
null);
|
||||
lines''', null);
|
||||
final List<String> result = await runner.run('oihaw');
|
||||
expect(result, hasLength(4));
|
||||
});
|
||||
|
||||
test('verify exception on nonzero process result exit code', () async {
|
||||
const String addr = '192.168.1.1';
|
||||
runner = SshCommandRunner.withProcessManager(fakeProcessManager,
|
||||
address: addr);
|
||||
runner = SshCommandRunner.withProcessManager(fakeProcessManager, address: addr);
|
||||
fakeProcessManager.fakeResult = ProcessResult(23, 1, 'whatever', null);
|
||||
Future<void> failingFunction() async {
|
||||
await runner.run('oihaw');
|
||||
@@ -113,10 +105,7 @@ void main() {
|
||||
|
||||
test('verify config is excluded correctly', () async {
|
||||
const String addr = 'fe80::8eae:4cff:fef4:9247';
|
||||
runner = SshCommandRunner.withProcessManager(
|
||||
fakeProcessManager,
|
||||
address: addr,
|
||||
);
|
||||
runner = SshCommandRunner.withProcessManager(fakeProcessManager, address: addr);
|
||||
fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null);
|
||||
await runner.run('ls /whatever');
|
||||
final List<String?> passedCommand = fakeProcessManager.runCommands.single as List<String?>;
|
||||
@@ -132,7 +121,8 @@ class FakeProcessManager extends Fake implements ProcessManager {
|
||||
List<List<dynamic>> runCommands = <List<dynamic>>[];
|
||||
|
||||
@override
|
||||
Future<ProcessResult> run(List<dynamic> command, {
|
||||
Future<ProcessResult> run(
|
||||
List<dynamic> command, {
|
||||
String? workingDirectory,
|
||||
Map<String, String>? environment,
|
||||
bool includeParentEnvironment = true,
|
||||
|
||||
Reference in New Issue
Block a user