[flutter_tools] shard out two integration tests we want to run on macOS arm64 (#101769)

This commit is contained in:
Christopher Fujino
2022-04-13 12:09:11 -07:00
committed by GitHub
parent 02ae020e53
commit fd5356ff60
7 changed files with 99 additions and 56 deletions

View File

@@ -0,0 +1,56 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart';
import '../integration.shard/test_utils.dart';
import '../src/common.dart';
Future<void> main() async {
test('verify the dart binary arch matches the host arch', () async {
final HostPlatform dartArch = _identifyMacBinaryArch(_dartBinary.path);
final OperatingSystemUtils os = OperatingSystemUtils(
processManager: processManager,
fileSystem: fileSystem,
platform: platform,
logger: BufferLogger.test(),
);
expect(dartArch, os.hostPlatform);
}, skip: !platform.isMacOS); // [intended] Calls macOS-specific commands
}
// Call `file` on the path and parse the output.
HostPlatform _identifyMacBinaryArch(String path) {
// Expect STDOUT like:
// bin/cache/dart-sdk/bin/dart: Mach-O 64-bit executable x86_64
final RegExp pattern = RegExp(r'Mach-O 64-bit executable (\w+)');
final ProcessResult result = processManager.runSync(
<String>['file', _dartBinary.path],
);
final RegExpMatch? match = pattern.firstMatch(result.stdout as String);
if (match == null) {
fail('Unrecognized STDOUT from `file`: "${result.stdout}"');
}
switch (match.group(1)) {
case 'x86_64':
return HostPlatform.darwin_x64;
case 'arm64':
return HostPlatform.darwin_arm;
default:
fail('Unexpected architecture ${match.group(1)}');
}
}
final String _flutterRootPath = getFlutterRoot();
final Directory _flutterRoot = fileSystem.directory(_flutterRootPath);
final File _dartBinary = _flutterRoot
.childDirectory('bin')
.childDirectory('cache')
.childDirectory('dart-sdk')
.childDirectory('bin')
.childFile('dart')
.absolute;

View File

@@ -9,9 +9,9 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/build_info.dart';
import '../integration.shard/test_utils.dart';
import '../src/common.dart';
import '../src/darwin_common.dart';
import 'test_utils.dart';
void main() {
group('iOS app validation', () {

View File

@@ -8,9 +8,9 @@ import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import '../integration.shard/test_utils.dart';
import '../src/common.dart';
import '../src/darwin_common.dart';
import 'test_utils.dart';
void main() {
for (final String buildMode in <String>['Debug', 'Release']) {

View File

@@ -7,8 +7,6 @@ import 'dart:convert';
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart';
import '../src/common.dart';
import 'test_utils.dart';
@@ -50,40 +48,6 @@ Future<void> main() async {
expect(stdout, contains('Successfully received SIGTERM!'));
},
skip: platform.isWindows); // [intended] Windows does not use the bash entrypoint
test('verify the dart binary arch matches the host arch', () async {
final HostPlatform dartArch = _identifyBinaryArch(dartBinary.path);
final OperatingSystemUtils os = OperatingSystemUtils(
processManager: processManager,
fileSystem: fileSystem,
platform: platform,
logger: BufferLogger.test(),
);
expect(dartArch, os.hostPlatform);
}, skip: !platform.isMacOS); // [intended] Calls macOS-specific commands
}
// Call `file` on the path and parse the output.
// This is macOS-specific.
HostPlatform _identifyBinaryArch(String path) {
// Expect STDOUT like:
// bin/cache/dart-sdk/bin/dart: Mach-O 64-bit executable x86_64
final RegExp pattern = RegExp(r'Mach-O 64-bit executable (\w+)');
final ProcessResult result = processManager.runSync(
<String>['file', dartBinary.path],
);
final RegExpMatch? match = pattern.firstMatch(result.stdout as String);
if (match == null) {
fail('Unrecognized STDOUT from `file`: "${result.stdout}"');
}
switch (match.group(1)) {
case 'x86_64':
return HostPlatform.darwin_x64;
case 'arm64':
return HostPlatform.darwin_arm;
default:
fail('Unexpected architecture ${match.group(1)}');
}
}
// A test Dart app that will run until it receives SIGTERM
@@ -105,14 +69,3 @@ File get dartBash {
.childFile('dart')
.absolute;
}
// The executable bash entrypoint for the Dart binary.
File get dartBinary {
return flutterRoot
.childDirectory('bin')
.childDirectory('cache')
.childDirectory('dart-sdk')
.childDirectory('bin')
.childFile('dart')
.absolute;
}