Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Skip non-web plugins on web
  • Loading branch information
stuartmorgan-g committed Jun 30, 2023
commit 906fb7bfa3256bfd76cb9409d9e9efbfe21a6c85
12 changes: 12 additions & 0 deletions script/tool/lib/src/dart_test_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:platform/platform.dart';

import 'common/core.dart';
import 'common/package_looping_command.dart';
import 'common/plugin_utils.dart';
import 'common/process_runner.dart';
import 'common/repository_package.dart';

Expand Down Expand Up @@ -59,6 +60,17 @@ class DartTestCommand extends PackageLoopingCommand {
return PackageResult.skip('No test/ directory.');
}

// Skip running plugin tests for non-web-supporting plugins (or non-web
// federated plugin implementations) on web, since there's no reason to
// expect them to work.
final bool webPlatform = getStringArg(_platformFlag).isNotEmpty &&
getStringArg(_platformFlag) != 'vm';
if (webPlatform &&
isFlutterPlugin(package) &&
!pluginSupportsPlatform(platformWeb, package)) {
return PackageResult.skip("Non-web plugin tests don't need web testing.");
}

bool passed;
if (package.requiresFlutter()) {
passed = await _runFlutterTests(package);
Expand Down
69 changes: 69 additions & 0 deletions script/tool/test/dart_test_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,29 @@ void main() {
});

test('runs in Chrome when requested for Flutter package', () async {
final RepositoryPackage package = createFakePackage(
'a_package',
packagesDir,
isFlutter: true,
extraFiles: <String>['test/empty_test.dart'],
);

await runCapturingPrint(
runner, <String>['dart-test', '--platform=chrome']);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>['test', '--color', '--platform=chrome'],
package.path),
]),
);
});

test('runs in Chrome when requested for Flutter plugin that implement web',
() async {
final RepositoryPackage plugin = createFakePlugin(
'plugin',
packagesDir,
Expand All @@ -255,6 +278,52 @@ void main() {
);
});

test('runs in Chrome when requested for Flutter plugin that endorse web',
() 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>['dart-test', '--platform=chrome']);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>['test', '--color', '--platform=chrome'],
plugin.path),
]),
);
});

test('skips running non-web-plugins in browser mode', () async {
createFakePlugin(
'non_web_plugin',
packagesDir,
extraFiles: <String>['test/empty_test.dart'],
);

final List<String> output = await runCapturingPrint(
runner, <String>['dart-test', '--platform=chrome']);

expect(
output,
containsAllInOrder(<Matcher>[
contains("Non-web plugin tests don't need web testing."),
]));
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[]),
);
});

test('runs in Chrome when requested for Dart package', () async {
final RepositoryPackage package = createFakePackage(
'package',
Expand Down