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

Run flutter tester with arch -x86_64 on arm64 Mac (#92508)

parent 5eacd89f
...@@ -16,6 +16,7 @@ import '../base/common.dart'; ...@@ -16,6 +16,7 @@ import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/os.dart';
import '../base/platform.dart'; import '../base/platform.dart';
import '../convert.dart'; import '../convert.dart';
import '../device.dart'; import '../device.dart';
...@@ -46,7 +47,13 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -46,7 +47,13 @@ class FlutterTesterTestDevice extends TestDevice {
}) : assert(shellPath != null), // Please provide the path to the shell in the SKY_SHELL environment variable. }) : assert(shellPath != null), // Please provide the path to the shell in the SKY_SHELL environment variable.
assert(!debuggingOptions.startPaused || enableObservatory), assert(!debuggingOptions.startPaused || enableObservatory),
_gotProcessObservatoryUri = enableObservatory _gotProcessObservatoryUri = enableObservatory
? Completer<Uri>() : (Completer<Uri>()..complete(null)); ? Completer<Uri>() : (Completer<Uri>()..complete(null)),
_operatingSystemUtils = OperatingSystemUtils(
fileSystem: fileSystem,
logger: logger,
platform: platform,
processManager: processManager,
);
/// Used for logging to identify the test that is currently being executed. /// Used for logging to identify the test that is currently being executed.
final int id; final int id;
...@@ -70,6 +77,7 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -70,6 +77,7 @@ class FlutterTesterTestDevice extends TestDevice {
Process _process; Process _process;
HttpServer _server; HttpServer _server;
final OperatingSystemUtils _operatingSystemUtils;
/// Starts the device. /// Starts the device.
/// ///
...@@ -87,6 +95,13 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -87,6 +95,13 @@ class FlutterTesterTestDevice extends TestDevice {
logger.printTrace('test $id: test harness socket server is running at port:${_server.port}'); logger.printTrace('test $id: test harness socket server is running at port:${_server.port}');
final List<String> command = <String>[ final List<String> command = <String>[
// Until an arm64 flutter tester binary is available, force to run in Rosetta
// to avoid "unexpectedly got a signal in sigtramp" crash.
// https://github.com/flutter/flutter/issues/88106
if (_operatingSystemUtils.hostPlatform == HostPlatform.darwin_arm) ...<String>[
'/usr/bin/arch',
'-x86_64',
],
shellPath, shellPath,
if (enableObservatory) ...<String>[ if (enableObservatory) ...<String>[
// Some systems drive the _FlutterPlatform class in an unusual way, where // Some systems drive the _FlutterPlatform class in an unusual way, where
......
...@@ -51,9 +51,66 @@ void main() { ...@@ -51,9 +51,66 @@ void main() {
dartEntrypointArgs: dartEntrypointArgs, dartEntrypointArgs: dartEntrypointArgs,
); );
testUsingContext('runs in Rosetta on arm64 Mac', () async {
final FakeProcessManager processManager = FakeProcessManager.empty();
final FlutterTesterTestDevice device = TestFlutterTesterDevice(
platform: FakePlatform(operatingSystem: 'macos'),
fileSystem: fileSystem,
processManager: processManager,
enableObservatory: false,
dartEntrypointArgs: const <String>[],
);
processManager.addCommands(<FakeCommand>[
const FakeCommand(
command: <String>[
'which',
'sysctl',
],
),
const FakeCommand(
command: <String>[
'sysctl',
'hw.optional.arm64',
],
stdout: 'hw.optional.arm64: 1',
),
FakeCommand(command: const <String>[
'/usr/bin/arch',
'-x86_64',
'/',
'--disable-observatory',
'--ipv6',
'--enable-checked-mode',
'--verify-entry-points',
'--enable-software-rendering',
'--skia-deterministic-rendering',
'--enable-dart-profiling',
'--non-interactive',
'--use-test-fonts',
'--packages=.dart_tool/package_config.json',
'example.dill',
], environment: <String, String>{
'FLUTTER_TEST': 'true',
'FONTCONFIG_FILE': device.fontConfigManager.fontConfigFile.path,
'SERVER_PORT': '0',
'APP_NAME': '',
}),
]);
await device.start('example.dill');
expect(processManager.hasRemainingExpectations, isFalse);
});
group('The FLUTTER_TEST environment variable is passed to the test process', () { group('The FLUTTER_TEST environment variable is passed to the test process', () {
setUp(() { setUp(() {
processManager = FakeProcessManager.empty(); processManager = FakeProcessManager.list(<FakeCommand>[
const FakeCommand(
command: <String>[
'uname',
'-m',
],
stdout: 'x86_64',
),
]);
device = createDevice(); device = createDevice();
fileSystem fileSystem
...@@ -127,6 +184,13 @@ void main() { ...@@ -127,6 +184,13 @@ void main() {
group('Dart Entrypoint Args', () { group('Dart Entrypoint Args', () {
setUp(() { setUp(() {
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.list(<FakeCommand>[
const FakeCommand(
command: <String>[
'uname',
'-m',
],
stdout: 'x86_64',
),
const FakeCommand( const FakeCommand(
command: <String>[ command: <String>[
'/', '/',
...@@ -161,6 +225,13 @@ void main() { ...@@ -161,6 +225,13 @@ void main() {
group('DDS', () { group('DDS', () {
setUp(() { setUp(() {
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.list(<FakeCommand>[
const FakeCommand(
command: <String>[
'uname',
'-m',
],
stdout: 'x86_64',
),
const FakeCommand( const FakeCommand(
command: <String>[ command: <String>[
'/', '/',
......
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