[tool] Only run unit tests in Chrome for inline web (#4153)

Currently we are running Dart unit tests in Chrome for any plugin with
web support, but it should only be necessary for plugins that have an
inline web implementation, not for app-facing packages that endorse a
web implementation.
This commit is contained in:
stuartmorgan
2023-06-08 10:38:03 -04:00
committed by GitHub
parent 1057ab48db
commit e13b8c4338
4 changed files with 27 additions and 12 deletions

View File

@ -11,20 +11,12 @@
# Unit tests for plugins that support web currently run in
# Chrome, which isn't currently supported by web infrastructure.
# TODO(ditman): Fix this in the repo tooling.
- camera
- camera_web
- file_selector
- file_selector_web
- google_maps_flutter
- google_maps_flutter_web
- google_sign_in
- google_sign_in_web
- image_picker
- image_picker_for_web
- shared_preferences
- shared_preferences_web
- url_launcher
- url_launcher_web
- video_player
- video_player_web
- webview_flutter_web

View File

@ -66,7 +66,9 @@ class TestCommand extends PackageLoopingCommand {
'--color',
if (experiment.isNotEmpty) '--enable-experiment=$experiment',
// TODO(ditman): Remove this once all plugins are migrated to 'drive'.
if (pluginSupportsPlatform(platformWeb, package)) '--platform=chrome',
if (pluginSupportsPlatform(platformWeb, package,
requiredMode: PlatformSupport.inline))
'--platform=chrome',
],
workingDir: package.directory,
);

View File

@ -15,7 +15,7 @@ import 'mocks.dart';
import 'util.dart';
void main() {
group('$TestCommand', () {
group('TestCommand', () {
late FileSystem fileSystem;
late Platform mockPlatform;
late Directory packagesDir;
@ -239,6 +239,27 @@ void main() {
);
});
test('Does not run on Chrome for web endorsements', () async {
final RepositoryPackage plugin = createFakePlugin(
'plugin',
packagesDir,
extraFiles: <String>['test/empty_test.dart'],
platformSupport: <String, PlatformDetails>{
platformWeb: const PlatformDetails(PlatformSupport.federated),
},
);
await runCapturingPrint(runner, <String>['test']);
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(getFlutterCommand(mockPlatform),
const <String>['test', '--color'], plugin.path),
]),
);
});
test('enable-experiment flag', () async {
final RepositoryPackage plugin = createFakePlugin('a', packagesDir,
extraFiles: <String>['test/empty_test.dart']);