Unverified Commit 839a183e authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Add note to doctor validator if script is running Rosetta (#101309)

parent d6cc67d5
......@@ -372,10 +372,16 @@ class _MacOSUtils extends _PosixUtils {
_processUtils.runSync(<String>['sw_vers', '-productName']),
_processUtils.runSync(<String>['sw_vers', '-productVersion']),
_processUtils.runSync(<String>['sw_vers', '-buildVersion']),
_processUtils.runSync(<String>['uname', '-m']),
];
if (results.every((RunResult result) => result.exitCode == 0)) {
String osName = getNameForHostPlatform(hostPlatform);
// If the script is running in Rosetta, "uname -m" will return x86_64.
if (hostPlatform == HostPlatform.darwin_arm && results[3].stdout.contains('x86_64')) {
osName = '$osName (Rosetta)';
}
_name =
'${results[0].stdout.trim()} ${results[1].stdout.trim()} ${results[2].stdout.trim()} ${getNameForHostPlatform(hostPlatform)}';
'${results[0].stdout.trim()} ${results[1].stdout.trim()} ${results[2].stdout.trim()} $osName';
}
_name ??= super.name;
}
......
......@@ -311,6 +311,13 @@ void main() {
],
stdout: 'build',
),
const FakeCommand(
command: <String>[
'uname',
'-m',
],
stdout: 'arm64',
),
const FakeCommand(
command: <String>[
'which',
......@@ -331,6 +338,56 @@ void main() {
expect(utils.name, 'product version build darwin-arm');
});
testWithoutContext('macOS ARM on Rosetta name', () async {
fakeProcessManager.addCommands(<FakeCommand>[
const FakeCommand(
command: <String>[
'sw_vers',
'-productName',
],
stdout: 'product',
),
const FakeCommand(
command: <String>[
'sw_vers',
'-productVersion',
],
stdout: 'version',
),
const FakeCommand(
command: <String>[
'sw_vers',
'-buildVersion',
],
stdout: 'build',
),
const FakeCommand(
command: <String>[
'uname',
'-m',
],
stdout: 'x86_64', // Running on Rosetta
),
const FakeCommand(
command: <String>[
'which',
'sysctl',
],
),
const FakeCommand(
command: <String>[
'sysctl',
'hw.optional.arm64',
],
stdout: 'hw.optional.arm64: 1',
),
]);
final OperatingSystemUtils utils =
createOSUtils(FakePlatform(operatingSystem: 'macos'));
expect(utils.name, 'product version build darwin-arm (Rosetta)');
});
testWithoutContext('macOS x86 name', () async {
fakeProcessManager.addCommands(<FakeCommand>[
const FakeCommand(
......@@ -354,6 +411,13 @@ void main() {
],
stdout: 'build',
),
const FakeCommand(
command: <String>[
'uname',
'-m',
],
stdout: 'x86_64',
),
const FakeCommand(
command: <String>[
'which',
......
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