mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add SDK location unit tests (#52691)
This commit is contained in:
parent
b55f969bdc
commit
93a6057c42
@ -169,10 +169,9 @@ class Xcode {
|
|||||||
assert(sdk != null);
|
assert(sdk != null);
|
||||||
final RunResult runResult = await _processUtils.run(
|
final RunResult runResult = await _processUtils.run(
|
||||||
<String>['xcrun', '--sdk', getNameForSdk(sdk), '--show-sdk-path'],
|
<String>['xcrun', '--sdk', getNameForSdk(sdk), '--show-sdk-path'],
|
||||||
throwOnError: true,
|
|
||||||
);
|
);
|
||||||
if (runResult.exitCode != 0) {
|
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();
|
return runResult.stdout.trim();
|
||||||
}
|
}
|
||||||
|
@ -178,6 +178,32 @@ void main() {
|
|||||||
expect(getNameForSdk(SdkType.iPhoneSimulator), 'iphonesimulator');
|
expect(getNameForSdk(SdkType.iPhoneSimulator), 'iphonesimulator');
|
||||||
expect(getNameForSdk(SdkType.macOS), 'macosx');
|
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', () {
|
group('xcdevice', () {
|
||||||
|
Loading…
Reference in New Issue
Block a user