Refactor framework coverage tests (#146210)

Refactor framework coverage tests in order to reduce testing logic in test.dart and allow for later implementing package:test onto the existing framework coverage tests

Part of https://github.com/flutter/flutter/issues/145482
This commit is contained in:
Jesse 2024-04-18 17:07:05 -04:00 committed by GitHub
parent 7610ceca42
commit f0fc419a6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 27 deletions

View File

@ -0,0 +1,33 @@
// 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 'dart:io' show File;
import 'package:path/path.dart' as path;
import '../utils.dart';
Future<void> frameworkCoverageRunner() async {
final File coverageFile = File(path.join(flutterRoot, 'packages', 'flutter', 'coverage', 'lcov.info'));
if (!coverageFile.existsSync()) {
foundError(<String>[
'${red}Coverage file not found.$reset',
'Expected to find: $cyan${coverageFile.absolute.path}$reset',
'This file is normally obtained by running `${green}flutter update-packages$reset`.',
]);
return;
}
coverageFile.deleteSync();
await runFlutterTest(path.join(flutterRoot, 'packages', 'flutter'),
options: const <String>['--coverage'],
);
if (!coverageFile.existsSync()) {
foundError(<String>[
'${red}Coverage file not found.$reset',
'Expected to find: $cyan${coverageFile.absolute.path}$reset',
'This file should have been generated by the `${green}flutter test --coverage$reset` script, but was not.',
]);
return;
}
}

View File

@ -64,6 +64,7 @@ import 'suite_runners/run_analyze_tests.dart';
import 'suite_runners/run_customer_testing_tests.dart';
import 'suite_runners/run_docs_tests.dart';
import 'suite_runners/run_flutter_packages_tests.dart';
import 'suite_runners/run_framework_coverage_tests.dart';
import 'suite_runners/run_fuchsia_precache.dart';
import 'suite_runners/run_realm_checker_tests.dart';
import 'suite_runners/run_skp_generator_tests.dart';
@ -139,7 +140,7 @@ Future<void> main(List<String> args) async {
await selectShard(<String, ShardRunner>{
'add_to_app_life_cycle_tests': () => addToAppLifeCycleRunner(flutterRoot),
'build_tests': _runBuildTests,
'framework_coverage': _runFrameworkCoverage,
'framework_coverage': frameworkCoverageRunner,
'framework_tests': _runFrameworkTests,
'tool_tests': _runToolTests,
// web_tool_tests is also used by HHH: https://dart.googlesource.com/recipes/+/refs/heads/master/recipes/dart/flutter_engine.py
@ -988,31 +989,6 @@ Future<void> _runFrameworkTests() async {
});
}
Future<void> _runFrameworkCoverage() async {
final File coverageFile = File(path.join(flutterRoot, 'packages', 'flutter', 'coverage', 'lcov.info'));
if (!coverageFile.existsSync()) {
foundError(<String>[
'${red}Coverage file not found.$reset',
'Expected to find: $cyan${coverageFile.absolute.path}$reset',
'This file is normally obtained by running `${green}flutter update-packages$reset`.',
]);
return;
}
coverageFile.deleteSync();
await runFlutterTest(path.join(flutterRoot, 'packages', 'flutter'),
options: const <String>['--coverage'],
);
if (!coverageFile.existsSync()) {
foundError(<String>[
'${red}Coverage file not found.$reset',
'Expected to find: $cyan${coverageFile.absolute.path}$reset',
'This file should have been generated by the `${green}flutter test --coverage$reset` script, but was not.',
]);
return;
}
}
/// This will force the next run of the Flutter tool (if it uses the provided
/// environment) to have asserts enabled, by setting an environment variable.
void adjustEnvironmentToEnableFlutterAsserts(Map<String, String> environment) {

View File

@ -29,7 +29,6 @@ typedef ShardRunner = Future<void> Function();
/// appropriate error message.
typedef OutputChecker = String? Function(CommandResult);
const Duration _quietTimeout = Duration(minutes: 10); // how long the output should be hidden between calls to printProgress before just being verbose
// If running from LUCI set to False.