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
032f8cdb
Commit
032f8cdb
authored
Jul 09, 2018
by
Gary Miguel
Committed by
Chris Bracken
Jul 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use runTests in fuchsia tester. (#19178)
This allows us to collect code coverage for Fuchsia tests.
parent
7dd265ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
12 deletions
+42
-12
fuchsia_tester.dart
packages/flutter_tools/bin/fuchsia_tester.dart
+42
-12
No files found.
packages/flutter_tools/bin/fuchsia_tester.dart
View file @
032f8cdb
...
...
@@ -11,12 +11,12 @@ import 'package:flutter_tools/src/base/io.dart';
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/context_runner.dart'
;
import
'package:flutter_tools/src/dart/package_map.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/disabled_usage.dart'
;
import
'package:flutter_tools/src/globals.dart'
;
import
'package:flutter_tools/src/test/flutter_platform.dart'
as
loader
;
import
'package:flutter_tools/src/test/coverage_collector.dart'
;
import
'package:flutter_tools/src/test/runner.dart'
;
import
'package:flutter_tools/src/usage.dart'
;
import
'package:test/src/executable.dart'
as
test
;
// ignore: implementation_imports
// Note: this was largely inspired by lib/src/commands/test.dart.
...
...
@@ -28,6 +28,8 @@ const List<String> _kRequiredOptions = const <String>[
_kOptionShell
,
_kOptionTestDirectory
,
];
const
String
_kOptionCoverage
=
'coverage'
;
const
String
_kOptionCoveragePath
=
'coverage-path'
;
Future
<
Null
>
main
(
List
<
String
>
args
)
{
return
runInContext
<
Null
>(()
=>
run
(
args
),
overrides:
<
Type
,
dynamic
>{
...
...
@@ -47,12 +49,20 @@ Future<Null> run(List<String> args) async {
final
ArgParser
parser
=
new
ArgParser
()
..
addOption
(
_kOptionPackages
,
help:
'The .packages file'
)
..
addOption
(
_kOptionShell
,
help:
'The Flutter shell binary'
)
..
addOption
(
_kOptionTestDirectory
,
help:
'Directory containing the tests'
);
..
addOption
(
_kOptionTestDirectory
,
help:
'Directory containing the tests'
)
..
addFlag
(
_kOptionCoverage
,
defaultsTo:
false
,
negatable:
false
,
help:
'Whether to collect coverage information.'
,
)
..
addOption
(
_kOptionCoveragePath
,
defaultsTo:
'coverage/lcov.info'
,
help:
'Where to store coverage information (if coverage is enabled).'
,
);
final
ArgResults
argResults
=
parser
.
parse
(
args
);
if
(
_kRequiredOptions
.
any
((
String
option
)
=>
!
argResults
.
options
.
contains
(
option
)))
{
printError
(
'Missing option! All options must be specified.'
);
exit
(
1
);
throwToolExit
(
'Missing option! All options must be specified.'
);
}
final
Directory
tempDirectory
=
fs
.
systemTempDirectory
.
createTempSync
(
'fuchsia_tester'
);
...
...
@@ -70,16 +80,36 @@ Future<Null> run(List<String> args) async {
if
(!
fs
.
isFileSync
(
shellPath
))
{
throwToolExit
(
'Cannot find Flutter shell at
$shellPath
'
);
}
loader
.
installHook
(
shellPath:
shellPath
,
);
// Put the tester shell where runTests expects it.
// TODO(tvolkert,garymm): Switch to a Fuchsia-specific Artifacts impl.
final
Link
testerDestLink
=
fs
.
link
(
artifacts
.
getArtifactPath
(
Artifact
.
flutterTester
));
testerDestLink
.
parent
.
createSync
(
recursive:
true
);
testerDestLink
.
createSync
(
shellPath
);
PackageMap
.
globalPackagesPath
=
fs
.
path
.
normalize
(
fs
.
path
.
absolute
(
argResults
[
_kOptionPackages
]));
fs
.
currentDirectory
=
testDirectory
;
await
test
.
main
(
testArgs
);
exit
(
exitCode
);
CoverageCollector
collector
;
if
(
argResults
[
'coverage'
])
{
collector
=
new
CoverageCollector
();
}
exitCode
=
await
runTests
(
tests
,
workDir:
testDirectory
,
watcher:
collector
,
enableObservatory:
collector
!=
null
,
);
if
(
collector
!=
null
)
{
// collector expects currentDirectory to be the root of the dart
// package (i.e. contains lib/ and test/ sub-dirs).
fs
.
currentDirectory
=
testDirectory
.
parent
;
if
(!
await
collector
.
collectCoverageData
(
argResults
[
_kOptionCoveragePath
]))
throwToolExit
(
'Failed to collect coverage data'
);
}
}
finally
{
tempDirectory
.
deleteSync
(
recursive:
true
);
}
...
...
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