Support tags when running tests from command line (#55152)

This commit is contained in:
Katarina Sheremet
2020-04-21 19:35:13 +02:00
committed by GitHub
parent 579c82e0ba
commit d8f353af5b
5 changed files with 65 additions and 0 deletions

View File

@@ -42,6 +42,14 @@ class TestCommand extends FlutterCommand {
valueHelp: 'substring',
splitCommas: false,
)
..addOption('tags',
abbr: 't',
help: 'Run only tests associated with tags',
)
..addOption('exclude-tags',
abbr: 'x',
help: 'Run only tests WITHOUT given tags',
)
..addFlag('start-paused',
defaultsTo: false,
negatable: false,
@@ -160,6 +168,8 @@ class TestCommand extends FlutterCommand {
final bool buildTestAssets = boolArg('test-assets');
final List<String> names = stringsArg('name');
final List<String> plainNames = stringsArg('plain-name');
final String tags = stringArg('tags');
final String excludeTags = stringArg('exclude-tags');
final FlutterProject flutterProject = FlutterProject.current();
if (buildTestAssets && flutterProject.manifest.assets.isNotEmpty) {
@@ -250,6 +260,8 @@ class TestCommand extends FlutterCommand {
workDir: workDir,
names: names,
plainNames: plainNames,
tags: tags,
excludeTags: excludeTags,
watcher: watcher,
enableObservatory: collector != null || startPaused || boolArg('enable-vmservice'),
startPaused: startPaused,

View File

@@ -31,6 +31,8 @@ abstract class FlutterTestRunner {
Directory workDir,
List<String> names = const <String>[],
List<String> plainNames = const <String>[],
String tags,
String excludeTags,
bool enableObservatory = false,
bool startPaused = false,
bool disableServiceAuthCodes = false,
@@ -62,6 +64,8 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
Directory workDir,
List<String> names = const <String>[],
List<String> plainNames = const <String>[],
String tags,
String excludeTags,
bool enableObservatory = false,
bool startPaused = false,
bool disableServiceAuthCodes = false,
@@ -104,6 +108,10 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
...<String>['--plain-name', plainName],
if (randomSeed != null)
'--test-randomize-ordering-seed=$randomSeed',
if (tags != null)
...<String>['--tags', tags],
if (excludeTags != null)
...<String>['--exclude-tags', excludeTags],
];
if (web) {
final String tempBuildDir = globals.fs.systemTempDirectory