Reland "[ios] Adds the ability to run unittests using XCTest."
Original change's description:
> Revert "[ios] Adds the ability to run unittests using XCTest."
>
> This reverts commit b6c231b5f8761d0c95a82432a296b429cb774120.
>
> Reason for revert: Suspected for causing compiling errors on mac.
>
> Original change's description:
> > [ios] Adds the ability to run unittests using XCTest.
> >
> > This new functionality is hidden behind both a GN arg
> > (enable_run_ios_unittests_with_xctest) and a commandline switch
> > (--enable-run-unittests-with-xctest), in order to default it to off
> > until the bots are updated to properly run XCTest-based unittests.
> >
> > The iOS test runner is updated to run in one of two modes. When
> > --enable-run-unittests-with-xctest is false (the default), behavior is
> > unchanged; TestSuite::Run() calls UIApplicationMain(), then the
> > UIApplicationDelegate calls TestSuite::Run() again, which actually runs
> > the tests when invoked the second time. When the switch is set to true,
> > the second invocation of TestSuite::Run() is made by our XCTestCase
> > subclass rather than by the application delegate.
> >
> > Xcode provides the ability to run XCTests and XCUITests from the
> > commandline, but does not provide any other way to install and run an
> > app outside of this test-based workflow. (We had an alternative that
> > used third party libraries, but they no longer work on iOS 13.) This
> > makes it difficult to install and run GoogleTest-based tests on iOS
> > devices, since they run as a single self-contained application, but it
> > would not be practical to drop GoogleTest support on iOS. Instead, we
> > are exploring invoking these tests via XCTest, which would allow us to
> > use Xcode's tooling but still run the same GoogleTest-based tests as on
> > other platforms.
> >
> > BUG=635509
> >
> > Change-Id: I26c67d9c7e16a744f43a20f2d8c5839ca8b3c31a
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787593
> > Reviewed-by: Dirk Pranke <[email protected]>
> > Reviewed-by: Mark Mentovai <[email protected]>
> > Reviewed-by: Justin Cohen <[email protected]>
> > Commit-Queue: Rohit Rao <[email protected]>
> > Cr-Commit-Position: refs/heads/master@{#694749}
>
> [email protected],[email protected],[email protected],[email protected]
>
> Change-Id: Ic67605ab0292551500a163e993c6d93fec3048c0
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 635509,1002144
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1791798
> Reviewed-by: Tarun Bansal <[email protected]>
> Commit-Queue: Tarun Bansal <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#694814}
[email protected],[email protected],[email protected],[email protected],[email protected]
Change-Id: I94e59823c379e1afb4e9e965bfe602d06400e8b5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 635509, 1002144
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1790069
Reviewed-by: Rohit Rao <[email protected]>
Reviewed-by: Mark Mentovai <[email protected]>
Commit-Queue: Rohit Rao <[email protected]>
Cr-Commit-Position: refs/heads/master@{#694950}
diff --git a/testing/test.gni b/testing/test.gni
index ee87c65..491fa35d 100644
--- a/testing/test.gni
+++ b/testing/test.gni
@@ -293,6 +293,14 @@
import("//build/config/ios/ios_sdk.gni")
import("//build/config/ios/rules.gni")
+ declare_args() {
+ # Keep the unittest-as-xctest functionality defaulted to off until the
+ # bots are updated to handle it properly.
+ # TODO(crbug.com/1001667): Remove this arg once the iOS test runner
+ # supports running unittests with xctest.
+ enable_run_ios_unittests_with_xctest = false
+ }
+
_test_target = target_name
_resources_bundle_data = target_name + "_resources_bundle_data"
@@ -306,9 +314,19 @@
]
}
- ios_app_bundle(_test_target) {
+ if (enable_run_ios_unittests_with_xctest) {
+ ios_test_target_type = "ios_xctest_test"
+ } else {
+ ios_test_target_type = "ios_app_bundle"
+ }
+
+ target(ios_test_target_type, _test_target) {
testonly = true
+ if (enable_run_ios_unittests_with_xctest) {
+ xctest_module_target = "//base/test:google_test_runner"
+ }
+
# See above call.
set_sources_assignment_filter([])
forward_variables_from(invoker, "*", [ "testonly" ])