mirror of
https://github.com/flutter/flutter
synced 2024-10-13 03:32:55 +00:00
Use simctl exit code instead of stderr (#73070)
This commit is contained in:
parent
273630c09d
commit
bc7286f118
|
@ -124,7 +124,7 @@ class Xcode {
|
|||
final RunResult result = _processUtils.runSync(
|
||||
<String>[...xcrunCommand(), 'simctl', 'list'],
|
||||
);
|
||||
_isSimctlInstalled = result.stderr == null || result.stderr == '';
|
||||
_isSimctlInstalled = result.exitCode == 0;
|
||||
} on ProcessException {
|
||||
_isSimctlInstalled = false;
|
||||
}
|
||||
|
|
|
@ -140,6 +140,53 @@ void main() {
|
|||
expect(xcode.isInstalledAndMeetsVersionCheck, isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('isSimctlInstalled is true when simctl list succeeds', () {
|
||||
when(mockXcodeProjectInterpreter.xcrunCommand()).thenReturn(<String>['xcrun']);
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'xcrun',
|
||||
'simctl',
|
||||
'list',
|
||||
],
|
||||
),
|
||||
);
|
||||
final Xcode xcode = Xcode(
|
||||
logger: logger,
|
||||
platform: FakePlatform(operatingSystem: 'macos'),
|
||||
fileSystem: MemoryFileSystem.test(),
|
||||
processManager: fakeProcessManager,
|
||||
xcodeProjectInterpreter: mockXcodeProjectInterpreter,
|
||||
);
|
||||
|
||||
expect(xcode.isSimctlInstalled, isTrue);
|
||||
expect(fakeProcessManager.hasRemainingExpectations, isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('isSimctlInstalled is true when simctl list fails', () {
|
||||
when(mockXcodeProjectInterpreter.xcrunCommand()).thenReturn(<String>['xcrun']);
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'xcrun',
|
||||
'simctl',
|
||||
'list',
|
||||
],
|
||||
exitCode: 1,
|
||||
),
|
||||
);
|
||||
final Xcode xcode = Xcode(
|
||||
logger: logger,
|
||||
platform: FakePlatform(operatingSystem: 'macos'),
|
||||
fileSystem: MemoryFileSystem.test(),
|
||||
processManager: fakeProcessManager,
|
||||
xcodeProjectInterpreter: mockXcodeProjectInterpreter,
|
||||
);
|
||||
|
||||
expect(xcode.isSimctlInstalled, isFalse);
|
||||
expect(fakeProcessManager.hasRemainingExpectations, isFalse);
|
||||
});
|
||||
|
||||
group('macOS', () {
|
||||
Xcode xcode;
|
||||
FakePlatform platform;
|
||||
|
|
|
@ -7,12 +7,9 @@ import 'package:flutter_tools/src/doctor.dart';
|
|||
import 'package:flutter_tools/src/macos/xcode.dart';
|
||||
import 'package:flutter_tools/src/macos/xcode_validator.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
||||
class MockProcessManager extends Mock implements ProcessManager {}
|
||||
class MockXcode extends Mock implements Xcode {}
|
||||
|
||||
void main() {
|
||||
|
|
Loading…
Reference in a new issue