blob: a98d2b3ecebee3cf051fea647ed95c068f818343 [file] [log] [blame]
// 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:args/command_runner.dart';
import '../framework/runner.dart';
class TestCommand extends Command<void> {
TestCommand() {
abbr: 't',
help: 'The name of a task listed under bin/tasks.\n'
' Example: complex_layout__start_up.\n');
help: 'The name of a task listed under bin/tasks.\n'
'For example, "--task-args build" is passed as "bin/task/task.dart --build"');
abbr: 'd',
help: 'Target device id (prefixes are allowed, names are not supported).\n'
'The option will be ignored if the test target does not run on a\n'
'mobile device. This still respects the device operating system\n'
'settings in the test case, and will results in error if no device\n'
'with given ID/ID prefix is found.',
help: '[Flutter infrastructure] Git branch of the current commit. LUCI\n'
'checkouts run in detached HEAD state, so the branch must be passed.',
help: 'Name of a build output within the engine out directory, if you\n'
'are building Flutter locally. Use this to select a specific\n'
'version of the engine if you have built multiple engine targets.\n'
'This path is relative to --local-engine-src-path/out. This option\n'
'is required when running an A/B test (see the --ab option).',
help: 'Path to your engine src directory, if you are building Flutter\n'
'locally. Defaults to \$FLUTTER_ENGINE if set, or tries to guess at\n'
'the location based on the value of the --flutter-root option.',
argParser.addOption('luci-builder', help: '[Flutter infrastructure] Name of the LUCI builder being run on.');
help: '[Flutter infrastructure] File path for test results. If passed with\n'
'task, will write test results to the file.');
help: 'Suppresses standard output and only print standard error output.',
help: 'Use an emulator instead of a device to run tests.'
String get name => 'test';
String get description => 'Run Flutter DeviceLab test';
Future<void> run() async {
final List<String> taskArgsRaw = argResults!['task-args'] as List<String>;
// Prepend '--' to convert args to options when passed to task
final List<String> taskArgs = taskArg) => '--$taskArg').toList();
await runTasks(
<String>[argResults!['task'] as String],
deviceId: argResults!['device-id'] as String?,
gitBranch: argResults!['git-branch'] as String?,
localEngine: argResults!['local-engine'] as String?,
localEngineSrcPath: argResults!['local-engine-src-path'] as String?,
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,