Skip to content

Commit

Permalink
Remove Windows build workaround
Browse files Browse the repository at this point in the history
Now that the Windows app template is stable, examples should have it
checked in as usual, so the workaround is no longer needed.

Requires flutter/plugins#3149 to land first.
  • Loading branch information
stuartmorgan committed Oct 13, 2020
1 parent 1c6c801 commit eb12699
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 217 deletions.
17 changes: 0 additions & 17 deletions lib/src/build_examples_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,6 @@ class BuildExamplesCommand extends PluginCommand {
if (argResults[kWindows]) {
print('\nBUILDING Windows for $packageName');
if (isWindowsPlugin(plugin, fileSystem)) {
// The Windows tooling is not yet stable, so we need to
// delete any existing windows directory and create a new one
// with 'flutter create .'
final Directory windowsFolder =
fileSystem.directory(p.join(example.path, 'windows'));
bool exampleCreated = false;
if (!windowsFolder.existsSync()) {
int exampleCreateCode = await processRunner.runAndStream(
flutterCommand, <String>['create', '.'],
workingDir: example);
if (exampleCreateCode == 0) {
exampleCreated = true;
}
}
int buildExitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
Expand All @@ -140,9 +126,6 @@ class BuildExamplesCommand extends PluginCommand {
if (buildExitCode != 0) {
failingPackages.add('$packageName (windows)');
}
if (exampleCreated && windowsFolder.existsSync()) {
windowsFolder.deleteSync(recursive: true);
}
} else {
print('Windows is not supported by this plugin');
}
Expand Down
15 changes: 0 additions & 15 deletions lib/src/drive_examples_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,6 @@ class DriveExamplesCommand extends PluginCommand {
if (!(await pluginSupportedOnCurrentPlatform(plugin, fileSystem))) {
continue;
}
if (isWindows) {
// The Windows tooling is not yet stable, so the platform directory for the application
// might not exist, to prevent it from becoming stale. If it doesn't, create one.
final Directory windowsFolder =
fileSystem.directory(p.join(example.path, 'windows'));
if (!windowsFolder.existsSync()) {
int exitCode = await processRunner.runAndStream(
flutterCommand, <String>['create', '.'],
workingDir: example);
if (exitCode != 0) {
print('Failed to create a windows directory for $packageName');
continue;
}
}
}
final Directory driverTests =
fileSystem.directory(p.join(example.path, 'test_driver'));
if (!driverTests.existsSync()) {
Expand Down
82 changes: 0 additions & 82 deletions test/build_examples_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,46 +181,6 @@ void main() {
cleanupPackages();
});

test(
'building for Linux does not call flutter create if a directory exists',
() async {
createFakePlugin('plugin',
withExtraFiles: <List<String>>[
<String>['example', 'test'],
<String>['example', 'linux', 'test.h']
],
isLinuxPlugin: true);

final Directory pluginExampleDirectory =
mockPackagesDir.childDirectory('plugin').childDirectory('example');

createFakePubspec(pluginExampleDirectory, isFlutter: true);

final List<String> output = await runCapturingPrint(
runner, <String>['build-examples', '--no-ipa', '--linux']);
final String packageName =
p.relative(pluginExampleDirectory.path, from: mockPackagesDir.path);

expect(
output,
orderedEquals(<String>[
'\nBUILDING Linux for $packageName',
'\n\n',
'All builds successful!',
]),
);

print(processRunner.recordedCalls);
// flutter create . should NOT be called.
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(flutterCommand, <String>['build', 'linux'],
pluginExampleDirectory.path),
]));
cleanupPackages();
});

test('building for macos with no implementation results in no-op',
() async {
createFakePlugin('plugin', withExtraFiles: <List<String>>[
Expand Down Expand Up @@ -355,48 +315,6 @@ void main() {
);

print(processRunner.recordedCalls);
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(flutterCommand, <String>['create', '.'],
pluginExampleDirectory.path),
ProcessCall(flutterCommand, <String>['build', 'windows'],
pluginExampleDirectory.path),
]));
cleanupPackages();
});

test(
'building for windows does not call flutter create if a directory exists',
() async {
createFakePlugin('plugin',
withExtraFiles: <List<String>>[
<String>['example', 'test'],
<String>['example', 'windows', 'test.h']
],
isWindowsPlugin: true);

final Directory pluginExampleDirectory =
mockPackagesDir.childDirectory('plugin').childDirectory('example');

createFakePubspec(pluginExampleDirectory, isFlutter: true);

final List<String> output = await runCapturingPrint(
runner, <String>['build-examples', '--no-ipa', '--windows']);
final String packageName =
p.relative(pluginExampleDirectory.path, from: mockPackagesDir.path);

expect(
output,
orderedEquals(<String>[
'\nBUILDING Windows for $packageName',
'\n\n',
'All builds successful!',
]),
);

print(processRunner.recordedCalls);
// flutter create . should NOT be called.
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
Expand Down
104 changes: 1 addition & 103 deletions test/drive_examples_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,57 +276,6 @@ void main() {
]));
});

test(
'driving on a Linux plugin with a Linux direactory does not call flutter create',
() async {
createFakePlugin('plugin',
withExtraFiles: <List<String>>[
<String>['example', 'test_driver', 'plugin_test.dart'],
<String>['example', 'test_driver', 'plugin.dart'],
<String>['example', 'linux', 'test.h'],
],
isLinuxPlugin: true);

final Directory pluginExampleDirectory =
mockPackagesDir.childDirectory('plugin').childDirectory('example');

createFakePubspec(pluginExampleDirectory, isFlutter: true);

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

expect(
output,
orderedEquals(<String>[
'\n\n',
'All driver tests successful!',
]),
);

String deviceTestPath = p.join('test_driver', 'plugin.dart');
String driverTestPath = p.join('test_driver', 'plugin_test.dart');
print(processRunner.recordedCalls);
// flutter create . should NOT be called.
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
flutterCommand,
<String>[
'drive',
'-d',
'linux',
'--driver',
driverTestPath,
'--target',
deviceTestPath
],
pluginExampleDirectory.path),
]));
});

test('driving when plugin does not suppport macOS is a no-op', () async {
createFakePlugin('plugin', withExtraFiles: <List<String>>[
<String>['example', 'test_driver', 'plugin_test.dart'],
Expand Down Expand Up @@ -403,6 +352,7 @@ void main() {
pluginExampleDirectory.path),
]));
});

test('driving when plugin does not suppport windows is a no-op', () async {
createFakePlugin('plugin',
withExtraFiles: <List<String>>[
Expand Down Expand Up @@ -464,58 +414,6 @@ void main() {
String deviceTestPath = p.join('test_driver', 'plugin.dart');
String driverTestPath = p.join('test_driver', 'plugin_test.dart');
print(processRunner.recordedCalls);
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(flutterCommand, <String>['create', '.'],
pluginExampleDirectory.path),
ProcessCall(
flutterCommand,
<String>[
'drive',
'-d',
'windows',
'--driver',
driverTestPath,
'--target',
deviceTestPath
],
pluginExampleDirectory.path),
]));
});
test(
'driving on a Windows plugin with a windows direactory does not call flutter create',
() async {
createFakePlugin('plugin',
withExtraFiles: <List<String>>[
<String>['example', 'test_driver', 'plugin_test.dart'],
<String>['example', 'test_driver', 'plugin.dart'],
<String>['example', 'windows', 'test.h'],
],
isWindowsPlugin: true);

final Directory pluginExampleDirectory =
mockPackagesDir.childDirectory('plugin').childDirectory('example');

createFakePubspec(pluginExampleDirectory, isFlutter: true);

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

expect(
output,
orderedEquals(<String>[
'\n\n',
'All driver tests successful!',
]),
);

String deviceTestPath = p.join('test_driver', 'plugin.dart');
String driverTestPath = p.join('test_driver', 'plugin_test.dart');
print(processRunner.recordedCalls);
// flutter create . should NOT be called.
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
Expand Down

0 comments on commit eb12699

Please sign in to comment.