Unverified Commit 93a6057c authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Add SDK location unit tests (#52691)

parent b55f969b
......@@ -169,10 +169,9 @@ class Xcode {
assert(sdk != null);
final RunResult runResult = await _processUtils.run(
<String>['xcrun', '--sdk', getNameForSdk(sdk), '--show-sdk-path'],
throwOnError: true,
);
if (runResult.exitCode != 0) {
throwToolExit('Could not find iPhone SDK location: ${runResult.stderr}');
throwToolExit('Could not find SDK location: ${runResult.stderr}');
}
return runResult.stdout.trim();
}
......
......@@ -178,6 +178,32 @@ void main() {
expect(getNameForSdk(SdkType.iPhoneSimulator), 'iphonesimulator');
expect(getNameForSdk(SdkType.macOS), 'macosx');
});
group('SDK location', () {
const String sdkroot = 'Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk';
testWithoutContext('--show-sdk-path iphoneos', () async {
when(processManager.run(<String>['xcrun', '--sdk', 'iphoneos', '--show-sdk-path'])).thenAnswer((_) =>
Future<ProcessResult>.value(ProcessResult(1, 0, sdkroot, '')));
expect(await xcode.sdkLocation(SdkType.iPhone), sdkroot);
});
testWithoutContext('--show-sdk-path macosx', () async {
when(processManager.run(<String>['xcrun', '--sdk', 'macosx', '--show-sdk-path'])).thenAnswer((_) =>
Future<ProcessResult>.value(ProcessResult(1, 0, sdkroot, '')));
expect(await xcode.sdkLocation(SdkType.macOS), sdkroot);
});
testWithoutContext('--show-sdk-path fails', () async {
when(processManager.run(<String>['xcrun', '--sdk', 'iphoneos', '--show-sdk-path'])).thenAnswer((_) =>
Future<ProcessResult>.value(ProcessResult(1, 1, '', 'xcrun: error:')));
expect(() async => await xcode.sdkLocation(SdkType.iPhone),
throwsToolExit(message: 'Could not find SDK location'));
});
});
});
group('xcdevice', () {
......
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