Unverified Commit f989d551 authored by Ricardo Amador's avatar Ricardo Amador Committed by GitHub

Devicelab android emulator (#113472)

* Testing whether emulator is possible.

* Adding changes to see if emulator can be used from recipe.

* adding emulator support.

* Add the emulator flag for testing.

* Using string for boolean since it cannot be parsed in properties

* Checking to see if these changes are being used.

* Updated bool back to string

* Remove trailing whitespace from file.
parent 0449030a
......@@ -1385,6 +1385,7 @@ targets:
tags: >
["devicelab" ,"android", "linux"]
task_name: android_defines_test
use_emulator: "true"
- name: Linux_android android_obfuscate_test
recipe: devicelab/devicelab_drone
......
......@@ -62,6 +62,9 @@ Future<void> main(List<String> rawArgs) async {
/// Path to write test results to.
final String? resultsPath = args['results-file'] as String?;
/// Use an emulator for this test if it is an android test.
final bool useEmulator = (args['use-emulator'] as bool?) ?? false;
if (args.wasParsed('list')) {
for (int i = 0; i < taskNames.length; i++) {
print('${(i + 1).toString().padLeft(3)} - ${taskNames[i]}');
......@@ -107,6 +110,7 @@ Future<void> main(List<String> rawArgs) async {
gitBranch: gitBranch,
luciBuilder: luciBuilder,
resultsPath: resultsPath,
useEmulator: useEmulator,
);
}
}
......@@ -319,6 +323,11 @@ ArgParser createArgParser(List<String> taskNames) {
'running when a task is completed. If any Dart processes are terminated '
'in this way, the test is considered to have failed.',
)
..addFlag(
'use-emulator',
help: 'If this is an android test, use an emulator to run the test instead of '
'a physical device.'
)
..addMultiOption(
'test',
hide: true,
......
......@@ -51,6 +51,10 @@ class TestCommand extends Command<void> {
'silent',
help: 'Suppresses standard output and only print standard error output.',
);
argParser.addFlag(
'use-emulator',
help: 'Use an emulator instead of a device to run tests.'
);
}
@override
......@@ -74,6 +78,7 @@ class TestCommand extends Command<void> {
luciBuilder: argResults!['luci-builder'] as String?,
resultsPath: argResults!['results-file'] as String?,
silent: (argResults!['silent'] as bool?) ?? false,
useEmulator: (argResults!['use-emulator'] as bool?) ?? false,
taskArgs: taskArgs,
);
}
......
......@@ -39,6 +39,7 @@ Future<void> runTasks(
String? luciBuilder,
String? resultsPath,
List<String>? taskArgs,
bool useEmulator = false,
@visibleForTesting Map<String, String>? isolateParams,
@visibleForTesting Function(String) print = print,
@visibleForTesting List<String>? logs,
......@@ -59,6 +60,7 @@ Future<void> runTasks(
gitBranch: gitBranch,
luciBuilder: luciBuilder,
isolateParams: isolateParams,
useEmulator: useEmulator,
);
if (!result.succeeded) {
......@@ -104,6 +106,7 @@ Future<TaskResult> rerunTask(
String? resultsPath,
String? gitBranch,
String? luciBuilder,
bool useEmulator = false,
@visibleForTesting Map<String, String>? isolateParams,
}) async {
section('Running task "$taskName"');
......@@ -116,6 +119,7 @@ Future<TaskResult> rerunTask(
silent: silent,
taskArgs: taskArgs,
isolateParams: isolateParams,
useEmulator: useEmulator,
);
print('Task result:');
......@@ -152,6 +156,7 @@ Future<TaskResult> runTask(
String? localEngineSrcPath,
String? deviceId,
List<String>? taskArgs,
bool useEmulator = false,
@visibleForTesting Map<String, String>? isolateParams,
}) async {
final String taskExecutable = 'bin/tasks/$taskName.dart';
......@@ -160,6 +165,13 @@ Future<TaskResult> runTask(
throw 'Executable Dart file not found: $taskExecutable';
}
if (useEmulator) {
taskArgs ??= <String>[];
taskArgs
..add('--android-emulator')
..add('--browser-name=android-chrome');
}
final Process runner = await startProcess(
dartBin,
<String>[
......
......@@ -283,6 +283,7 @@ Future<Process> startProcess(
newEnvironment['BOT'] = isBot ? 'true' : 'false';
newEnvironment['LANG'] = 'en_US.UTF-8';
print('Executing "$command" in "$finalWorkingDirectory" with environment $newEnvironment');
final Process process = await _processManager.start(
<String>[executable, ...?arguments],
environment: newEnvironment,
......
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