Run coverage in a dedicated shard on Travis (#10755)
This commit is contained in:
parent
615410d2d2
commit
bd67926f84
@ -17,6 +17,7 @@ install:
|
|||||||
env:
|
env:
|
||||||
- SHARD=analyze
|
- SHARD=analyze
|
||||||
- SHARD=tests
|
- SHARD=tests
|
||||||
|
- SHARD=coverage
|
||||||
- SHARD=docs
|
- SHARD=docs
|
||||||
before_script:
|
before_script:
|
||||||
- ./dev/bots/travis_setup.sh
|
- ./dev/bots/travis_setup.sh
|
||||||
|
@ -8,6 +8,8 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
|
typedef Future<Null> ShardRunner();
|
||||||
|
|
||||||
final String flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));
|
final String flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));
|
||||||
final String flutter = path.join(flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');
|
final String flutter = path.join(flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');
|
||||||
final String dart = path.join(flutterRoot, 'bin', 'cache', 'dart-sdk', 'bin', Platform.isWindows ? 'dart.exe' : 'dart');
|
final String dart = path.join(flutterRoot, 'bin', 'cache', 'dart-sdk', 'bin', Platform.isWindows ? 'dart.exe' : 'dart');
|
||||||
@ -22,6 +24,13 @@ final String yellow = hasColor ? '\x1B[33m' : '';
|
|||||||
final String cyan = hasColor ? '\x1B[36m' : '';
|
final String cyan = hasColor ? '\x1B[36m' : '';
|
||||||
final String reset = hasColor ? '\x1B[0m' : '';
|
final String reset = hasColor ? '\x1B[0m' : '';
|
||||||
|
|
||||||
|
const Map<String, ShardRunner> _kShards = const <String, ShardRunner>{
|
||||||
|
'docs': _generateDocs,
|
||||||
|
'analyze': _analyzeRepo,
|
||||||
|
'tests': _runTests,
|
||||||
|
'coverage': _runCoverage,
|
||||||
|
};
|
||||||
|
|
||||||
/// When you call this, you can set FLUTTER_TEST_ARGS to pass custom
|
/// When you call this, you can set FLUTTER_TEST_ARGS to pass custom
|
||||||
/// arguments to flutter test. For example, you might want to call this
|
/// arguments to flutter test. For example, you might want to call this
|
||||||
/// script using FLUTTER_TEST_ARGS=--local-engine=host_debug_unopt to
|
/// script using FLUTTER_TEST_ARGS=--local-engine=host_debug_unopt to
|
||||||
@ -33,9 +42,17 @@ final String reset = hasColor ? '\x1B[0m' : '';
|
|||||||
/// SHARD=analyze bin/cache/dart-sdk/bin/dart dev/bots/test.dart
|
/// SHARD=analyze bin/cache/dart-sdk/bin/dart dev/bots/test.dart
|
||||||
/// FLUTTER_TEST_ARGS=--local-engine=host_debug_unopt bin/cache/dart-sdk/bin/dart dev/bots/test.dart
|
/// FLUTTER_TEST_ARGS=--local-engine=host_debug_unopt bin/cache/dart-sdk/bin/dart dev/bots/test.dart
|
||||||
Future<Null> main() async {
|
Future<Null> main() async {
|
||||||
if (Platform.environment['SHARD'] == 'docs') {
|
final String shard = Platform.environment['SHARD'] ?? 'tests';
|
||||||
|
if (!_kShards.containsKey(shard))
|
||||||
|
throw new ArgumentError('Invalid shard: $shard');
|
||||||
|
await _kShards[shard]();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Null> _generateDocs() async {
|
||||||
print('${bold}DONE: test.dart does nothing in the docs shard.$reset');
|
print('${bold}DONE: test.dart does nothing in the docs shard.$reset');
|
||||||
} else if (Platform.environment['SHARD'] == 'analyze') {
|
}
|
||||||
|
|
||||||
|
Future<Null> _analyzeRepo() async {
|
||||||
// Analyze all the Dart code in the repo.
|
// Analyze all the Dart code in the repo.
|
||||||
await _runFlutterAnalyze(flutterRoot,
|
await _runFlutterAnalyze(flutterRoot,
|
||||||
options: <String>['--flutter-repo'],
|
options: <String>['--flutter-repo'],
|
||||||
@ -61,7 +78,9 @@ Future<Null> main() async {
|
|||||||
);
|
);
|
||||||
|
|
||||||
print('${bold}DONE: Analysis successful.$reset');
|
print('${bold}DONE: Analysis successful.$reset');
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
Future<Null> _runTests() async {
|
||||||
// Verify that the tests actually return failure on failure and success on success.
|
// Verify that the tests actually return failure on failure and success on success.
|
||||||
final String automatedTests = path.join(flutterRoot, 'dev', 'automated_tests');
|
final String automatedTests = path.join(flutterRoot, 'dev', 'automated_tests');
|
||||||
await _runFlutterTest(automatedTests,
|
await _runFlutterTest(automatedTests,
|
||||||
@ -99,14 +118,8 @@ Future<Null> main() async {
|
|||||||
printOutput: false,
|
printOutput: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
final List<String> coverageFlags = <String>[];
|
|
||||||
if (Platform.environment['TRAVIS'] != null && Platform.environment['TRAVIS_PULL_REQUEST'] == 'false')
|
|
||||||
coverageFlags.add('--coverage');
|
|
||||||
|
|
||||||
// Run tests.
|
// Run tests.
|
||||||
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter'),
|
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter'));
|
||||||
options: coverageFlags,
|
|
||||||
);
|
|
||||||
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_driver'));
|
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_driver'));
|
||||||
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_test'));
|
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_test'));
|
||||||
await _pubRunTest(path.join(flutterRoot, 'packages', 'flutter_tools'));
|
await _pubRunTest(path.join(flutterRoot, 'packages', 'flutter_tools'));
|
||||||
@ -121,6 +134,19 @@ Future<Null> main() async {
|
|||||||
|
|
||||||
print('${bold}DONE: All tests successful.$reset');
|
print('${bold}DONE: All tests successful.$reset');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Null> _runCoverage() async {
|
||||||
|
if (Platform.environment['TRAVIS'] == null ||
|
||||||
|
Platform.environment['TRAVIS_PULL_REQUEST'] != 'false') {
|
||||||
|
print('${bold}DONE: test.dart does not run coverage for Travis pull requests');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter'),
|
||||||
|
options: const <String>['--coverage'],
|
||||||
|
);
|
||||||
|
|
||||||
|
print('${bold}DONE: Coverage collection successful.$reset');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Null> _pubRunTest(
|
Future<Null> _pubRunTest(
|
||||||
|
@ -6,7 +6,7 @@ export PATH="$PWD/bin:$PWD/bin/cache/dart-sdk/bin:$PATH"
|
|||||||
|
|
||||||
LCOV_FILE=./packages/flutter/coverage/lcov.info
|
LCOV_FILE=./packages/flutter/coverage/lcov.info
|
||||||
|
|
||||||
if [ "$SHARD" = "tests" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ] && [ -f "$LCOV_FILE" ]; then
|
if [ "$SHARD" = "coverage" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ] && [ -f "$LCOV_FILE" ]; then
|
||||||
GSUTIL=$HOME/google-cloud-sdk/bin/gsutil
|
GSUTIL=$HOME/google-cloud-sdk/bin/gsutil
|
||||||
GCLOUD=$HOME/google-cloud-sdk/bin/gcloud
|
GCLOUD=$HOME/google-cloud-sdk/bin/gcloud
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user