Skip to content

[tool] Extend flutter test workaround to other desktops #6024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions script/tool/lib/src/drive_examples_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,10 @@ class DriveExamplesCommand extends PackageLoopingCommand {
// Workaround for https://github.com/flutter/flutter/issues/135673
// Once that is fixed on stable, this logic can be removed and the command
// can always just be run with "integration_test".
final bool needsMultipleInvocations =
testFiles.length > 1 && getBoolArg(platformMacOS);
final bool needsMultipleInvocations = testFiles.length > 1 &&
(getBoolArg(platformLinux) ||
getBoolArg(platformMacOS) ||
getBoolArg(platformWindows));
final Iterable<String> individualRunTargets = needsMultipleInvocations
? testFiles
.map((File f) => getRelativePosixPath(f, from: example.directory))
Expand Down
206 changes: 159 additions & 47 deletions script/tool/test/drive_examples_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -450,57 +450,169 @@ void main() {

// This tests the workaround for https://github.com/flutter/flutter/issues/135673
// and the behavior it tests should be removed once that is fixed.
test('runs tests separately on macOS', () async {
final RepositoryPackage plugin = createFakePlugin(
'plugin',
packagesDir,
extraFiles: <String>[
'example/integration_test/first_test.dart',
'example/integration_test/second_test.dart',
'example/macos/macos.swift',
],
platformSupport: <String, PlatformDetails>{
platformMacOS: const PlatformDetails(PlatformSupport.inline),
},
);
group('runs tests separately on desktop', () {
test('macOS', () async {
final RepositoryPackage plugin = createFakePlugin(
'plugin',
packagesDir,
extraFiles: <String>[
'example/integration_test/first_test.dart',
'example/integration_test/second_test.dart',
'example/macos/macos.swift',
],
platformSupport: <String, PlatformDetails>{
platformMacOS: const PlatformDetails(PlatformSupport.inline),
},
);

final Directory pluginExampleDirectory = getExampleDir(plugin);
final Directory pluginExampleDirectory = getExampleDir(plugin);

final List<String> output = await runCapturingPrint(runner, <String>[
'drive-examples',
'--macos',
]);
final List<String> output = await runCapturingPrint(runner, <String>[
'drive-examples',
'--macos',
]);

expect(
output,
containsAllInOrder(<Matcher>[
contains('Running for plugin'),
contains('No issues found!'),
]),
);
expect(
output,
containsAllInOrder(<Matcher>[
contains('Running for plugin'),
contains('No issues found!'),
]),
);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'test',
'-d',
'macos',
'integration_test/first_test.dart',
],
pluginExampleDirectory.path),
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'test',
'-d',
'macos',
'integration_test/second_test.dart',
],
pluginExampleDirectory.path),
]));
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'test',
'-d',
'macos',
'integration_test/first_test.dart',
],
pluginExampleDirectory.path),
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'test',
'-d',
'macos',
'integration_test/second_test.dart',
],
pluginExampleDirectory.path),
]));
});

// This tests the workaround for https://github.com/flutter/flutter/issues/135673
// and the behavior it tests should be removed once that is fixed.
test('Linux', () async {
final RepositoryPackage plugin = createFakePlugin(
'plugin',
packagesDir,
extraFiles: <String>[
'example/integration_test/first_test.dart',
'example/integration_test/second_test.dart',
'example/linux/foo.cc',
],
platformSupport: <String, PlatformDetails>{
platformLinux: const PlatformDetails(PlatformSupport.inline),
},
);

final Directory pluginExampleDirectory = getExampleDir(plugin);

final List<String> output = await runCapturingPrint(runner, <String>[
'drive-examples',
'--linux',
]);

expect(
output,
containsAllInOrder(<Matcher>[
contains('Running for plugin'),
contains('No issues found!'),
]),
);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'test',
'-d',
'linux',
'integration_test/first_test.dart',
],
pluginExampleDirectory.path),
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'test',
'-d',
'linux',
'integration_test/second_test.dart',
],
pluginExampleDirectory.path),
]));
});

// This tests the workaround for https://github.com/flutter/flutter/issues/135673
// and the behavior it tests should be removed once that is fixed.
test('Windows', () async {
final RepositoryPackage plugin = createFakePlugin(
'plugin',
packagesDir,
extraFiles: <String>[
'example/integration_test/first_test.dart',
'example/integration_test/second_test.dart',
'example/windows/foo.cpp',
],
platformSupport: <String, PlatformDetails>{
platformWindows: const PlatformDetails(PlatformSupport.inline),
},
);

final Directory pluginExampleDirectory = getExampleDir(plugin);

final List<String> output = await runCapturingPrint(runner, <String>[
'drive-examples',
'--windows',
]);

expect(
output,
containsAllInOrder(<Matcher>[
contains('Running for plugin'),
contains('No issues found!'),
]),
);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'test',
'-d',
'windows',
'integration_test/first_test.dart',
],
pluginExampleDirectory.path),
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'test',
'-d',
'windows',
'integration_test/second_test.dart',
],
pluginExampleDirectory.path),
]));
});
});

test('driving when plugin does not suppport web is a no-op', () async {
Expand Down