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

Use simctl exit code instead of stderr (#73070)

parent 273630c0
......@@ -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() {
......
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