Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
d8f353af
Unverified
Commit
d8f353af
authored
Apr 21, 2020
by
Katarina Sheremet
Committed by
GitHub
Apr 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support tags when running tests from command line (#55152)
parent
579c82e0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
0 deletions
+65
-0
filtering_tag_test.dart
dev/automated_tests/flutter_test/filtering_tag_test.dart
+14
-0
test.dart
packages/flutter_tools/lib/src/commands/test.dart
+12
-0
runner.dart
packages/flutter_tools/lib/src/test/runner.dart
+8
-0
test_test.dart
...flutter_tools/test/commands.shard/hermetic/test_test.dart
+2
-0
test_test.dart
...lutter_tools/test/commands.shard/permeable/test_test.dart
+29
-0
No files found.
dev/automated_tests/flutter_test/filtering_tag_test.dart
0 → 100644
View file @
d8f353af
// 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:test/test.dart'
hide
TypeMatcher
,
isInstanceOf
;
void
main
(
)
{
test
(
'included'
,
()
{
expect
(
2
+
2
,
4
);
},
tags:
<
String
>[
'include-tag'
]);
test
(
'excluded'
,
()
{
throw
'this test should have been filtered out'
;
},
tags:
<
String
>[
'exclude-tag'
]);
}
packages/flutter_tools/lib/src/commands/test.dart
View file @
d8f353af
...
...
@@ -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
,
...
...
packages/flutter_tools/lib/src/test/runner.dart
View file @
d8f353af
...
...
@@ -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
...
...
packages/flutter_tools/test/commands.shard/hermetic/test_test.dart
View file @
d8f353af
...
...
@@ -164,6 +164,8 @@ class FakeFlutterTestRunner 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
,
...
...
packages/flutter_tools/test/commands.shard/permeable/test_test.dart
View file @
d8f353af
...
...
@@ -96,6 +96,35 @@ void main() {
expect
(
result
.
exitCode
,
0
);
});
testUsingContext
(
'flutter test should run a test with a given tag'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
final
ProcessResult
result
=
await
_runFlutterTest
(
'filtering_tag'
,
automatedTestsDirectory
,
flutterTestDirectory
,
extraArguments:
const
<
String
>[
'--tags'
,
'include-tag'
]);
if
(!(
result
.
stdout
as
String
).
contains
(
'+1: All tests passed'
))
{
fail
(
'unexpected output from test:
\n\n
${result.stdout}
\n
-- end stdout --
\n\n
'
);
}
expect
(
result
.
exitCode
,
0
);
});
testUsingContext
(
'flutter test should not run a test with excluded tag'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
final
ProcessResult
result
=
await
_runFlutterTest
(
'filtering_tag'
,
automatedTestsDirectory
,
flutterTestDirectory
,
extraArguments:
const
<
String
>[
'--exclude-tags'
,
'exclude-tag'
]);
if
(!(
result
.
stdout
as
String
).
contains
(
'+1: All tests passed'
))
{
fail
(
'unexpected output from test:
\n\n
${result.stdout}
\n
-- end stdout --
\n\n
'
);
}
expect
(
result
.
exitCode
,
0
);
});
testUsingContext
(
'flutter test should run all tests when tags are unspecified'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
final
ProcessResult
result
=
await
_runFlutterTest
(
'filtering_tag'
,
automatedTestsDirectory
,
flutterTestDirectory
);
if
(!(
result
.
stdout
as
String
).
contains
(
'+1 -1: Some tests failed'
))
{
fail
(
'unexpected output from test:
\n\n
${result.stdout}
\n
-- end stdout --
\n\n
'
);
}
expect
(
result
.
exitCode
,
1
);
});
testUsingContext
(
'flutter test should test runs to completion'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
final
ProcessResult
result
=
await
_runFlutterTest
(
'trivial'
,
automatedTestsDirectory
,
flutterTestDirectory
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment