Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[flutter_plugin_tests] Split analyze out of xctest #4161

Merged
merged 10 commits into from
Jul 21, 2021

Conversation

stuartmorgan
Copy link
Contributor

To prep for making a combined command to run native tests across different platforms, rework xctest:

  • Split analyze out into a new xcode-analyze command:
    • Since the analyze step runs a new build over everything with different flags, this is only a small amount slower than the combined version
    • This makes the logic easier to follow
    • This allows us to meaningfully report skips, to better notice missing tests.
  • Add the ability to target specific test bundles (RunnerTests or RunnerUITests)

To share code between the commands, this extracts a new Xcode helper class.

Part of flutter/flutter#84392 and flutter/flutter#86489

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Note that unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

@google-cla google-cla bot added the cla: yes label Jul 16, 2021
'version': '13.0',
'isAvailable': true,
'name': 'iOS 13.0'
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This testing of finding the best device among many is now part of xcode_test.dart, so what's left here is just one valid device for the test to find.

group('iOS', () {
test('skip if iOS is not supported', () async {
createFakePlugin('plugin', packagesDir, extraFiles: <String>[
'example/test',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opportunistic cleanup; this extraFiles was copy/pasted from some initial test into lots of other tests that don't actually need it, and I've been cleaning it up as I notice.

kPlatformIos: PlatformSupport.inline
});

final Directory pluginExampleDirectory =
pluginDirectory.childDirectory('example');

processRunner.processToReturn = MockProcess.succeeding();
processRunner.resultStdout =
'{"project":{"targets":["bar_scheme", "foo_scheme"]}}';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opportunistic cleanup; I'm assuming that this is from an earlier version of xctest_command, because nothing currently uses this output.


final List<String> output = await runCapturingPrint(runner,
<String>['xctest', '--macos', _kDestination, 'foo_destination']);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opportunistic cleanup; I accidentally left the targets when initially copy/pasting iOS tests for macOS.

@@ -56,9 +59,6 @@ class XCTestCommand extends PackageLoopingCommand {
'Runs the xctests in the iOS and/or macOS example apps.\n\n'
'This command requires "flutter" and "xcrun" to be in your path.';

@override
String get failureListHeader => 'The following packages are failing XCTests:';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opportunistic cleanup; I left this when doing the initial migration to the new base command to minimize test diff, but there's no reason we need a custom summary header for this command.

@stuartmorgan stuartmorgan requested a review from jmagman July 20, 2021 20:11
@jmagman
Copy link
Member

jmagman commented Jul 20, 2021

Add the ability to target specific test bundles (RunnerTests or RunnerUITests)

Both types of tests will run on the same build artifacts, so it should be faster to run them at the same time. It's a fine feature to add, just keep it in mind if you intend to split them into separate CI tests.

Comment on lines 91 to 98
final List<String> findSimulatorsArguments = <String>[
'simctl',
'list',
'--json'
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you just copied this, but if you add devices available

Suggested change
final List<String> findSimulatorsArguments = <String>[
'simctl',
'list',
'--json'
];
final List<String> findSimulatorsArguments = <String>[
'simctl',
'list',
'devices',
'available',
'--json'
];

The availabilityError/isAvailable check below can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done! (I had to add 'runtimes' as well since it's parsing those too.)

])) {
failures.add('iOS');
}
if (testMacos && !await _analyzePlugin(package, 'macOS')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to worry about this now, but when CI starts using Xcode 13 next year we may need a macOS -destination option.
flutter/flutter#86590

@stuartmorgan
Copy link
Contributor Author

Both types of tests will run on the same build artifacts, so it should be faster to run them at the same time. It's a fine feature to add, just keep it in mind if you intend to split them into separate CI tests.

Yes, I had tested that at the same time I tested splitting out analyze and as expected it is much slower. This is intended for local use (and is prep for the new combined PR that will have options to select unit or integration tests for local use, and maybe for use in CI on platforms where combining them doesn't help).

@stuartmorgan stuartmorgan merged commit 09ec519 into flutter:master Jul 21, 2021
@stuartmorgan stuartmorgan deleted the xctest-refactor branch July 21, 2021 01:17
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 27, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 27, 2021
fotiDim pushed a commit to fotiDim/plugins that referenced this pull request Sep 13, 2021
To prep for making a combined command to run native tests across different platforms, rework `xctest`:
- Split analyze out into a new `xcode-analyze` command:
  - Since the analyze step runs a new build over everything with different flags, this is only a small amount slower than the combined version
  - This makes the logic easier to follow
  - This allows us to meaningfully report skips, to better notice missing tests.
- Add the ability to target specific test bundles (RunnerTests or RunnerUITests)

To share code between the commands, this extracts a new `Xcode` helper class.

Part of flutter/flutter#84392 and flutter/flutter#86489
amantoux pushed a commit to amantoux/plugins that referenced this pull request Sep 27, 2021
To prep for making a combined command to run native tests across different platforms, rework `xctest`:
- Split analyze out into a new `xcode-analyze` command:
  - Since the analyze step runs a new build over everything with different flags, this is only a small amount slower than the combined version
  - This makes the logic easier to follow
  - This allows us to meaningfully report skips, to better notice missing tests.
- Add the ability to target specific test bundles (RunnerTests or RunnerUITests)

To share code between the commands, this extracts a new `Xcode` helper class.

Part of flutter/flutter#84392 and flutter/flutter#86489
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants