Fix line-dependent tests for formatting (#160389)

These tests are dependent on line numbers. This formats them and updates
the line number to take them off the critical path.
This commit is contained in:
Michael Goderbauer 2024-12-16 16:29:51 -08:00 committed by GitHub
parent 43ee8029c9
commit e19e117c37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2767 additions and 2821 deletions

View File

@ -25,7 +25,8 @@ void _tests() {
}); });
Future<void> pumpTestWidget(WidgetTester tester) async { Future<void> pumpTestWidget(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(
MaterialApp(
home: ListView( home: ListView(
children: <Widget>[ children: <Widget>[
const Text('Plain text'), const Text('Plain text'),
@ -43,7 +44,8 @@ void _tests() {
), ),
], ],
), ),
)); ),
);
} }
// This test generates code using generateTestSemanticsExpressionForCurrentSemanticsTree // This test generates code using generateTestSemanticsExpressionForCurrentSemanticsTree
@ -55,8 +57,11 @@ void _tests() {
testWidgets('generates code', (WidgetTester tester) async { testWidgets('generates code', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await pumpTestWidget(tester); await pumpTestWidget(tester);
final String code = semantics final String code =
.generateTestSemanticsExpressionForCurrentSemanticsTree(DebugSemanticsDumpOrder.inverseHitTest) semantics
.generateTestSemanticsExpressionForCurrentSemanticsTree(
DebugSemanticsDumpOrder.inverseHitTest,
)
.split('\n') .split('\n')
.map<String>((String line) => line.trim()) .map<String>((String line) => line.trim())
.join('\n') .join('\n')
@ -69,7 +74,10 @@ void _tests() {
if (childSearch != null) { if (childSearch != null) {
return childSearch; return childSearch;
} }
} else if (entity is File && entity.path.endsWith('semantics_tester_generate_test_semantics_expression_for_current_semantics_tree_test.dart')) { } else if (entity is File &&
entity.path.endsWith(
'semantics_tester_generate_test_semantics_expression_for_current_semantics_tree_test.dart',
)) {
return entity; return entity;
} }
} }
@ -79,10 +87,9 @@ void _tests() {
final File thisTestFile = findThisTestFile(Directory.current)!; final File thisTestFile = findThisTestFile(Directory.current)!;
expect(thisTestFile, isNotNull); expect(thisTestFile, isNotNull);
String expectedCode = thisTestFile.readAsStringSync(); String expectedCode = thisTestFile.readAsStringSync();
expectedCode = expectedCode.substring( expectedCode =
expectedCode.indexOf('v' * 12) + 12, expectedCode
expectedCode.indexOf('^' * 12) - 3, .substring(expectedCode.indexOf('v' * 12) + 12, expectedCode.indexOf('^' * 12) - 3)
)
.split('\n') .split('\n')
.map<String>((String line) => line.trim()) .map<String>((String line) => line.trim())
.join('\n') .join('\n')
@ -102,6 +109,7 @@ void _tests() {
// You must update it when changing the output generated by // You must update it when changing the output generated by
// generateTestSemanticsExpressionForCurrentSemanticsTree. Otherwise, // generateTestSemanticsExpressionForCurrentSemanticsTree. Otherwise,
// the test 'generates code', defined above, will fail. // the test 'generates code', defined above, will fail.
// dart format off
// vvvvvvvvvvvv // vvvvvvvvvvvv
TestSemantics.root( TestSemantics.root(
children: <TestSemantics>[ children: <TestSemantics>[
@ -154,6 +162,7 @@ void _tests() {
], ],
), ),
// ^^^^^^^^^^^^ // ^^^^^^^^^^^^
// dart format on
ignoreRect: true, ignoreRect: true,
ignoreTransform: true, ignoreTransform: true,
ignoreId: true, ignoreId: true,

File diff suppressed because it is too large Load Diff