[flutter_tools] io cleanups to simplify null safety migration (#77955)
This commit is contained in:
@@ -9,6 +9,7 @@ import 'dart:io' as io;
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:test/fake.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
@@ -66,7 +67,7 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('ProcessSignal toString() works', () async {
|
||||
expect(io.ProcessSignal.sigint.toString(), ProcessSignal.SIGINT.toString());
|
||||
expect(io.ProcessSignal.sigint.toString(), ProcessSignal.sigint.toString());
|
||||
});
|
||||
|
||||
test('exit throws a StateError if called without being overriden', () {
|
||||
@@ -100,6 +101,18 @@ void main() {
|
||||
|
||||
resetNetworkInterfaceLister();
|
||||
});
|
||||
|
||||
testWithoutContext('Does not listen to Posix process signals on windows', () async {
|
||||
final FakePlatform windows = FakePlatform(operatingSystem: 'windows');
|
||||
final FakePlatform linux = FakePlatform(operatingSystem: 'linux');
|
||||
final FakeProcessSignal fakeSignalA = FakeProcessSignal();
|
||||
final FakeProcessSignal fakeSignalB = FakeProcessSignal();
|
||||
fakeSignalA.controller.add(fakeSignalA);
|
||||
fakeSignalB.controller.add(fakeSignalB);
|
||||
|
||||
expect(await PosixProcessSignal(fakeSignalA, platform: windows).watch().isEmpty, true);
|
||||
expect(await PosixProcessSignal(fakeSignalB, platform: linux).watch().first, isNotNull);
|
||||
});
|
||||
}
|
||||
|
||||
class FakeProcessSignal extends Fake implements io.ProcessSignal {
|
||||
|
||||
@@ -637,7 +637,7 @@ class FakeSignals implements Signals {
|
||||
|
||||
@override
|
||||
Object addHandler(ProcessSignal signal, SignalHandler handler) {
|
||||
if (signal == ProcessSignal.SIGTERM) {
|
||||
if (signal == ProcessSignal.sigterm) {
|
||||
return delegate.addHandler(subForSigTerm, handler);
|
||||
}
|
||||
return delegate.addHandler(signal, handler);
|
||||
|
||||
@@ -204,7 +204,7 @@ abstract class FlutterTestDriver {
|
||||
|
||||
Future<int> _killForcefully() {
|
||||
_debugPrint('Sending SIGKILL to $_processPid..');
|
||||
ProcessSignal.SIGKILL.send(_processPid);
|
||||
ProcessSignal.sigkill.send(_processPid);
|
||||
return _process.exitCode;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user