Run flutter_gallery macOS native tests on presubmit (#89620)
This commit is contained in:
@@ -2,14 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_devicelab/framework/devices.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/host_agent.dart';
|
||||
import 'package:flutter_devicelab/framework/ios.dart';
|
||||
import 'package:flutter_devicelab/framework/task_result.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.ios;
|
||||
@@ -38,58 +35,7 @@ Future<void> main() async {
|
||||
section('Run platform unit tests');
|
||||
|
||||
final Device device = await devices.workingDevice;
|
||||
final Map<String, String> environment = Platform.environment;
|
||||
// If not running on CI, inject the Flutter team code signing properties.
|
||||
final String developmentTeam = environment['FLUTTER_XCODE_DEVELOPMENT_TEAM'] ?? 'S8QB4VV633';
|
||||
final String? codeSignStyle = environment['FLUTTER_XCODE_CODE_SIGN_STYLE'];
|
||||
final String? provisioningProfile = environment['FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER'];
|
||||
|
||||
final String resultBundleTemp = Directory.systemTemp.createTempSync('flutter_native_ui_tests_ios32_xcresult.').path;
|
||||
final String resultBundlePath = path.join(resultBundleTemp, 'result');
|
||||
final int testResultExit = await exec(
|
||||
'xcodebuild',
|
||||
<String>[
|
||||
'-workspace',
|
||||
'Runner.xcworkspace',
|
||||
'-scheme',
|
||||
'Runner',
|
||||
'-configuration',
|
||||
'Release',
|
||||
'-destination',
|
||||
'id=${device.deviceId}',
|
||||
'-resultBundlePath',
|
||||
resultBundlePath,
|
||||
'test',
|
||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||
'DEVELOPMENT_TEAM=$developmentTeam',
|
||||
if (codeSignStyle != null)
|
||||
'CODE_SIGN_STYLE=$codeSignStyle',
|
||||
if (provisioningProfile != null)
|
||||
'PROVISIONING_PROFILE_SPECIFIER=$provisioningProfile',
|
||||
],
|
||||
workingDirectory: path.join(projectDirectory, 'ios'),
|
||||
canFail: true,
|
||||
);
|
||||
|
||||
if (testResultExit != 0) {
|
||||
final Directory? dumpDirectory = hostAgent.dumpDirectory;
|
||||
if (dumpDirectory != null) {
|
||||
// Zip the test results to the artifacts directory for upload.
|
||||
final String zipPath = path.join(dumpDirectory.path,
|
||||
'native_ui_tests_ios32-${DateTime.now().toLocal().toIso8601String()}.zip');
|
||||
await exec(
|
||||
'zip',
|
||||
<String>[
|
||||
'-r',
|
||||
'-9',
|
||||
zipPath,
|
||||
'result.xcresult',
|
||||
],
|
||||
workingDirectory: resultBundleTemp,
|
||||
canFail: true, // Best effort to get the logs.
|
||||
);
|
||||
}
|
||||
|
||||
if (!await runXcodeTests(projectDirectory, device.deviceId, 'native_ui_tests_ios')) {
|
||||
return TaskResult.failure('Platform unit tests failed');
|
||||
}
|
||||
|
||||
|
||||
35
dev/devicelab/bin/tasks/native_ui_tests_macos.dart
Normal file
35
dev/devicelab/bin/tasks/native_ui_tests_macos.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
// 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:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/ios.dart';
|
||||
import 'package:flutter_devicelab/framework/task_result.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
final String projectDirectory = '${flutterDirectory.path}/dev/integration_tests/flutter_gallery';
|
||||
|
||||
await inDirectory(projectDirectory, () async {
|
||||
section('Build gallery app');
|
||||
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>[
|
||||
'macos',
|
||||
'-v',
|
||||
'--debug',
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
section('Run platform unit tests');
|
||||
|
||||
if (!await runXcodeTests(projectDirectory, 'platform=macOS', 'native_ui_tests_macos')) {
|
||||
return TaskResult.failure('Platform unit tests failed');
|
||||
}
|
||||
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
}
|
||||
@@ -3,7 +3,11 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import 'host_agent.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
typedef SimulatorFunction = Future<void> Function(String deviceId);
|
||||
@@ -135,3 +139,60 @@ Future<void> removeIOSimulator(String deviceId) async {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> runXcodeTests(String projectDirectory, String deviceId, String testName) async {
|
||||
final Map<String, String> environment = Platform.environment;
|
||||
// If not running on CI, inject the Flutter team code signing properties.
|
||||
final String developmentTeam = environment['FLUTTER_XCODE_DEVELOPMENT_TEAM'] ?? 'S8QB4VV633';
|
||||
final String? codeSignStyle = environment['FLUTTER_XCODE_CODE_SIGN_STYLE'];
|
||||
final String? provisioningProfile = environment['FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER'];
|
||||
|
||||
final String resultBundleTemp = Directory.systemTemp.createTempSync('flutter_xcresult.').path;
|
||||
final String resultBundlePath = path.join(resultBundleTemp, 'result');
|
||||
final int testResultExit = await exec(
|
||||
'xcodebuild',
|
||||
<String>[
|
||||
'-workspace',
|
||||
'Runner.xcworkspace',
|
||||
'-scheme',
|
||||
'Runner',
|
||||
'-configuration',
|
||||
'Release',
|
||||
'-destination',
|
||||
'id=$deviceId',
|
||||
'-resultBundlePath',
|
||||
resultBundlePath,
|
||||
'test',
|
||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||
'DEVELOPMENT_TEAM=$developmentTeam',
|
||||
if (codeSignStyle != null)
|
||||
'CODE_SIGN_STYLE=$codeSignStyle',
|
||||
if (provisioningProfile != null)
|
||||
'PROVISIONING_PROFILE_SPECIFIER=$provisioningProfile',
|
||||
],
|
||||
workingDirectory: path.join(projectDirectory, 'ios'),
|
||||
canFail: true,
|
||||
);
|
||||
|
||||
if (testResultExit != 0) {
|
||||
final Directory? dumpDirectory = hostAgent.dumpDirectory;
|
||||
if (dumpDirectory != null) {
|
||||
// Zip the test results to the artifacts directory for upload.
|
||||
final String zipPath = path.join(dumpDirectory.path,
|
||||
'$testName-${DateTime.now().toLocal().toIso8601String()}.zip');
|
||||
await exec(
|
||||
'zip',
|
||||
<String>[
|
||||
'-r',
|
||||
'-9',
|
||||
zipPath,
|
||||
'result.xcresult',
|
||||
],
|
||||
workingDirectory: resultBundleTemp,
|
||||
canFail: true, // Best effort to get the logs.
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user