[ios] - Add possibility to configure xctest on a build target basis.
This CL will allow projects (like WebRTC, see [1]) to configure whether
to use XCtest or not on a target by target basis instead of doing it at
build level with the GN arg 'enable_run_ios_unittests_with_xctest'.
[1] - https://webrtc-review.googlesource.com/c/src/+/184360
Bug: webrtc:11937
Change-Id: Ia227b2f5eb268dc59cfbe5617dbfc4836e6ae372
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414169
Reviewed-by: Dirk Pranke <[email protected]>
Commit-Queue: Mirko Bonadei <[email protected]>
Cr-Commit-Position: refs/heads/master@{#807647}
diff --git a/testing/test.gni b/testing/test.gni
index 1fab44d..0187b24f 100644
--- a/testing/test.gni
+++ b/testing/test.gni
@@ -45,7 +45,14 @@
# use_raw_android_executable: Use executable() rather than android_apk().
# use_native_activity: Test implements ANativeActivity_onCreate().
# win_test_enable_cfi_linker: (Win) Enable CFI linker for this test binary.
+# is_xctest: (iOS, optional) whether to build the executable as XCTest.
+# Similar to the GN arg 'enable_run_ios_unittests_with_xctest' but
+# for build targets.
template("test") {
+ if (!is_ios) {
+ assert(!defined(invoker.is_xctest) || !invoker.is_xctest,
+ "is_xctest can be set only for iOS builds")
+ }
if (is_android) {
assert(!defined(invoker.use_xvfb) || !invoker.use_xvfb)
@@ -293,7 +300,10 @@
outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
}
- if (enable_run_ios_unittests_with_xctest) {
+ force_xctest = enable_run_ios_unittests_with_xctest ||
+ (defined(invoker.is_xctest) && invoker.is_xctest)
+
+ if (force_xctest) {
ios_test_target_type = "ios_xctest_test"
} else {
ios_test_target_type = "ios_app_bundle"
@@ -302,7 +312,7 @@
target(ios_test_target_type, _test_target) {
testonly = true
- if (enable_run_ios_unittests_with_xctest && build_with_chromium) {
+ if (force_xctest && build_with_chromium) {
xctest_module_target = "//base/test:google_test_runner"
}