Move more of the tests in the engine to package:test (flutter/engine#55083)

Partial work towards https://github.com/flutter/flutter/issues/133569.
This commit is contained in:
Matan Lurey
2024-09-10 14:14:12 -07:00
committed by GitHub
parent f6915ab4ca
commit 64fbc93023
5 changed files with 44 additions and 33 deletions

View File

@@ -18,4 +18,4 @@ dependencies:
path: any
dev_dependencies:
litetest: any
test: any

View File

@@ -4,9 +4,9 @@
import 'dart:io';
import 'package:litetest/litetest.dart';
import 'package:metrics_center/metrics_center.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';
import '../bin/parse_and_send.dart' as pas;

View File

@@ -984,7 +984,7 @@ def build_dart_host_test_list(build_dir):
(os.path.join('flutter', 'testing', 'scenario_app'), []),
(
os.path.join('flutter', 'tools', 'api_check'),
[os.path.join(BUILDROOT_DIR, 'flutter')],
[],
),
(os.path.join('flutter', 'tools', 'build_bucket_golden_scraper'), []),
(os.path.join('flutter', 'tools', 'clang_tidy'), []),

View File

@@ -14,12 +14,8 @@ resolution: workspace
dependencies:
analyzer: any
_fe_analyzer_shared: any
pub_semver: any
dev_dependencies:
async_helper: any
expect: any
litetest: any
engine_repo_tools: any
path: any
smith: any
test: any

View File

@@ -2,21 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:apicheck/apicheck.dart';
import 'package:litetest/litetest.dart';
import 'package:engine_repo_tools/engine_repo_tools.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
void main(List<String> arguments) {
if (arguments.isEmpty) {
print('usage: dart bin/apicheck.dart path/to/engine/src/flutter');
exit(1);
}
final String flutterRoot = arguments[0];
void main() {
final String flutterRoot = Engine.findWithin().flutterDir.path;
checkApiConsistency(flutterRoot);
checkNativeApi(flutterRoot);
@@ -45,12 +39,14 @@ void checkApiConsistency(String flutterRoot) {
);
// C values: kFlutterAccessibilityFeatureFooBar = 1 << N,
final List<String> embedderEnumValues = getCppEnumValues(
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
sourcePath:
path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
enumName: 'FlutterAccessibilityFeature',
);
// C++ values: kFooBar = 1 << N,
final List<String> internalEnumValues = getCppEnumClassValues(
sourcePath: path.join(flutterRoot, 'lib','ui', 'window', 'platform_configuration.h'),
sourcePath: path.join(
flutterRoot, 'lib', 'ui', 'window', 'platform_configuration.h'),
enumName: 'AccessibilityFeatureFlag',
);
// Java values: FOO_BAR(1 << N).
@@ -72,17 +68,20 @@ void checkApiConsistency(String flutterRoot) {
className: 'SemanticsAction',
);
final List<String> webuiFields = getDartClassFields(
sourcePath: path.join(flutterRoot, 'lib', 'web_ui', 'lib', 'semantics.dart'),
sourcePath:
path.join(flutterRoot, 'lib', 'web_ui', 'lib', 'semantics.dart'),
className: 'SemanticsAction',
);
// C values: kFlutterSemanticsActionFooBar = 1 << N.
final List<String> embedderEnumValues = getCppEnumValues(
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
sourcePath:
path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
enumName: 'FlutterSemanticsAction',
);
// C++ values: kFooBar = 1 << N.
final List<String> internalEnumValues = getCppEnumClassValues(
sourcePath: path.join(flutterRoot, 'lib', 'ui', 'semantics', 'semantics_node.h'),
sourcePath:
path.join(flutterRoot, 'lib', 'ui', 'semantics', 'semantics_node.h'),
enumName: 'SemanticsAction',
);
// Java values: FOO_BAR(1 << N).
@@ -101,22 +100,34 @@ void checkApiConsistency(String flutterRoot) {
test('AppLifecycleState enums match', () {
// Dart values: _kFooBarIndex = 1 << N.
final List<String> uiFields = getDartClassFields(
sourcePath: path.join(flutterRoot, 'lib', 'ui', 'platform_dispatcher.dart'),
sourcePath:
path.join(flutterRoot, 'lib', 'ui', 'platform_dispatcher.dart'),
className: 'AppLifecycleState',
);
final List<String> webuiFields = getDartClassFields(
sourcePath: path.join(flutterRoot, 'lib', 'web_ui', 'lib', 'platform_dispatcher.dart'),
sourcePath: path.join(
flutterRoot, 'lib', 'web_ui', 'lib', 'platform_dispatcher.dart'),
className: 'AppLifecycleState',
);
// C++ values: kFooBar = 1 << N.
final List<String> internalEnumValues = getCppEnumClassValues(
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'common', 'app_lifecycle_state.h'),
sourcePath: path.join(
flutterRoot, 'shell', 'platform', 'common', 'app_lifecycle_state.h'),
enumName: 'AppLifecycleState',
);
// Java values: FOO_BAR(1 << N).
final List<String> javaEnumValues = getJavaEnumValues(
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'android', 'io',
'flutter', 'embedding', 'engine', 'systemchannels', 'LifecycleChannel.java'),
sourcePath: path.join(
flutterRoot,
'shell',
'platform',
'android',
'io',
'flutter',
'embedding',
'engine',
'systemchannels',
'LifecycleChannel.java'),
enumName: 'AppLifecycleState',
).map(allCapsToCamelCase).toList();
@@ -137,12 +148,14 @@ void checkApiConsistency(String flutterRoot) {
);
// C values: kFlutterSemanticsFlagFooBar = 1 << N.
final List<String> embedderEnumValues = getCppEnumValues(
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
sourcePath:
path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
enumName: 'FlutterSemanticsFlag',
);
// C++ values: kFooBar = 1 << N.
final List<String> internalEnumValues = getCppEnumClassValues(
sourcePath: path.join(flutterRoot, 'lib', 'ui', 'semantics', 'semantics_node.h'),
sourcePath:
path.join(flutterRoot, 'lib', 'ui', 'semantics', 'semantics_node.h'),
enumName: 'SemanticsFlags',
);
// Java values: FOO_BAR(1 << N).
@@ -185,7 +198,8 @@ class NativeFunctionVisitor extends RecursiveAstVisitor<void> {
@override
void visitNativeFunctionBody(NativeFunctionBody node) {
final MethodDeclaration? method = node.thisOrAncestorOfType<MethodDeclaration>();
final MethodDeclaration? method =
node.thisOrAncestorOfType<MethodDeclaration>();
if (method != null) {
if (method.parameters != null) {
check(method.toString(), method.parameters!);
@@ -193,7 +207,8 @@ class NativeFunctionVisitor extends RecursiveAstVisitor<void> {
return;
}
final FunctionDeclaration? func = node.thisOrAncestorOfType<FunctionDeclaration>();
final FunctionDeclaration? func =
node.thisOrAncestorOfType<FunctionDeclaration>();
if (func != null) {
final FunctionExpression funcExpr = func.functionExpression;
if (funcExpr.parameters != null) {