Skip to content

iOS: Re-enable iOS unittests#167893

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
cbracken:swift_reenable_unittests
Apr 28, 2025
Merged

iOS: Re-enable iOS unittests#167893
auto-submit[bot] merged 1 commit into
flutter:masterfrom
cbracken:swift_reenable_unittests

Conversation

@cbracken

@cbracken cbracken commented Apr 27, 2025

Copy link
Copy Markdown
Member

Re-enables iOS unittests, which were inadvertently disabled as part of #167530.

This extracts out enable_ios_unittests for readability/re-usability across the build system, and better documents enable_unittests as specifically being for platform-portable unit tests that can be run on general-purpose operating systems such as macOS, Fuchsia, Linux, but not specific target OSes such as iOS/Android that require executables to be built against platform SDKs as installable apps.

Issue: #144791

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions Bot added platform-ios iOS applications specifically engine flutter/engine related. See also e: labels. labels Apr 27, 2025
if (enable_unittests) {
if (is_ios) {
public_deps += [ "//flutter/shell/platform/darwin/ios:ios_test_flutter" ]
}

@cbracken cbracken Apr 27, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In #167530, this block was moved inside the enable_unittests conditional here:
https://github.com/flutter/flutter/pull/167530/files#diff-0009a2dc7028a9776b47e2251ca6b7154d4cd374466a074996d29cf881ab940aL181

This caused iOS tests to be disabled, since enable_unittests is never true for is_ios or is_android. See testing.gni below, and note it's defined as:

enable_unittests = current_toolchain == host_toolchain || is_fuchsia || is_mac

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is... so confusing. may be add a comment here or rename it? nvm i saw your another comment.

# * host_toolchain: non-cross-compile. We can run tests on the host.
# * Fuchsia: build unittests for testing on device.
# * macOS: arm64 builds can run x64 binaries.
enable_unittests = current_toolchain == host_toolchain || is_fuchsia || is_mac

@cbracken cbracken Apr 27, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think a reasonable followup might be to rename enable_unittests to something like enable_portable_unittests or similar, since these are used to build our generic FML, embedder API, Impeller, etc. tests into binaries that are runnable on general-purpose OSes like Linux, macOS, including non-host OSes such as Fuchsia.

iOS and Android tests, on the other hand, need to be built as installable app bundles, which is a bit of a different usecase.

I think it's worthwhile treating these as separate variables to avoid having to litter the build with enable_unittests && !(is_ios || is_android). I also think it's worth having a specific enable_ios_unittests and probably enable_android_unittests for the same reason, that way we avoid enable_target_device_unittests && is_ios etc. all over the place.

Would love any suggestions on better names for enable_unittests that emphasise that this is specifically for platform-portable stuff that can be run on general-purpose OSes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

... on general-purpose OSes like Linux, macOS, including non-host OSes such as Fuchsia.

by general purpose do you mean just host builds (except fushsia which is the odd one out)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right -- "host" refers to the OS that is doing the compilation and "target" refers to the target OS that we're building binaries for. Many of our unit tests (like the embedder API tests) are totally generic, portable tests. When there's no platform-specific behaviour, we can just run them as general tests on the host OS.

Other tests (like Impeller-specific tests) have some platform-specific behaviour (e.g. Metal requires Apple platforms [I'm ignoring swiftshader/swangle here]) but it's configuration that is supported on at least one of our host platforms (e.g. Metal on macOS) so doesn't necessarily have to run on iOS.

iOS and Android don't really have the facility to run arbitrary ELF or Mach-O binaries (e.g. from a command-line), and generally require apps to be built into some form of package, deployed etc. so there's not a huge value in e.g. running the generic C++ embedder API tests on iOS or Android.

Fuchsia is a bit special because we always cross-compile for Fuchsia from Linux or macOS, but Fuchsia is a general-purpose OS that does have the ability to run binaries from a command-line. As such, we build a bunch of these for Fuchsia. So in effect these aren't so much host tests as really generic tests we can run on general-purpose OSes.

In a bunch of cases (maybe even most cases), we could actually build them into an IPA for iOS or an APK for Android, but we don't because we get very little added value in doing so, but would take the non-zero added cost of having to wrap them up in app packages and deal with host-target launch, logging, and result-checking.

Re-enables iOS unittests, which were inadvertently disabled as part of flutter#167530.

This extracts out `enable_ios_unittests` for readability/re-usability
across the build system, and better documents `enable_unittests` as
specifically being for platform-portable unit tests that can be run on
general-purpose operating systems such as macOS, Fuchsia, Linux, but not
specific target OSes such as iOS/Android that require executables to be
built against platform SDKs as installable apps.

Issue: flutter#144791
@cbracken cbracken force-pushed the swift_reenable_unittests branch from e2d02b1 to 616df92 Compare April 27, 2025 16:26
@cbracken cbracken requested a review from matanlurey April 28, 2025 02:57
if (enable_unittests) {
if (is_ios) {
public_deps += [ "//flutter/shell/platform/darwin/ios:ios_test_flutter" ]
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is... so confusing. may be add a comment here or rename it? nvm i saw your another comment.

]
}

platform_frameworks_path =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

github is confused with this diff - all these lines are just indented because of the if right?

# * host_toolchain: non-cross-compile. We can run tests on the host.
# * Fuchsia: build unittests for testing on device.
# * macOS: arm64 builds can run x64 binaries.
enable_unittests = current_toolchain == host_toolchain || is_fuchsia || is_mac

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

... on general-purpose OSes like Linux, macOS, including non-host OSes such as Fuchsia.

by general purpose do you mean just host builds (except fushsia which is the odd one out)?

@cbracken cbracken added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 28, 2025
@auto-submit auto-submit Bot added this pull request to the merge queue Apr 28, 2025
Merged via the queue into flutter:master with commit 7895450 Apr 28, 2025
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 28, 2025
@cbracken cbracken deleted the swift_reenable_unittests branch April 28, 2025 04:53
cbracken added a commit to cbracken/flutter that referenced this pull request Apr 28, 2025
Re-enables iOS unittests, which were inadvertently disabled as part of
flutter#167530.

This extracts out `enable_ios_unittests` for readability/re-usability
across the build system, and better documents `enable_unittests` as
specifically being for platform-portable unit tests that can be run on
general-purpose operating systems such as macOS, Fuchsia, Linux, but not
specific target OSes such as iOS/Android that require executables to be
built against platform SDKs as installable apps.

Issue: flutter#144791

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [X] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull request Aug 14, 2025
Re-enables iOS unittests, which were inadvertently disabled as part of
flutter#167530.

This extracts out `enable_ios_unittests` for readability/re-usability
across the build system, and better documents `enable_unittests` as
specifically being for platform-portable unit tests that can be run on
general-purpose operating systems such as macOS, Fuchsia, Linux, but not
specific target OSes such as iOS/Android that require executables to be
built against platform SDKs as installable apps.

Issue: flutter#144791

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [X] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine flutter/engine related. See also e: labels. platform-ios iOS applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants