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
33ad5bac
Unverified
Commit
33ad5bac
authored
Jun 26, 2019
by
Jonah Williams
Committed by
GitHub
Jun 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempt to enable tool coverage redux (#35074)
parent
206d43de
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
273 additions
and
136 deletions
+273
-136
.cirrus.yml
.cirrus.yml
+13
-0
test.dart
dev/bots/test.dart
+54
-0
coverage_collector.dart
packages/flutter_tools/lib/src/test/coverage_collector.dart
+26
-1
create_test.dart
packages/flutter_tools/test/commands/create_test.dart
+2
-1
daemon_mode_test.dart
...ages/flutter_tools/test/integration/daemon_mode_test.dart
+5
-0
debugger_stepping_test.dart
...lutter_tools/test/integration/debugger_stepping_test.dart
+5
-0
expression_evaluation_test.dart
...er_tools/test/integration/expression_evaluation_test.dart
+5
-0
flutter_attach_test.dart
...s/flutter_tools/test/integration/flutter_attach_test.dart
+5
-0
flutter_run_test.dart
...ages/flutter_tools/test/integration/flutter_run_test.dart
+5
-0
hot_reload_test.dart
packages/flutter_tools/test/integration/hot_reload_test.dart
+5
-0
lifetime_test.dart
packages/flutter_tools/test/integration/lifetime_test.dart
+5
-0
common.dart
packages/flutter_tools/test/src/common.dart
+1
-1
tool_coverage.dart
packages/flutter_tools/tool/tool_coverage.dart
+142
-133
No files found.
.cirrus.yml
View file @
33ad5bac
...
...
@@ -120,6 +120,19 @@ task:
container
:
cpu
:
4
memory
:
12G
-
name
:
tool_coverage-linux
# Only re-run tool coverage if the package itself changed.
skip
:
"
!changesInclude('./packages/flutter_tools/**/*',
'.cirrus.yml',
'./dev/bots/test.dart')"
env
:
GCLOUD_SERVICE_ACCOUNT_KEY
:
ENCRYPTED[f12abe60f5045d619ef4c79b83dd1e0722a0b0b13dbea95fbe334e2db7fffbcd841a5a92da8824848b539a19afe0c9fb]
CODECOV_TOKEN
:
ENCRYPTED[7c76a7f8c9264f3b7f3fd63fcf186f93c62c4dfe43ec288861c2f506d456681032b89efe7b7a139c82156350ca2c752c]
SHARD
:
tool_coverage
test_script
:
-
dart --enable-asserts ./dev/bots/test.dart
-
bash <(curl -s https://codecov.io/bash) -c -s ./packages/flutter_tools/coverage/ -f '*.lcov.info' -F flutter_tool
container
:
cpu
:
8
memory
:
24G
-
name
:
web_tests-linux
# TODO(jonahwilliams): re-enabled once we've determined causes for flakiness
allow_failures
:
true
...
...
dev/bots/test.dart
View file @
33ad5bac
...
...
@@ -20,6 +20,7 @@ final String flutter = path.join(flutterRoot, 'bin', Platform.isWindows ? 'flutt
final
String
dart
=
path
.
join
(
flutterRoot
,
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
Platform
.
isWindows
?
'dart.exe'
:
'dart'
);
final
String
pub
=
path
.
join
(
flutterRoot
,
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
Platform
.
isWindows
?
'pub.bat'
:
'pub'
);
final
String
pubCache
=
path
.
join
(
flutterRoot
,
'.pub-cache'
);
final
String
toolRoot
=
path
.
join
(
flutterRoot
,
'packages'
,
'flutter_tools'
);
final
List
<
String
>
flutterTestArgs
=
<
String
>[];
final
bool
useFlutterTestFormatter
=
Platform
.
environment
[
'FLUTTER_TEST_FORMATTER'
]
==
'true'
;
...
...
@@ -30,6 +31,7 @@ const Map<String, ShardRunner> _kShards = <String, ShardRunner>{
'tests'
:
_runTests
,
'web_tests'
:
_runWebTests
,
'tool_tests'
:
_runToolTests
,
'tool_coverage'
:
_runToolCoverage
,
'build_tests'
:
_runBuildTests
,
'coverage'
:
_runCoverage
,
'integration_tests'
:
_runIntegrationTests
,
...
...
@@ -176,6 +178,58 @@ Future<bq.BigqueryApi> _getBigqueryApi() async {
}
}
// Partition tool tests into two groups, see explanation on `_runToolCoverage`.
List
<
List
<
String
>>
_partitionToolTests
()
{
final
List
<
String
>
pending
=
<
String
>[];
final
String
toolTestDir
=
path
.
join
(
toolRoot
,
'test'
);
for
(
FileSystemEntity
entity
in
Directory
(
toolTestDir
).
listSync
(
recursive:
true
))
{
if
(
entity
is
File
&&
entity
.
path
.
endsWith
(
'_test.dart'
))
{
final
String
relativePath
=
path
.
relative
(
entity
.
path
,
from:
toolRoot
);
pending
.
add
(
relativePath
);
}
}
// Shuffle the tests to avoid giving an expensive test directory like
// integration to a single run of tests.
pending
..
shuffle
();
final
int
aboutHalf
=
pending
.
length
~/
2
;
final
List
<
String
>
groupA
=
pending
.
take
(
aboutHalf
).
toList
();
final
List
<
String
>
groupB
=
pending
.
skip
(
aboutHalf
).
toList
();
return
<
List
<
String
>>[
groupA
,
groupB
];
}
// Tools tests run with coverage enabled have much higher memory usage than
// our current CI infrastructure can support. We partition the tests into
// two sets and run them in separate invocations of dart to reduce peak memory
// usage. codecov.io automatically handles merging different coverage files
// together, so producing separate files is OK.
//
// See: https://github.com/flutter/flutter/issues/35025
Future
<
void
>
_runToolCoverage
()
async
{
final
List
<
List
<
String
>>
tests
=
_partitionToolTests
();
// Precompile tests to speed up subsequent runs.
await
runCommand
(
pub
,
<
String
>[
'run'
,
'build_runner'
,
'build'
],
workingDirectory:
toolRoot
,
);
// The name of this subshard has to match the --file path provided at
// the end of this test script in `.cirrus.yml`.
const
List
<
String
>
subshards
=
<
String
>[
'A'
,
'B'
];
for
(
int
i
=
0
;
i
<
tests
.
length
;
i
++)
{
final
List
<
String
>
testGroup
=
tests
[
i
];
await
runCommand
(
dart
,
<
String
>[
path
.
join
(
'tool'
,
'tool_coverage.dart'
),
'--'
]..
addAll
(
testGroup
),
workingDirectory:
toolRoot
,
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
flutterRoot
,
'SUBSHARD'
:
subshards
[
i
],
}
);
}
}
Future
<
void
>
_runToolTests
()
async
{
final
bq
.
BigqueryApi
bigqueryApi
=
await
_getBigqueryApi
();
await
_runSmokeTests
();
...
...
packages/flutter_tools/lib/src/test/coverage_collector.dart
View file @
33ad5bac
...
...
@@ -41,6 +41,32 @@ class CoverageCollector extends TestWatcher {
}
}
/// Collects coverage for an isolate using the given `port`.
///
/// This should be called when the code whose coverage data is being collected
/// has been run to completion so that all coverage data has been recorded.
///
/// The returned [Future] completes when the coverage is collected.
Future
<
void
>
collectCoverageIsolate
(
Uri
observatoryUri
)
async
{
assert
(
observatoryUri
!=
null
);
printTrace
(
'collecting coverage data from
$observatoryUri
...'
);
final
Map
<
String
,
dynamic
>
data
=
await
collect
(
observatoryUri
,
(
String
libraryName
)
{
// If we have a specified coverage directory or could not find the package name, then
// accept all libraries.
return
(
coverageDirectory
!=
null
)
||
(
flutterProject
==
null
)
||
libraryName
.
contains
(
flutterProject
.
manifest
.
appName
);
});
if
(
data
==
null
)
{
throw
Exception
(
'Failed to collect coverage.'
);
}
assert
(
data
!=
null
);
print
(
'(
$observatoryUri
): collected coverage data; merging...'
);
_addHitmap
(
coverage
.
createHitmap
(
data
[
'coverage'
]));
print
(
'(
$observatoryUri
): done merging coverage data into global coverage map.'
);
}
/// Collects coverage for the given [Process] using the given `port`.
///
/// This should be called when the code whose coverage data is being collected
...
...
@@ -91,7 +117,6 @@ class CoverageCollector extends TestWatcher {
coverage
.
Formatter
formatter
,
Directory
coverageDirectory
,
})
async
{
printTrace
(
'formating coverage data'
);
if
(
_globalHitmap
==
null
)
{
return
null
;
}
...
...
packages/flutter_tools/test/commands/create_test.dart
View file @
33ad5bac
...
...
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@Tags
(<
String
>[
'create'
])
// This test performs too poorly to run with coverage enabled.
@Tags
(<
String
>[
'create'
,
'no_coverage'
])
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:typed_data'
;
...
...
packages/flutter_tools/test/integration/daemon_mode_test.dart
View file @
33ad5bac
...
...
@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Integration tests which invoke flutter instead of unit testing the code
// will not produce meaningful coverage information - we can measure coverage
// from the isolate running the test, but not from the isolate started via
// the command line process.
@Tags
(<
String
>[
'no_coverage'
])
import
'dart:async'
;
import
'dart:convert'
;
...
...
packages/flutter_tools/test/integration/debugger_stepping_test.dart
View file @
33ad5bac
...
...
@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Integration tests which invoke flutter instead of unit testing the code
// will not produce meaningful coverage information - we can measure coverage
// from the isolate running the test, but not from the isolate started via
// the command line process.
@Tags
(<
String
>[
'no_coverage'
])
import
'package:file/file.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
...
...
packages/flutter_tools/test/integration/expression_evaluation_test.dart
View file @
33ad5bac
...
...
@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Integration tests which invoke flutter instead of unit testing the code
// will not produce meaningful coverage information - we can measure coverage
// from the isolate running the test, but not from the isolate started via
// the command line process.
@Tags
(<
String
>[
'no_coverage'
])
import
'dart:async'
;
import
'package:file/file.dart'
;
...
...
packages/flutter_tools/test/integration/flutter_attach_test.dart
View file @
33ad5bac
...
...
@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Integration tests which invoke flutter instead of unit testing the code
// will not produce meaningful coverage information - we can measure coverage
// from the isolate running the test, but not from the isolate started via
// the command line process.
@Tags
(<
String
>[
'no_coverage'
])
import
'package:file/file.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
...
...
packages/flutter_tools/test/integration/flutter_run_test.dart
View file @
33ad5bac
...
...
@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Integration tests which invoke flutter instead of unit testing the code
// will not produce meaningful coverage information - we can measure coverage
// from the isolate running the test, but not from the isolate started via
// the command line process.
@Tags
(<
String
>[
'no_coverage'
])
import
'package:file/file.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
...
...
packages/flutter_tools/test/integration/hot_reload_test.dart
View file @
33ad5bac
...
...
@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Integration tests which invoke flutter instead of unit testing the code
// will not produce meaningful coverage information - we can measure coverage
// from the isolate running the test, but not from the isolate started via
// the command line process.
@Tags
(<
String
>[
'no_coverage'
])
import
'dart:async'
;
import
'package:file/file.dart'
;
...
...
packages/flutter_tools/test/integration/lifetime_test.dart
View file @
33ad5bac
...
...
@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Integration tests which invoke flutter instead of unit testing the code
// will not produce meaningful coverage information - we can measure coverage
// from the isolate running the test, but not from the isolate started via
// the command line process.
@Tags
(<
String
>[
'no_coverage'
])
import
'dart:async'
;
import
'package:file/file.dart'
;
...
...
packages/flutter_tools/test/src/common.dart
View file @
33ad5bac
...
...
@@ -18,7 +18,7 @@ import 'package:flutter_tools/src/commands/create.dart';
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'package:flutter_tools/src/runner/flutter_command_runner.dart'
;
export
'package:test_
api/test_api
.dart'
hide
TypeMatcher
,
isInstanceOf
;
// Defines a 'package:test' shim.
export
'package:test_
core/test_core
.dart'
hide
TypeMatcher
,
isInstanceOf
;
// Defines a 'package:test' shim.
/// Disable both web and desktop to make testing easier. For example, prevent
/// them from showing up in the devices list if the host happens to be setup
...
...
packages/flutter_tools/tool/tool_coverage.dart
View file @
33ad5bac
This diff is collapsed.
Click to expand it.
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