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
Temporarily repurpose the main unit tests for CI run
  • Loading branch information
stuartmorgan-g committed Jun 30, 2023
commit 26326e475943b999cb74e18f77f5416368ff5a58
34 changes: 10 additions & 24 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,43 +96,29 @@ targets:
recipe: packages/packages
timeout: 60
properties:
add_recipes_cq: "true"
target_file: dart_unit_tests.yaml
target_file: web_dart_unit_tests.yaml
channel: master
version_file: flutter_master.version
cores: "32"
package_sharding: "--shardIndex 0 --shardCount 2"
dependencies: >-
[
{"dependency": "chrome_and_driver", "version": "version:114.0"}
]

- name: Linux dart_unit_test_shard_2 master
recipe: packages/packages
timeout: 60
properties:
add_recipes_cq: "true"
target_file: dart_unit_tests.yaml
target_file: web_dart_unit_tests.yaml
channel: master
version_file: flutter_master.version
cores: "32"
package_sharding: "--shardIndex 1 --shardCount 2"

- name: Linux dart_unit_test_shard_1 stable
recipe: packages/packages
timeout: 60
properties:
target_file: dart_unit_tests.yaml
channel: stable
version_file: flutter_stable.version
cores: "32"
package_sharding: "--shardIndex 0 --shardCount 2"

- name: Linux dart_unit_test_shard_2 stable
recipe: packages/packages
timeout: 60
properties:
target_file: dart_unit_tests.yaml
channel: stable
version_file: flutter_stable.version
cores: "32"
package_sharding: "--shardIndex 1 --shardCount 2"
dependencies: >-
[
{"dependency": "chrome_and_driver", "version": "version:114.0"}
]

- name: Linux analyze master
recipe: packages/packages
Expand Down
17 changes: 12 additions & 5 deletions script/tool/lib/src/dart_test_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ 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 All @@ -27,8 +26,16 @@ class DartTestCommand extends PackageLoopingCommand {
'See https://github.com/dart-lang/sdk/blob/main/docs/process/experimental-flags.md '
'for details.',
);
argParser.addOption(
_platformFlag,
defaultsTo: '',
help:
'Runs Dart unit tests on the given platform instead of the Dart VM.',
);
}

static const String _platformFlag = 'platform';

@override
final String name = 'dart-test';

Expand Down Expand Up @@ -64,17 +71,15 @@ class DartTestCommand extends PackageLoopingCommand {
/// Runs the Dart tests for a Flutter package, returning true on success.
Future<bool> _runFlutterTests(RepositoryPackage package) async {
final String experiment = getStringArg(kEnableExperiment);
final String platform = getStringArg(_platformFlag);

final int exitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
'test',
'--color',
if (experiment.isNotEmpty) '--enable-experiment=$experiment',
// TODO(ditman): Remove this once all plugins are migrated to 'drive'.
if (pluginSupportsPlatform(platformWeb, package,
requiredMode: PlatformSupport.inline))
'--platform=chrome',
if (platform.isNotEmpty) '--platform=$platform',
],
workingDir: package.directory,
);
Expand All @@ -96,13 +101,15 @@ class DartTestCommand extends PackageLoopingCommand {
}

final String experiment = getStringArg(kEnableExperiment);
final String platform = getStringArg(_platformFlag);

exitCode = await processRunner.runAndStream(
'dart',
<String>[
'run',
if (experiment.isNotEmpty) '--enable-experiment=$experiment',
'test',
if (platform.isNotEmpty) '--platform=$platform',
],
workingDir: package.directory,
);
Expand Down
22 changes: 11 additions & 11 deletions script/tool/test/dart_test_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void main() {
]));
});

test('runs on Chrome for web plugins', () async {
test('runs in Chrome when requested for Flutter package', () async {
final RepositoryPackage plugin = createFakePlugin(
'plugin',
packagesDir,
Expand All @@ -241,7 +241,8 @@ void main() {
},
);

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

expect(
processRunner.recordedCalls,
Expand All @@ -254,23 +255,22 @@ void main() {
);
});

test('Does not run on Chrome for web endorsements', () async {
final RepositoryPackage plugin = createFakePlugin(
'plugin',
test('runs in Chrome when requested for Dart package', () async {
final RepositoryPackage package = createFakePackage(
'package',
packagesDir,
extraFiles: <String>['test/empty_test.dart'],
platformSupport: <String, PlatformDetails>{
platformWeb: const PlatformDetails(PlatformSupport.federated),
},
);

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

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