Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Apr 10, 2020

relevant pr: flutter/flutter#54324

This introduces a new shared_library that has all the contents of Fluttter.framework and the compiled unit tests. This is the library the test runner links against instead of Flutter.framework. That allows us to bypass the visibility problem since the tests are in the same binary as the code.

@gaaclarke gaaclarke force-pushed the all-ios-unit-tests branch 5 times, most recently from 4ffc767 to 1b8f117 Compare April 10, 2020 18:54
configs -= [ "//build/config/compiler:chromium_code" ]
cflags = [
"-fvisibility=default",
"-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform//Developer/Library/Frameworks/",
Copy link
Member

Choose a reason for hiding this comment

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

  1. What if Xcode is at a different path?
  2. What about the non-simulator frameworks?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is still a draft PR =). I can address where xcode is located. I haven't been able to get rid of the hardcoded iPhoneSimulator path. The problem is that GN special cases all libs that are "X.framework" but it doesn't support XCTest.framework.

Since this is intended for the simulator it isn't the end of the world if I can't get it removed.

Copy link
Member

Choose a reason for hiding this comment

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

This is still a draft PR =).

Sorry, got excited!

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@gaaclarke gaaclarke force-pushed the all-ios-unit-tests branch from 1b8f117 to 0fa69a6 Compare April 10, 2020 20:04
Copy link
Member

@xster xster left a comment

Choose a reason for hiding this comment

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

awesome!

public = _flutter_framework_headers

source_set("flutter_framework_source") {
cflags_objc = flutter_cflags_objc
Copy link
Member

Choose a reason for hiding this comment

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

we can add a non-public visibility clause here to be clean

Copy link
Member Author

Choose a reason for hiding this comment

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

done

"-Wno-misleading-indentation",
]
sources = [
"../../../../../third_party/ocmock/Source/OCMock/NSInvocation+OCMAdditions.h",
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if it works, but instead of digging through all these source, can't the dependent just have a deps = [ "//third_party/ocmock" ] here? (searching through other .gn file examples in third_party)

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't because ocmock doesn't have a GN file that specifies how to build it. We can't add one there either because that isn't a repo we control. We can clone it at some point.

Copy link
Member

Choose a reason for hiding this comment

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

There is one though https://chromium.googlesource.com/chromium/src/+/master/third_party/ocmock/BUILD.gn. It's probably our DEPS needing to get it from chromium rather than the upstream github directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't use chromium's ocmock because it is a source_set not a static_library. I can try a static_library based on that source_set but i've had problems with static_libraries in the past. I'd prefer to do this as a separate PR if you don't mind.

Copy link
Member

Choose a reason for hiding this comment

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

ah ok, feel free to do it in a separate PR.

That source_set is default public visibility, I suppose we can still make a static_library here that just deps = [ "//third_party/ocmock" ] if we clone the right repo.

cd ../../../..
./flutter/tools/gn --ios --simulator --unoptimized
ninja -j 100 -C out/ios_debug_sim_unopt
ninja -j 100 -C out/ios_debug_sim_unopt ios_test_flutter
Copy link
Member

Choose a reason for hiding this comment

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

is this out/ios_test_flutter?

Copy link
Member Author

Choose a reason for hiding this comment

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

nope, we are piggy backing on ./flutter/tools/gn

include_dirs = [ "../../../../../third_party/ocmock/Source/" ]
}

ios_test_flutter_path = rebase_path("$root_out_dir/libios_test_flutter.dylib")
Copy link
Member

Choose a reason for hiding this comment

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

perhaps still mention that it's for simulators in the name

Copy link
Member Author

Choose a reason for hiding this comment

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

added comment

@gaaclarke
Copy link
Member Author

This PR depends on LUCI updating: https://chromium-review.googlesource.com/c/chromium/tools/build/+/2145769

@gaaclarke gaaclarke force-pushed the all-ios-unit-tests branch 7 times, most recently from 5dd5ddb to 45c4878 Compare April 10, 2020 21:49
@gaaclarke gaaclarke force-pushed the all-ios-unit-tests branch from 45c4878 to b29dbaf Compare April 10, 2020 21:51
@gaaclarke gaaclarke marked this pull request as ready for review April 10, 2020 21:55
@auto-assign auto-assign bot requested a review from cbracken April 10, 2020 21:55

ocmock_path = "../../../../../third_party/ocmock/Source"

# TODO: Clone the OCMock repository so we can add a BUILD.gn to it.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

as commented above

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a todo issue.

cd ../../../..
./flutter/tools/gn --ios --simulator --unoptimized
ninja -j 100 -C out/ios_debug_sim_unopt
ninja -j 100 -C out/$FLUTTER_ENGINE ios_test_flutter
Copy link
Member

Choose a reason for hiding this comment

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

If we're still building the engine here, is there a reason we're not running the gn step?
Given that $FLUTTER_ENGINE is now a variable, the gn params probably should be too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of it being something it does, it's a precondition now. I could pass the args through. There isn't really a need other than to help people. I added a check in the script with a helpful message.

Copy link
Member

Choose a reason for hiding this comment

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

just use autoninja here, so it knows if it should use goma or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

ios_test_flutter_path = rebase_path("$root_out_dir/libios_test_flutter.dylib")
platform_frameworks_path = "$ios_sdk_path/../../Library/Frameworks/"

# NOTE: This currently only support simulator targets because of the install_name.
Copy link
Member

Choose a reason for hiding this comment

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

ultra nit: s/support/supports/

Copy link
Member Author

Choose a reason for hiding this comment

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

done

"framework/Source/FlutterPluginAppLifeCycleDelegateTest.m",
"framework/Source/FlutterTextInputPluginTest.m",
"framework/Source/FlutterViewControllerTest.mm",
"framework/Source/SemanticsObjectTest.mm",
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there's anything we can do to make sure people don't forget to add to this when creating new files since it could be easy to miss. We should at least have a testing/ios/IosUnitTests/README.md.

Copy link
Member Author

Choose a reason for hiding this comment

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

added a readme

Copy link
Contributor

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

Some minor nits about GN rules but looks good overall.

ocmock_path = "../../../../../third_party/ocmock/Source"

# TODO: Clone the OCMock repository so we can add a BUILD.gn to it.
static_library("ocmock") {
Copy link
Contributor

Choose a reason for hiding this comment

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

This definition goes in //build/secondary/third_party/ocmock/BUILD.gn. Thats where we maintain target build rules for dependencies that don't maintain their own GN rules (or said rules are incompatible with our buildroot.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, while you at it, make this a source_set as that skips the archiving step.

Copy link
Member Author

Choose a reason for hiding this comment

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

This needs to be a static_library because it is linked by xcode's build system when building the testing bundle.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for clarifying.

Copy link
Member Author

Choose a reason for hiding this comment

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

wrt moving the build file. I added those details to the TODO about cloning the repository if we find we can't use chromium's clone. I'll follow up on this, like the other issue I'd like to do anything that involves an extra repo for another PR since i'm juggling this and LUCI already.

configs -= [ "//build/config/compiler:chromium_code" ]
cflags = [
"-fvisibility=default",
"-mios-simulator-version-min=13.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this variable to //build/config/ios/ios_sdk.gni and add this flag to sysroot flags in //build/toolchain/mac/BUILD.gn. See where we add -miphoneos-version-min=, this can go right next to that on simulator targets. Adding sysroot flags on a per target basis quickly gets out of hand.

Copy link
Member Author

Choose a reason for hiding this comment

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

I pulled out the variable, added a todo issue to move it into build. Since this PR already has many moving pieces I want to do it in a separate PR instead of getting another repo involved.

# NOTE: This currently only support simulator targets because of the install_name.
# TODO: Switch the install_name and make the test runner copy the dynamic library
# into the testing bundle.
shared_library("ios_test_flutter") {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be a good idea now to track decommissioning the unused FlutterTests target if this is the way to go to write tests against engine internals with embedding code.

Copy link
Member Author

Choose a reason for hiding this comment

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

That could be useful in the future if someone wanted to do the work of moving the whole build system over to GN. This addition doesn't necessarily obsolesce target. I'll add a note. I'm afraid to rip out something I don't have to touch.

platform_frameworks_path = "$ios_sdk_path/../../Library/Frameworks/"

# NOTE: This currently only support simulator targets because of the install_name.
# TODO: Switch the install_name and make the test runner copy the dynamic library
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and elsewhere: Please file issues for TODOs and cross-reference them by number here.

Copy link
Member Author

Choose a reason for hiding this comment

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

done


- (void)testItReportsDarkPlatformBrightnessWhenTraitCollectionRequestsIt {
if (!@available(iOS 13, *)) {
if (@available(iOS 13, *)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch. How did we miss this earlier? I expect clang had warnings for these.

Copy link
Member Author

Choose a reason for hiding this comment

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

"-Werror" isn't on by default in xcode projects, we were previously using xcode to build them.

#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h"

using namespace flutter;
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Checkout out how it says "never use using directives" then about 50 lines later they use one in an example. Other google projects seem to allow them as long as they are inside of a scoped namespace. I just removed it.

Copy link
Contributor

Choose a reason for hiding this comment

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

lol. WDYT about having our own version of the guidelines? We ought to be able to edit or amend them for clarity.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we want to go that way we should make it an addendum that clarifies ambiguities like this as they show up.

@gaaclarke
Copy link
Member Author

Landed on red to clear out luci errors. (There were warnings as errors as a result to a luci change).

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 15, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 15, 2020
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.

6 participants