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
739adf3d
Unverified
Commit
739adf3d
authored
Feb 24, 2021
by
Daniel Gomez
Committed by
GitHub
Feb 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sharding options to test command line (#76382)
parent
5cac7c3b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
0 deletions
+89
-0
test.dart
packages/flutter_tools/lib/src/commands/test.dart
+33
-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
+48
-0
No files found.
packages/flutter_tools/lib/src/commands/test.dart
View file @
739adf3d
...
...
@@ -140,6 +140,16 @@ class TestCommand extends FlutterCommand {
'which indicates that a seed should be selected randomly. '
'By default, tests run in the order they are declared.'
,
)
..
addOption
(
'total-shards'
,
help:
'Tests can be sharded with the "--total-shards" and "--shard-index" '
'arguments, allowing you to split up your test suites and run '
'them separately.'
)
..
addOption
(
'shard-index'
,
help:
'Tests can be sharded with the "--total-shards" and "--shard-index" '
'arguments, allowing you to split up your test suites and run '
'them separately.'
)
..
addFlag
(
'enable-vmservice'
,
defaultsTo:
false
,
hide:
!
verboseHelp
,
...
...
@@ -265,6 +275,27 @@ class TestCommand extends FlutterCommand {
];
}
final
int
shardIndex
=
int
.
tryParse
(
stringArg
(
'shard-index'
)
??
''
);
if
(
shardIndex
!=
null
&&
(
shardIndex
<
0
||
!
shardIndex
.
isFinite
))
{
throwToolExit
(
'Could not parse --shard-index=
$shardIndex
argument. It must be an integer greater than -1.'
);
}
final
int
totalShards
=
int
.
tryParse
(
stringArg
(
'total-shards'
)
??
''
);
if
(
totalShards
!=
null
&&
(
totalShards
<=
0
||
!
totalShards
.
isFinite
))
{
throwToolExit
(
'Could not parse --total-shards=
$totalShards
argument. It must be an integer greater than zero.'
);
}
if
(
totalShards
!=
null
&&
shardIndex
==
null
)
{
throwToolExit
(
'If you set --total-shards you need to also set --shard-index.'
);
}
if
(
shardIndex
!=
null
&&
totalShards
==
null
)
{
throwToolExit
(
'If you set --shard-index you need to also set --total-shards.'
);
}
final
bool
machine
=
boolArg
(
'machine'
);
CoverageCollector
collector
;
if
(
boolArg
(
'coverage'
)
||
boolArg
(
'merge-coverage'
))
{
...
...
@@ -314,6 +345,8 @@ class TestCommand extends FlutterCommand {
reporter:
stringArg
(
'reporter'
),
timeout:
stringArg
(
'timeout'
),
runSkipped:
boolArg
(
'run-skipped'
),
shardIndex:
shardIndex
,
totalShards:
totalShards
,
);
if
(
collector
!=
null
)
{
...
...
packages/flutter_tools/lib/src/test/runner.dart
View file @
739adf3d
...
...
@@ -51,6 +51,8 @@ abstract class FlutterTestRunner {
String
reporter
,
String
timeout
,
bool
runSkipped
=
false
,
int
shardIndex
,
int
totalShards
,
});
}
...
...
@@ -83,6 +85,8 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
String
reporter
,
String
timeout
,
bool
runSkipped
=
false
,
int
shardIndex
,
int
totalShards
,
})
async
{
// Configure package:test to use the Flutter engine for child processes.
final
String
shellPath
=
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
flutterTester
);
...
...
@@ -112,6 +116,10 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
...<
String
>[
'--exclude-tags'
,
excludeTags
],
if
(
runSkipped
)
'--run-skipped'
,
if
(
totalShards
!=
null
)
'--total-shards=
$totalShards
'
,
if
(
shardIndex
!=
null
)
'--shard-index=
$shardIndex
'
,
];
if
(
web
)
{
final
String
tempBuildDir
=
globals
.
fs
.
systemTempDirectory
...
...
packages/flutter_tools/test/commands.shard/hermetic/test_test.dart
View file @
739adf3d
...
...
@@ -59,6 +59,52 @@ void main() {
Cache:
()
=>
FakeCache
(),
});
group
(
'shard-index and total-shards'
,
()
{
testUsingContext
(
'with the params they are Piped to package:test'
,
()
async
{
final
FakePackageTest
fakePackageTest
=
FakePackageTest
();
final
TestCommand
testCommand
=
TestCommand
(
testWrapper:
fakePackageTest
);
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
testCommand
);
await
commandRunner
.
run
(
const
<
String
>[
'test'
,
'--total-shards=1'
,
'--shard-index=2'
,
'--no-pub'
,
]);
expect
(
fakePackageTest
.
lastArgs
,
contains
(
'--total-shards=1'
));
expect
(
fakePackageTest
.
lastArgs
,
contains
(
'--shard-index=2'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Cache:
()
=>
FakeCache
(),
});
testUsingContext
(
'without the params they not Piped to package:test'
,
()
async
{
final
FakePackageTest
fakePackageTest
=
FakePackageTest
();
final
TestCommand
testCommand
=
TestCommand
(
testWrapper:
fakePackageTest
);
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
testCommand
);
await
commandRunner
.
run
(
const
<
String
>[
'test'
,
'--no-pub'
,
]);
expect
(
fakePackageTest
.
lastArgs
,
isNot
(
contains
(
'--total-shards'
)));
expect
(
fakePackageTest
.
lastArgs
,
isNot
(
contains
(
'--shard-index'
)));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Cache:
()
=>
FakeCache
(),
});
});
testUsingContext
(
'Supports coverage and machine'
,
()
async
{
final
FakePackageTest
fakePackageTest
=
FakePackageTest
();
...
...
@@ -216,6 +262,8 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
String
reporter
,
String
timeout
,
bool
runSkipped
=
false
,
int
shardIndex
,
int
totalShards
,
})
async
{
lastEnableObservatoryValue
=
enableObservatory
;
return
exitCode
;
...
...
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