Skip to content

Commit c134e16

Browse files
author
nturgut
authored
add information collection for safari bots (flutter#20123)
* add information collection for safari bots * remove unused parts. add cast to fix analyze errors * add more information. address reviwer comments * address reviewr comments * typo fix
1 parent e1c9673 commit c134e16

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

lib/web_ui/dev/felt.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,18 @@ void main(List<String> args) async {
4747
} on ToolException catch (e) {
4848
io.stderr.writeln(e.message);
4949
exitCode = 1;
50+
} on ProcessException catch (e) {
51+
io.stderr.writeln('description: ${e.description}'
52+
'executable: ${e.executable} '
53+
'arguments: ${e.arguments} '
54+
'exit code: ${e.exitCode}');
55+
exitCode = e.exitCode;
5056
} catch (e) {
5157
rethrow;
5258
} finally {
5359
await cleanup();
5460
// The exit code is changed by one of the branches.
55-
if(exitCode != -1) {
61+
if (exitCode != -1) {
5662
io.exit(exitCode);
5763
}
5864
}

lib/web_ui/dev/macos_info.dart

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
import 'dart:convert';
5+
6+
import 'utils.dart';
7+
8+
class MacOSInfo {
9+
/// Print information collected from the operating system.
10+
///
11+
/// Built in tools such as `system_profiler` and `defaults` are utilized.
12+
Future<void> printInformation() async {
13+
try {
14+
await _printSafariApplications();
15+
} catch (error) {
16+
print('Error thrown while getting Safari Applications: $error');
17+
}
18+
19+
try {
20+
await _printSafariDefaults();
21+
} catch (error) {
22+
print('Error thrown while getting Safari defaults: $error');
23+
}
24+
25+
try {
26+
await _printUserLimits();
27+
} catch (error) {
28+
print('Error thrown while getting user limits defaults: $error');
29+
}
30+
}
31+
32+
/// Print information on applications in the system that contains string
33+
/// `Safari`.
34+
Future<void> _printSafariApplications() async {
35+
final String systemProfileJson = await evalProcess(
36+
'system_profiler', ['SPApplicationsDataType', '-json']);
37+
38+
final Map<String, dynamic> json =
39+
jsonDecode(systemProfileJson) as Map<String, dynamic>;
40+
final List<dynamic> systemProfile = json.values.first as List<dynamic>;
41+
for (int i = 0; i < systemProfile.length; i++) {
42+
final Map<String, dynamic> application =
43+
systemProfile[i] as Map<String, dynamic>;
44+
final String applicationName = application['_name'] as String;
45+
if (applicationName.contains('Safari')) {
46+
print('application: $applicationName '
47+
'fullInfo: ${application.toString()}');
48+
}
49+
}
50+
}
51+
52+
/// Print all the defaults in the system related to Safari.
53+
Future<void> _printSafariDefaults() async {
54+
final String defaults =
55+
await evalProcess('/usr/bin/defaults', ['find', 'Safari']);
56+
57+
print('Safari related defaults:\n $defaults');
58+
}
59+
60+
/// Print user limits (file and process).
61+
Future<void> _printUserLimits() async {
62+
final String fileLimit = await evalProcess('ulimit', ['-n']);
63+
64+
print('MacOS file limit: $fileLimit');
65+
66+
final String processLimit = await evalProcess('ulimit', ['-u']);
67+
68+
print('MacOS process limit: $processLimit');
69+
}
70+
}

lib/web_ui/dev/test_runner.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ import 'package:test_core/src/executable.dart'
1616
as test; // ignore: implementation_imports
1717
import 'package:simulators/simulator_manager.dart';
1818

19+
import 'common.dart';
1920
import 'environment.dart';
2021
import 'exceptions.dart';
2122
import 'integration_tests_manager.dart';
23+
import 'macos_info.dart';
2224
import 'safari_installation.dart';
2325
import 'supported_browsers.dart';
2426
import 'test_platform.dart';
@@ -124,6 +126,16 @@ class TestCommand extends Command<bool> with ArgUtils {
124126
// Check the flags to see what type of integration tests are requested.
125127
testTypesRequested = findTestType();
126128

129+
if (isSafariOnMacOS) {
130+
/// Collect information on the bot.
131+
final MacOSInfo macOsInfo = new MacOSInfo();
132+
await macOsInfo.printInformation();
133+
/// Tests may fail on the CI, therefore exit test_runner.
134+
if (isLuci) {
135+
return true;
136+
}
137+
}
138+
127139
switch (testTypesRequested) {
128140
case TestTypesRequested.unit:
129141
return runUnitTests();

0 commit comments

Comments
 (0)