Unverified Commit ef6c720d authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_test] handle breaking change to test main (#67425)

* [flutter_test] handle breaking change to test main . Fixes #67382
parent 8d923bf9
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
export 'package:flutter_goldens/flutter_goldens.dart' show main; export 'package:flutter_goldens/flutter_goldens.dart' show testExecutable;
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
export 'package:flutter_goldens/flutter_goldens.dart' show main; export 'package:flutter_goldens/flutter_goldens.dart' show testExecutable;
...@@ -27,7 +27,7 @@ const String _kFlutterRootKey = 'FLUTTER_ROOT'; ...@@ -27,7 +27,7 @@ const String _kFlutterRootKey = 'FLUTTER_ROOT';
/// [goldenFileComparator] to an instance of [FlutterGoldenFileComparator] that /// [goldenFileComparator] to an instance of [FlutterGoldenFileComparator] that
/// works for the current test. _Which_ FlutterGoldenFileComparator is /// works for the current test. _Which_ FlutterGoldenFileComparator is
/// instantiated is based on the current testing environment. /// instantiated is based on the current testing environment.
Future<void> main(FutureOr<void> testMain()) async { Future<void> testExecutable(FutureOr<void> testMain()) async {
const Platform platform = LocalPlatform(); const Platform platform = LocalPlatform();
if (FlutterPostSubmitFileComparator.isAvailableForEnvironment(platform)) { if (FlutterPostSubmitFileComparator.isAvailableForEnvironment(platform)) {
goldenFileComparator = await FlutterPostSubmitFileComparator.fromDefaultComparator(platform); goldenFileComparator = await FlutterPostSubmitFileComparator.fromDefaultComparator(platform);
......
...@@ -7,7 +7,7 @@ import 'dart:async'; ...@@ -7,7 +7,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
Future<void> main(FutureOr<void> testMain()) async { Future<void> testExecutable(FutureOr<void> testMain()) async {
reportTestException = (FlutterErrorDetails details, String testDescription) { reportTestException = (FlutterErrorDetails details, String testDescription) {
expect(details.exception, isA<StateError>()); expect(details.exception, isA<StateError>());
expect((details.exception as StateError).message, 'foo'); expect((details.exception as StateError).message, 'foo');
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import 'dart:async'; import 'dart:async';
Future<void> main(FutureOr<void> testMain()) async { Future<void> testExecutable(FutureOr<void> testMain()) async {
await runZoned<dynamic>(testMain, zoneValues: <Type, String>{ await runZoned<dynamic>(testMain, zoneValues: <Type, String>{
String: '/test_config', String: '/test_config',
}); });
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import 'dart:async'; import 'dart:async';
Future<void> main(FutureOr<void> testMain()) async { Future<void> testExecutable(FutureOr<void> testMain()) async {
await runZoned<dynamic>(testMain, zoneValues: <Type, dynamic>{ await runZoned<dynamic>(testMain, zoneValues: <Type, dynamic>{
String: '/test_config/nested_config', String: '/test_config/nested_config',
int: 123, int: 123,
......
...@@ -197,7 +197,7 @@ void main() { ...@@ -197,7 +197,7 @@ void main() {
'''); ''');
if (testConfigFile != null) { if (testConfigFile != null) {
buffer.write(''' buffer.write('''
return () => test_config.main(test.main); return () => test_config.testExecutable(test.main);
'''); ''');
} else { } else {
buffer.write(''' buffer.write('''
......
...@@ -956,7 +956,7 @@ void main() async { ...@@ -956,7 +956,7 @@ void main() async {
LocalFileComparator comparator = LocalFileComparator(Uri.parse('$testUri')); LocalFileComparator comparator = LocalFileComparator(Uri.parse('$testUri'));
goldenFileComparator = comparator; goldenFileComparator = comparator;
${testConfigFile != null ? 'test_config.main(() async {' : ''} ${testConfigFile != null ? 'test_config.testExecutable(() async {' : ''}
final commands = stdin final commands = stdin
.transform<String>(utf8.decoder) .transform<String>(utf8.decoder)
.transform<String>(const LineSplitter()) .transform<String>(const LineSplitter())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment