This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree 2 files changed +71
-1
lines changed 2 files changed +71
-1
lines changed Original file line number Diff line number Diff line change @@ -372,10 +372,16 @@ class _MacOSUtils extends _PosixUtils {
372
372
_processUtils.runSync (< String > ['sw_vers' , '-productName' ]),
373
373
_processUtils.runSync (< String > ['sw_vers' , '-productVersion' ]),
374
374
_processUtils.runSync (< String > ['sw_vers' , '-buildVersion' ]),
375
+ _processUtils.runSync (< String > ['uname' , '-m' ]),
375
376
];
376
377
if (results.every ((RunResult result) => result.exitCode == 0 )) {
378
+ String osName = getNameForHostPlatform (hostPlatform);
379
+ // If the script is running in Rosetta, "uname -m" will return x86_64.
380
+ if (hostPlatform == HostPlatform .darwin_arm && results[3 ].stdout.contains ('x86_64' )) {
381
+ osName = '$osName (Rosetta)' ;
382
+ }
377
383
_name =
378
- '${results [0 ].stdout .trim ()} ${results [1 ].stdout .trim ()} ${results [2 ].stdout .trim ()} ${ getNameForHostPlatform ( hostPlatform )} ' ;
384
+ '${results [0 ].stdout .trim ()} ${results [1 ].stdout .trim ()} ${results [2 ].stdout .trim ()} $osName ' ;
379
385
}
380
386
_name ?? = super .name;
381
387
}
Original file line number Diff line number Diff line change @@ -311,6 +311,13 @@ void main() {
311
311
],
312
312
stdout: 'build' ,
313
313
),
314
+ const FakeCommand (
315
+ command: < String > [
316
+ 'uname' ,
317
+ '-m' ,
318
+ ],
319
+ stdout: 'arm64' ,
320
+ ),
314
321
const FakeCommand (
315
322
command: < String > [
316
323
'which' ,
@@ -331,6 +338,56 @@ void main() {
331
338
expect (utils.name, 'product version build darwin-arm' );
332
339
});
333
340
341
+ testWithoutContext ('macOS ARM on Rosetta name' , () async {
342
+ fakeProcessManager.addCommands (< FakeCommand > [
343
+ const FakeCommand (
344
+ command: < String > [
345
+ 'sw_vers' ,
346
+ '-productName' ,
347
+ ],
348
+ stdout: 'product' ,
349
+ ),
350
+ const FakeCommand (
351
+ command: < String > [
352
+ 'sw_vers' ,
353
+ '-productVersion' ,
354
+ ],
355
+ stdout: 'version' ,
356
+ ),
357
+ const FakeCommand (
358
+ command: < String > [
359
+ 'sw_vers' ,
360
+ '-buildVersion' ,
361
+ ],
362
+ stdout: 'build' ,
363
+ ),
364
+ const FakeCommand (
365
+ command: < String > [
366
+ 'uname' ,
367
+ '-m' ,
368
+ ],
369
+ stdout: 'x86_64' , // Running on Rosetta
370
+ ),
371
+ const FakeCommand (
372
+ command: < String > [
373
+ 'which' ,
374
+ 'sysctl' ,
375
+ ],
376
+ ),
377
+ const FakeCommand (
378
+ command: < String > [
379
+ 'sysctl' ,
380
+ 'hw.optional.arm64' ,
381
+ ],
382
+ stdout: 'hw.optional.arm64: 1' ,
383
+ ),
384
+ ]);
385
+
386
+ final OperatingSystemUtils utils =
387
+ createOSUtils (FakePlatform (operatingSystem: 'macos' ));
388
+ expect (utils.name, 'product version build darwin-arm (Rosetta)' );
389
+ });
390
+
334
391
testWithoutContext ('macOS x86 name' , () async {
335
392
fakeProcessManager.addCommands (< FakeCommand > [
336
393
const FakeCommand (
@@ -354,6 +411,13 @@ void main() {
354
411
],
355
412
stdout: 'build' ,
356
413
),
414
+ const FakeCommand (
415
+ command: < String > [
416
+ 'uname' ,
417
+ '-m' ,
418
+ ],
419
+ stdout: 'x86_64' ,
420
+ ),
357
421
const FakeCommand (
358
422
command: < String > [
359
423
'which' ,
You can’t perform that action at this time.
0 commit comments