Unverified Commit 03034e9e authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Audit devicelab log streaming for nullability (#84820)

parent 15301a6f
...@@ -8,7 +8,6 @@ import 'dart:io'; ...@@ -8,7 +8,6 @@ import 'dart:io';
import 'package:flutter_devicelab/framework/devices.dart'; import 'package:flutter_devicelab/framework/devices.dart';
import 'package:flutter_devicelab/framework/framework.dart'; import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/host_agent.dart';
import 'package:flutter_devicelab/framework/task_result.dart'; import 'package:flutter_devicelab/framework/task_result.dart';
import 'package:flutter_devicelab/framework/utils.dart'; import 'package:flutter_devicelab/framework/utils.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
...@@ -34,8 +33,6 @@ void main() { ...@@ -34,8 +33,6 @@ void main() {
p.join(complexLayoutPath, 'test_driver', 'semantics_perf.dart'), p.join(complexLayoutPath, 'test_driver', 'semantics_perf.dart'),
'-d', '-d',
deviceId, deviceId,
'--screenshot',
hostAgent.dumpDirectory.path,
]); ]);
}); });
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
import 'package:flutter_devicelab/framework/devices.dart'; import 'package:flutter_devicelab/framework/devices.dart';
import 'package:flutter_devicelab/framework/framework.dart'; import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/host_agent.dart';
import 'package:flutter_devicelab/framework/task_result.dart'; import 'package:flutter_devicelab/framework/task_result.dart';
import 'package:flutter_devicelab/framework/utils.dart'; import 'package:flutter_devicelab/framework/utils.dart';
...@@ -18,8 +17,6 @@ Future<String> _runWithMode(String mode, String deviceId) async { ...@@ -18,8 +17,6 @@ Future<String> _runWithMode(String mode, String deviceId) async {
'test_driver/scroll_perf.dart', 'test_driver/scroll_perf.dart',
'-d', '-d',
deviceId, deviceId,
'--screenshot',
hostAgent.dumpDirectory.path,
]); ]);
return stderr.toString(); return stderr.toString();
} }
......
...@@ -360,9 +360,11 @@ Future<void> main() async { ...@@ -360,9 +360,11 @@ Future<void> main() async {
); );
if (testResultExit != 0) { if (testResultExit != 0) {
final Directory dumpDirectory = hostAgent.dumpDirectory;
if (dumpDirectory != null) {
// Zip the test results to the artifacts directory for upload. // Zip the test results to the artifacts directory for upload.
await inDirectory(resultBundleTemp, () { await inDirectory(resultBundleTemp, () {
final String zipPath = path.join(hostAgent.dumpDirectory.path, final String zipPath = path.join(dumpDirectory.path,
'module_test_ios-objc-${DateTime.now().toLocal().toIso8601String()}.zip'); 'module_test_ios-objc-${DateTime.now().toLocal().toIso8601String()}.zip');
return exec( return exec(
'zip', 'zip',
...@@ -375,6 +377,7 @@ Future<void> main() async { ...@@ -375,6 +377,7 @@ Future<void> main() async {
canFail: true, // Best effort to get the logs. canFail: true, // Best effort to get the logs.
); );
}); });
}
throw TaskResult.failure('Platform unit tests failed'); throw TaskResult.failure('Platform unit tests failed');
} }
......
...@@ -74,8 +74,10 @@ Future<void> main() async { ...@@ -74,8 +74,10 @@ Future<void> main() async {
); );
if (testResultExit != 0) { if (testResultExit != 0) {
final Directory dumpDirectory = hostAgent.dumpDirectory;
if (dumpDirectory != null) {
// Zip the test results to the artifacts directory for upload. // Zip the test results to the artifacts directory for upload.
final String zipPath = path.join(hostAgent.dumpDirectory.path, final String zipPath = path.join(dumpDirectory.path,
'native_ui_tests_ios32-${DateTime.now().toLocal().toIso8601String()}.zip'); 'native_ui_tests_ios32-${DateTime.now().toLocal().toIso8601String()}.zip');
await exec( await exec(
'zip', 'zip',
...@@ -88,6 +90,7 @@ Future<void> main() async { ...@@ -88,6 +90,7 @@ Future<void> main() async {
workingDirectory: resultBundleTemp, workingDirectory: resultBundleTemp,
canFail: true, // Best effort to get the logs. canFail: true, // Best effort to get the logs.
); );
}
return TaskResult.failure('Platform unit tests failed'); return TaskResult.failure('Platform unit tests failed');
} }
......
...@@ -11,7 +11,6 @@ import 'dart:io'; ...@@ -11,7 +11,6 @@ import 'dart:io';
import 'package:flutter_devicelab/common.dart'; import 'package:flutter_devicelab/common.dart';
import 'package:flutter_devicelab/framework/devices.dart'; import 'package:flutter_devicelab/framework/devices.dart';
import 'package:flutter_devicelab/framework/framework.dart'; import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/host_agent.dart';
import 'package:flutter_devicelab/framework/task_result.dart'; import 'package:flutter_devicelab/framework/task_result.dart';
import 'package:flutter_devicelab/framework/utils.dart'; import 'package:flutter_devicelab/framework/utils.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
...@@ -31,8 +30,6 @@ void main() { ...@@ -31,8 +30,6 @@ void main() {
'--verbose', '--verbose',
'-d', '-d',
device.deviceId, device.deviceId,
'--screenshot',
hostAgent.dumpDirectory.path,
'--route', '--route',
'/smuggle-it', '/smuggle-it',
'lib/route.dart', 'lib/route.dart',
......
...@@ -615,11 +615,12 @@ class AndroidDevice extends Device { ...@@ -615,11 +615,12 @@ class AndroidDevice extends Device {
@override @override
Future<void> stopLoggingToSink() async { Future<void> stopLoggingToSink() async {
assert(_loggingProcess != null); if (_loggingProcess != null) {
_abortedLogging = true; _abortedLogging = true;
_loggingProcess.kill(); _loggingProcess.kill();
await _loggingProcess.exitCode; await _loggingProcess.exitCode;
} }
}
@override @override
Stream<String> get logcat { Stream<String> get logcat {
...@@ -877,11 +878,12 @@ class IosDevice extends Device { ...@@ -877,11 +878,12 @@ class IosDevice extends Device {
@override @override
Future<void> stopLoggingToSink() async { Future<void> stopLoggingToSink() async {
assert(_loggingProcess != null); if (_loggingProcess != null) {
_abortedLogging = true; _abortedLogging = true;
_loggingProcess.kill(); _loggingProcess.kill();
await _loggingProcess.exitCode; await _loggingProcess.exitCode;
} }
}
// The methods below are stubs for now. They will need to be expanded. // The methods below are stubs for now. They will need to be expanded.
// We currently do not have a way to lock/unlock iOS devices. So we assume the // We currently do not have a way to lock/unlock iOS devices. So we assume the
......
...@@ -161,9 +161,8 @@ class _TaskRunner { ...@@ -161,9 +161,8 @@ class _TaskRunner {
result = await futureResult; result = await futureResult;
} finally { } finally {
if (device != null && device.canStreamLogs) { if (device != null && device.canStreamLogs) {
assert(sink != null);
await device.stopLoggingToSink(); await device.stopLoggingToSink();
await sink.close(); await sink?.close();
} }
} }
......
...@@ -16,6 +16,7 @@ import 'package:path/path.dart' as path; ...@@ -16,6 +16,7 @@ import 'package:path/path.dart' as path;
import 'package:process/process.dart'; import 'package:process/process.dart';
import 'package:stack_trace/stack_trace.dart'; import 'package:stack_trace/stack_trace.dart';
import 'host_agent.dart';
import 'task_result.dart'; import 'task_result.dart';
/// Virtual current working directory, which affect functions, such as [exec]. /// Virtual current working directory, which affect functions, such as [exec].
...@@ -453,6 +454,11 @@ List<String> flutterCommandArgs(String command, List<String> options) { ...@@ -453,6 +454,11 @@ List<String> flutterCommandArgs(String command, List<String> options) {
'--device-timeout', '--device-timeout',
'5', '5',
], ],
if (command == 'drive' && hostAgent.dumpDirectory != null) ...<String>[
'--screenshot',
hostAgent.dumpDirectory.path,
],
if (localEngine != null) ...<String>['--local-engine', localEngine], if (localEngine != null) ...<String>['--local-engine', localEngine],
if (localEngineSrcPath != null) ...<String>['--local-engine-src-path', localEngineSrcPath], if (localEngineSrcPath != null) ...<String>['--local-engine-src-path', localEngineSrcPath],
...options, ...options,
......
...@@ -10,7 +10,6 @@ import 'dart:math' as math; ...@@ -10,7 +10,6 @@ import 'dart:math' as math;
import '../framework/devices.dart'; import '../framework/devices.dart';
import '../framework/framework.dart'; import '../framework/framework.dart';
import '../framework/host_agent.dart';
import '../framework/task_result.dart'; import '../framework/task_result.dart';
import '../framework/utils.dart'; import '../framework/utils.dart';
...@@ -104,8 +103,6 @@ class GalleryTransitionTest { ...@@ -104,8 +103,6 @@ class GalleryTransitionTest {
'test_driver/$testDriver.dart', 'test_driver/$testDriver.dart',
'-d', '-d',
deviceId, deviceId,
'--screenshot',
hostAgent.dumpDirectory.path,
]); ]);
}); });
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
import '../framework/devices.dart'; import '../framework/devices.dart';
import '../framework/framework.dart'; import '../framework/framework.dart';
import '../framework/host_agent.dart';
import '../framework/task_result.dart'; import '../framework/task_result.dart';
import '../framework/utils.dart'; import '../framework/utils.dart';
...@@ -161,8 +160,6 @@ class DriverTest { ...@@ -161,8 +160,6 @@ class DriverTest {
testTarget, testTarget,
'-d', '-d',
deviceId, deviceId,
'--screenshot',
hostAgent.dumpDirectory.path,
...extraOptions, ...extraOptions,
]; ];
await flutter('drive', options: options, environment: Map<String, String>.from(environment)); await flutter('drive', options: options, environment: Map<String, String>.from(environment));
......
...@@ -314,8 +314,6 @@ TaskFunction createStackSizeTest() { ...@@ -314,8 +314,6 @@ TaskFunction createStackSizeTest() {
'--driver', testDriver, '--driver', testDriver,
'-d', '-d',
deviceId, deviceId,
'--screenshot',
hostAgent.dumpDirectory.path,
]); ]);
final Map<String, dynamic> data = json.decode( final Map<String, dynamic> data = json.decode(
file('${_testOutputDirectory(testDirectory)}/stack_size.json').readAsStringSync(), file('${_testOutputDirectory(testDirectory)}/stack_size.json').readAsStringSync(),
...@@ -411,8 +409,6 @@ TaskFunction createsScrollSmoothnessPerfTest() { ...@@ -411,8 +409,6 @@ TaskFunction createsScrollSmoothnessPerfTest() {
'-t', testTarget, '-t', testTarget,
'-d', '-d',
deviceId, deviceId,
'--screenshot',
hostAgent.dumpDirectory.path,
]); ]);
final Map<String, dynamic> data = json.decode( final Map<String, dynamic> data = json.decode(
file('${_testOutputDirectory(testDirectory)}/scroll_smoothness_test.json').readAsStringSync(), file('${_testOutputDirectory(testDirectory)}/scroll_smoothness_test.json').readAsStringSync(),
...@@ -464,8 +460,6 @@ TaskFunction createFramePolicyIntegrationTest() { ...@@ -464,8 +460,6 @@ TaskFunction createFramePolicyIntegrationTest() {
'-t', testTarget, '-t', testTarget,
'-d', '-d',
deviceId, deviceId,
'--screenshot',
hostAgent.dumpDirectory.path,
]); ]);
final Map<String, dynamic> data = json.decode( final Map<String, dynamic> data = json.decode(
file('${_testOutputDirectory(testDirectory)}/frame_policy_event_delay.json').readAsStringSync(), file('${_testOutputDirectory(testDirectory)}/frame_policy_event_delay.json').readAsStringSync(),
...@@ -585,16 +579,20 @@ class StartupTest { ...@@ -585,16 +579,20 @@ class StartupTest {
results.add(data); results.add(data);
} else { } else {
currentFailures += 1; currentFailures += 1;
if (hostAgent.dumpDirectory != null) {
await flutter( await flutter(
'screenshot', 'screenshot',
options: <String>[ options: <String>[
'-d', '-d',
device.deviceId, device.deviceId,
'--out', '--out',
hostAgent.dumpDirectory.childFile('screenshot_startup_failure_$currentFailures.png').path, hostAgent.dumpDirectory
.childFile('screenshot_startup_failure_$currentFailures.png')
.path,
], ],
canFail: true, canFail: true,
); );
}
i -= 1; i -= 1;
if (currentFailures == maxFailures) { if (currentFailures == maxFailures) {
return TaskResult.failure('Application failed to start $maxFailures times'); return TaskResult.failure('Application failed to start $maxFailures times');
...@@ -830,8 +828,6 @@ class PerfTest { ...@@ -830,8 +828,6 @@ class PerfTest {
...<String>['--dart-define', dartDefine], ...<String>['--dart-define', dartDefine],
'-d', '-d',
deviceId, deviceId,
'--screenshot',
hostAgent.dumpDirectory.path,
]); ]);
final Map<String, dynamic> data = json.decode( final Map<String, dynamic> data = json.decode(
file('${_testOutputDirectory(testDirectory)}/$resultFilename.json').readAsStringSync(), file('${_testOutputDirectory(testDirectory)}/$resultFilename.json').readAsStringSync(),
...@@ -1461,8 +1457,6 @@ class DevToolsMemoryTest { ...@@ -1461,8 +1457,6 @@ class DevToolsMemoryTest {
'drive', 'drive',
options: <String>[ options: <String>[
'-d', _device.deviceId, '-d', _device.deviceId,
'--screenshot',
hostAgent.dumpDirectory.path,
'--profile', '--profile',
'--profile-memory', _kJsonFileName, '--profile-memory', _kJsonFileName,
'--no-publish-port', '--no-publish-port',
......
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