Skip to content

Commit 60a1ffc

Browse files
[tool] Extend flutter test workaround to other desktops (#6024)
Expand the multiple-test-files workaround in `drive-examples` from macOS to all of the desktop platforms, now that we know it's not macOS-specific. See flutter/flutter#135673
1 parent 2d0f24f commit 60a1ffc

File tree

2 files changed

+163
-49
lines changed

2 files changed

+163
-49
lines changed

script/tool/lib/src/drive_examples_command.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,10 @@ class DriveExamplesCommand extends PackageLoopingCommand {
404404
// Workaround for https://github.com/flutter/flutter/issues/135673
405405
// Once that is fixed on stable, this logic can be removed and the command
406406
// can always just be run with "integration_test".
407-
final bool needsMultipleInvocations =
408-
testFiles.length > 1 && getBoolArg(platformMacOS);
407+
final bool needsMultipleInvocations = testFiles.length > 1 &&
408+
(getBoolArg(platformLinux) ||
409+
getBoolArg(platformMacOS) ||
410+
getBoolArg(platformWindows));
409411
final Iterable<String> individualRunTargets = needsMultipleInvocations
410412
? testFiles
411413
.map((File f) => getRelativePosixPath(f, from: example.directory))

script/tool/test/drive_examples_command_test.dart

Lines changed: 159 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -450,57 +450,169 @@ void main() {
450450

451451
// This tests the workaround for https://github.com/flutter/flutter/issues/135673
452452
// and the behavior it tests should be removed once that is fixed.
453-
test('runs tests separately on macOS', () async {
454-
final RepositoryPackage plugin = createFakePlugin(
455-
'plugin',
456-
packagesDir,
457-
extraFiles: <String>[
458-
'example/integration_test/first_test.dart',
459-
'example/integration_test/second_test.dart',
460-
'example/macos/macos.swift',
461-
],
462-
platformSupport: <String, PlatformDetails>{
463-
platformMacOS: const PlatformDetails(PlatformSupport.inline),
464-
},
465-
);
453+
group('runs tests separately on desktop', () {
454+
test('macOS', () async {
455+
final RepositoryPackage plugin = createFakePlugin(
456+
'plugin',
457+
packagesDir,
458+
extraFiles: <String>[
459+
'example/integration_test/first_test.dart',
460+
'example/integration_test/second_test.dart',
461+
'example/macos/macos.swift',
462+
],
463+
platformSupport: <String, PlatformDetails>{
464+
platformMacOS: const PlatformDetails(PlatformSupport.inline),
465+
},
466+
);
466467

467-
final Directory pluginExampleDirectory = getExampleDir(plugin);
468+
final Directory pluginExampleDirectory = getExampleDir(plugin);
468469

469-
final List<String> output = await runCapturingPrint(runner, <String>[
470-
'drive-examples',
471-
'--macos',
472-
]);
470+
final List<String> output = await runCapturingPrint(runner, <String>[
471+
'drive-examples',
472+
'--macos',
473+
]);
473474

474-
expect(
475-
output,
476-
containsAllInOrder(<Matcher>[
477-
contains('Running for plugin'),
478-
contains('No issues found!'),
479-
]),
480-
);
475+
expect(
476+
output,
477+
containsAllInOrder(<Matcher>[
478+
contains('Running for plugin'),
479+
contains('No issues found!'),
480+
]),
481+
);
481482

482-
expect(
483-
processRunner.recordedCalls,
484-
orderedEquals(<ProcessCall>[
485-
ProcessCall(
486-
getFlutterCommand(mockPlatform),
487-
const <String>[
488-
'test',
489-
'-d',
490-
'macos',
491-
'integration_test/first_test.dart',
492-
],
493-
pluginExampleDirectory.path),
494-
ProcessCall(
495-
getFlutterCommand(mockPlatform),
496-
const <String>[
497-
'test',
498-
'-d',
499-
'macos',
500-
'integration_test/second_test.dart',
501-
],
502-
pluginExampleDirectory.path),
503-
]));
483+
expect(
484+
processRunner.recordedCalls,
485+
orderedEquals(<ProcessCall>[
486+
ProcessCall(
487+
getFlutterCommand(mockPlatform),
488+
const <String>[
489+
'test',
490+
'-d',
491+
'macos',
492+
'integration_test/first_test.dart',
493+
],
494+
pluginExampleDirectory.path),
495+
ProcessCall(
496+
getFlutterCommand(mockPlatform),
497+
const <String>[
498+
'test',
499+
'-d',
500+
'macos',
501+
'integration_test/second_test.dart',
502+
],
503+
pluginExampleDirectory.path),
504+
]));
505+
});
506+
507+
// This tests the workaround for https://github.com/flutter/flutter/issues/135673
508+
// and the behavior it tests should be removed once that is fixed.
509+
test('Linux', () async {
510+
final RepositoryPackage plugin = createFakePlugin(
511+
'plugin',
512+
packagesDir,
513+
extraFiles: <String>[
514+
'example/integration_test/first_test.dart',
515+
'example/integration_test/second_test.dart',
516+
'example/linux/foo.cc',
517+
],
518+
platformSupport: <String, PlatformDetails>{
519+
platformLinux: const PlatformDetails(PlatformSupport.inline),
520+
},
521+
);
522+
523+
final Directory pluginExampleDirectory = getExampleDir(plugin);
524+
525+
final List<String> output = await runCapturingPrint(runner, <String>[
526+
'drive-examples',
527+
'--linux',
528+
]);
529+
530+
expect(
531+
output,
532+
containsAllInOrder(<Matcher>[
533+
contains('Running for plugin'),
534+
contains('No issues found!'),
535+
]),
536+
);
537+
538+
expect(
539+
processRunner.recordedCalls,
540+
orderedEquals(<ProcessCall>[
541+
ProcessCall(
542+
getFlutterCommand(mockPlatform),
543+
const <String>[
544+
'test',
545+
'-d',
546+
'linux',
547+
'integration_test/first_test.dart',
548+
],
549+
pluginExampleDirectory.path),
550+
ProcessCall(
551+
getFlutterCommand(mockPlatform),
552+
const <String>[
553+
'test',
554+
'-d',
555+
'linux',
556+
'integration_test/second_test.dart',
557+
],
558+
pluginExampleDirectory.path),
559+
]));
560+
});
561+
562+
// This tests the workaround for https://github.com/flutter/flutter/issues/135673
563+
// and the behavior it tests should be removed once that is fixed.
564+
test('Windows', () async {
565+
final RepositoryPackage plugin = createFakePlugin(
566+
'plugin',
567+
packagesDir,
568+
extraFiles: <String>[
569+
'example/integration_test/first_test.dart',
570+
'example/integration_test/second_test.dart',
571+
'example/windows/foo.cpp',
572+
],
573+
platformSupport: <String, PlatformDetails>{
574+
platformWindows: const PlatformDetails(PlatformSupport.inline),
575+
},
576+
);
577+
578+
final Directory pluginExampleDirectory = getExampleDir(plugin);
579+
580+
final List<String> output = await runCapturingPrint(runner, <String>[
581+
'drive-examples',
582+
'--windows',
583+
]);
584+
585+
expect(
586+
output,
587+
containsAllInOrder(<Matcher>[
588+
contains('Running for plugin'),
589+
contains('No issues found!'),
590+
]),
591+
);
592+
593+
expect(
594+
processRunner.recordedCalls,
595+
orderedEquals(<ProcessCall>[
596+
ProcessCall(
597+
getFlutterCommand(mockPlatform),
598+
const <String>[
599+
'test',
600+
'-d',
601+
'windows',
602+
'integration_test/first_test.dart',
603+
],
604+
pluginExampleDirectory.path),
605+
ProcessCall(
606+
getFlutterCommand(mockPlatform),
607+
const <String>[
608+
'test',
609+
'-d',
610+
'windows',
611+
'integration_test/second_test.dart',
612+
],
613+
pluginExampleDirectory.path),
614+
]));
615+
});
504616
});
505617

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

0 commit comments

Comments
 (0)