diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5c0242ef04..fe5f3e23ca 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -31,6 +31,9 @@ projects with `bazel run //examples/cc:xcodeproj`. You might need to `cd`
into the directory if the example app is in a separate `WORKSPACE` with
`cd examples/integration; bazel run //:xcodeproj`.
+You can run the internal tests as well:
+`bazel test //test/internal/xcschemes:all`
+
You can even test your changes in a separate project living outside this
repo by overriding the module or repository in your `.bazelrc`.
```
@@ -50,3 +53,17 @@ You can do so with `./test/update_all_fixtures.sh`.
All of the test fixture projects aren't buildable, because we use empty files in
place of things that are the same in every project. If you need to verify
anything in those projects, regenerate them locally.
+
+## Updating docs
+
+Run `./docs/update_docs.sh` to generate to documentation based on the comments.
+
+## Linting and formatting
+
+Before submitting your PR you should run the linter and formatter to
+make sure everything if formatted properly in your bazel files
+
+`bazel run //:buildifier.fix`
+
+you can run `bazel run //:buildifier.check` to make sure your formatting
+is correct.
diff --git a/docs/bazel.md b/docs/bazel.md
index 07615a8c30..8f34cef5b5 100755
--- a/docs/bazel.md
+++ b/docs/bazel.md
@@ -240,12 +240,36 @@ Defines a command-line argument.
| literal_string | Whether `value` should be interpreted as a literal string.
If `True`, any spaces will be escaped. This means that `value` will be passed to the launch target as a single string. If `False`, any spaces will not be escaped. This is useful to group multiple arguments under a single checkbox in Xcode. | `True` |
+
+
+## xcschemes.autogeneration.test
+
+
+xcschemes.autogeneration.test(options)
+
+
+Creates a value for the `test` argument of `xcschemes.autogeneration_config`.
+
+**PARAMETERS**
+
+
+| Name | Description | Default Value |
+| :------------- | :------------- | :------------- |
+| options | Test options for autogeneration.
Defaults to `None`. | `None` |
+
+**RETURNS**
+
+An opaque value for the
+ [`test`](user-content-xcschemes.autogeneration_config-test)
+ argument of `xcschemes.autogeneration_config`.
+
+
## xcschemes.autogeneration_config
-xcschemes.autogeneration_config(scheme_name_exclude_patterns)
+xcschemes.autogeneration_config(scheme_name_exclude_patterns, test)
Creates a value for the [`scheme_autogeneration_config`](xcodeproj-scheme_autogeneration_config) attribute of `xcodeproj`.
@@ -255,7 +279,8 @@ Creates a value for the [`scheme_autogeneration_config`](xcodeproj-scheme_autoge
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
-| scheme_name_exclude_patterns | A `list` of regex patterns used to skip creating matching autogenerated schemes.
Example:
xcodeproj(
...
scheme_name_exclude_patterns = xcschemes.autogeneration_config(
scheme_name_exclude_patterns = [
".*somePattern.*",
"^AnotherPattern.*",
],
)
)
| `None` |
+| scheme_name_exclude_patterns | A `list` of regex patterns used to skip creating matching autogenerated schemes.
Example:
xcodeproj(
...
scheme_name_exclude_patterns = xcschemes.autogeneration_config(
scheme_name_exclude_patterns = [
".*somePattern.*",
"^AnotherPattern.*",
],
),
)
| `None` |
+| test | Options to use for the test action.
Example:
```starlark xcodeproj( ... scheme_autogeneration_config = xcschemes.autogeneration_config( test = xcschemes.autogeneration.test( options = xcschemes.test_options( app_language = "en", app_region = "US", ) ) ) ) | `None` |
**RETURNS**
@@ -499,8 +524,8 @@ Defines a custom scheme.
## xcschemes.test
-xcschemes.test(args, build_targets, diagnostics, env, env_include_defaults, test_targets,
- use_run_args_and_env, xcode_configuration)
+xcschemes.test(args, build_targets, diagnostics, env, env_include_defaults, test_options,
+ test_targets, use_run_args_and_env, xcode_configuration)
Defines the Test action.
@@ -515,11 +540,31 @@ Defines the Test action.
| diagnostics | The diagnostics to enable when testing.
Can be `None` or a value returned by [`xcschemes.diagnostics`](#xcschemes.diagnostics). If `None`, `xcschemes.diagnostics()` will be used, which means no diagnostics will be enabled. | `None` |
| env | Environment variables to use when testing.
If set to `"inherit"`, then the environment variables will be supplied by the test targets (e.g. [`ios_unit_test.env`](https://github.com/bazelbuild/rules_apple/blob/master/doc/rules-ios.md#ios_unit_test-env)), as long as every test target has the same environment variables. Otherwise, the `dict` of environment variables will be set as provided, and `None` or `{}` will result in no environment variables.
Each value of the `dict` can either be a string or a value returned by [`xcschemes.env_value`](#xcschemes.env_value). If a value is a string, it will be transformed into `xcschemes.env_value(value)`. For example, xcschemes.test(
env = {
"VAR1": "value 1",
"VAR 2": xcschemes.env_value("value2", enabled = False),
},
)
will be transformed into: xcschemes.test(
env = {
"VAR1": xcschemes.env_value("value 1"),
"VAR 2": xcschemes.env_value("value2", enabled = False),
},
)
| `"inherit"` |
| env_include_defaults | Whether to include the rules_xcodeproj provided default Bazel environment variables (e.g. `BUILD_WORKING_DIRECTORY` and `BUILD_WORKSPACE_DIRECTORY`), in addition to any set by [`env`](#xcschemes.test-env). | `True` |
+| test_options | The test options to set for testing. Can be `None` or a value returned by [`xcschemes.test_options`](#xcschemes.test_options). If `None`, `xcschemes.test_options()` will be used, which means no additional test options be set. | `None` |
| test_targets | The test targets to build, and possibly run, when testing.
Each element of the `list` can be a label string or a value returned by [`xcschemes.test_target`](#xcschemes.test_target). If an element is a label string, it will be transformed into `xcschemes.test_target(label_str)`. For example, xcschemes.test(
test_targets = [
"//App:Test1",
xcschemes.test_target(
"//App:Test2",
…
),
],
)
will be transformed into: xcschemes.test(
test_targets = [
xcschemes.test_target("//App:Test1"),
xcschemes.test_target(
"//App:Test2",
…
),
],
)
| `[]` |
| use_run_args_and_env | Whether the `Use the Run action's arguments and environment variables` checkbox is checked.
If `True`, command-line arguments and environment variables will still be set as defined by [`args`](#xcschemes.test-args) and [`env`](#xcschemes.test-env), but will be ignored by Xcode unless you manually uncheck this checkbox in the scheme. If `None`, `True` will be used if [`args`](#xcschemes.test-args) and [`env`](#xcschemes.test-env) are both `"inherit"`, otherwise `False` will be used.
A value of `True` will be ignored (i.e. treated as `False`) if [`run.launch_target`](#xcschemes.run-launch_target) is not set to a target. | `None` |
| xcode_configuration | The name of the Xcode configuration to use to build the targets referenced in the Test action (i.e in the [`build_targets`](#xcschemes.test-build_targets) and [`test_targets`](#xcschemes.test-test_targets) attributes).
If not set, the value of [`xcodeproj.default_xcode_configuration`](#xcodeproj-default_xcode_configuration) is used. | `None` |
+
+
+## xcschemes.test_options
+
+
+xcschemes.test_options(app_language, app_region)
+
+
+Defines the test options for a custom scheme.
+
+**PARAMETERS**
+
+
+| Name | Description | Default Value |
+| :------------- | :------------- | :------------- |
+| app_language | Language to set in scheme.
Defaults to system settings if not set. | `None` |
+| app_region | Region to set in scheme.
Defaults to system settings if not set. | `None` |
+
+
## xcschemes.test_target
@@ -836,7 +881,7 @@ A `struct` representing an Xcode scheme.
xcode_schemes.test_action(targets, args, build_configuration, diagnostics, env,
- expand_variables_based_on, pre_actions, post_actions)
+ expand_variables_based_on, options, pre_actions, post_actions)
Constructs a test action for an Xcode scheme.
@@ -852,6 +897,7 @@ Constructs a test action for an Xcode scheme.
| diagnostics | Optional. A value returned by `xcode_schemes.diagnostics`. | `None` |
| env | Optional. A `dict` of `string` values that will be set as environment variables when the target is executed.
If both this and `args` are `None` (not just empty), then the launch action's environment variables will be inherited. | `None` |
| expand_variables_based_on | Optional. One of the specified test target labels.
If no value is provided, one of the test targets will be selected. If no expansion context is desired, use the `string` value `none`. | `None` |
+| options | Optional. A value returned by `xcode_schemes.test_options`. | `None` |
| pre_actions | Optional. A `sequence` of `struct` values as created by `xcode_schemes.pre_post_action`. | `[]` |
| post_actions | Optional. A `sequence` of `struct` values as created by `xcode_schemes.pre_post_action`. | `[]` |
diff --git a/examples/integration/test/fixtures/bwb_custom_xcode_schemes.json b/examples/integration/test/fixtures/bwb_custom_xcode_schemes.json
index 8c45c97816..4b468045e7 100644
--- a/examples/integration/test/fixtures/bwb_custom_xcode_schemes.json
+++ b/examples/integration/test/fixtures/bwb_custom_xcode_schemes.json
@@ -12,6 +12,7 @@
"IOSAPPSWIFTUNITTESTS_CUSTOMSCHEMEVAR": "TRUE"
},
"expand_variables_based_on": null,
+ "options": null,
"post_actions": [
{
"expand_variables_based_on": "@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTests",
@@ -39,6 +40,7 @@
"IOSAPPSWIFTUNITTESTS_CUSTOMSCHEMEVAR": "TRUE"
},
"expand_variables_based_on": null,
+ "options": null,
"post_actions": [],
"pre_actions": [],
"targets": [
@@ -61,6 +63,7 @@
"IOSAPPSWIFTUNITTESTS_CUSTOMSCHEMEVAR": "TRUE"
},
"expand_variables_based_on": null,
+ "options": null,
"post_actions": [
{
"expand_variables_based_on": "@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTestSuite",
diff --git a/examples/integration/test/fixtures/generated/xcodeproj_bwb/custom_xcode_schemes.json b/examples/integration/test/fixtures/generated/xcodeproj_bwb/custom_xcode_schemes.json
index e7074100b2..79c4bca4c3 100755
--- a/examples/integration/test/fixtures/generated/xcodeproj_bwb/custom_xcode_schemes.json
+++ b/examples/integration/test/fixtures/generated/xcodeproj_bwb/custom_xcode_schemes.json
@@ -1 +1 @@
-[{"build_action":null,"launch_action":null,"name":"iOSAppUnitTests_Scheme","profile_action":null,"test_action":{"args":null,"build_configuration":null,"diagnostics":null,"env":{"IOSAPPSWIFTUNITTESTS_CUSTOMSCHEMEVAR":"TRUE"},"expand_variables_based_on":null,"post_actions":[{"expand_variables_based_on":"@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTests","name":"Run After Tests","script":"echo \"Hi\""}],"pre_actions":[],"targets":["@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTests","@@//iOSApp/Test/ObjCUnitTests:iOSAppObjCUnitTests"]}},{"build_action":null,"launch_action":null,"name":"iOSAppSwiftUnitTests_Scheme","profile_action":null,"test_action":{"args":null,"build_configuration":"AppStore","diagnostics":null,"env":{"IOSAPPSWIFTUNITTESTS_CUSTOMSCHEMEVAR":"TRUE"},"expand_variables_based_on":null,"post_actions":[],"pre_actions":[],"targets":["@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTests"]}},{"build_action":null,"launch_action":null,"name":"iOSAppUnitTestSuite_CommandLineArgs_Scheme","profile_action":null,"test_action":{"args":["--command_line_args=-AppleLanguages,(en)"],"build_configuration":null,"diagnostics":null,"env":{"IOSAPPSWIFTUNITTESTS_CUSTOMSCHEMEVAR":"TRUE"},"expand_variables_based_on":null,"post_actions":[{"expand_variables_based_on":"@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTestSuite","name":"Run After Tests","script":"echo \"Hi\""}],"pre_actions":[],"targets":["@@//iOSApp/Test/ObjCUnitTests:iOSAppObjCUnitTestSuite","@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTestSuite"]}}]
+[{"build_action":null,"launch_action":null,"name":"iOSAppUnitTests_Scheme","profile_action":null,"test_action":{"args":null,"build_configuration":null,"diagnostics":null,"env":{"IOSAPPSWIFTUNITTESTS_CUSTOMSCHEMEVAR":"TRUE"},"expand_variables_based_on":null,"options":null,"post_actions":[{"expand_variables_based_on":"@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTests","name":"Run After Tests","script":"echo \"Hi\""}],"pre_actions":[],"targets":["@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTests","@@//iOSApp/Test/ObjCUnitTests:iOSAppObjCUnitTests"]}},{"build_action":null,"launch_action":null,"name":"iOSAppSwiftUnitTests_Scheme","profile_action":null,"test_action":{"args":null,"build_configuration":"AppStore","diagnostics":null,"env":{"IOSAPPSWIFTUNITTESTS_CUSTOMSCHEMEVAR":"TRUE"},"expand_variables_based_on":null,"options":null,"post_actions":[],"pre_actions":[],"targets":["@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTests"]}},{"build_action":null,"launch_action":null,"name":"iOSAppUnitTestSuite_CommandLineArgs_Scheme","profile_action":null,"test_action":{"args":["--command_line_args=-AppleLanguages,(en)"],"build_configuration":null,"diagnostics":null,"env":{"IOSAPPSWIFTUNITTESTS_CUSTOMSCHEMEVAR":"TRUE"},"expand_variables_based_on":null,"options":null,"post_actions":[{"expand_variables_based_on":"@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTestSuite","name":"Run After Tests","script":"echo \"Hi\""}],"pre_actions":[],"targets":["@@//iOSApp/Test/ObjCUnitTests:iOSAppObjCUnitTestSuite","@@//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTestSuite"]}}]
diff --git a/examples/integration/xcodeproj_targets.bzl b/examples/integration/xcodeproj_targets.bzl
index 4f94f22eef..8417f39a56 100644
--- a/examples/integration/xcodeproj_targets.bzl
+++ b/examples/integration/xcodeproj_targets.bzl
@@ -151,6 +151,12 @@ SCHEME_AUTOGENERATION_CONFIG = xcschemes.autogeneration_config(
".*UndesiredScheme.*",
".*UnwantedScheme.*",
],
+ test = xcschemes.autogeneration.test(
+ options = xcschemes.test_options(
+ app_language = "en",
+ app_region = "US",
+ ),
+ ),
)
def get_xcode_schemes():
@@ -238,6 +244,10 @@ XCSCHEMES = [
env = {
"IOSAPPSWIFTUNITTESTS_CUSTOMSCHEMEVAR": "TRUE",
},
+ test_options = xcschemes.test_options(
+ app_language = "en",
+ app_region = "US",
+ ),
test_targets = [
"//iOSApp/Test/SwiftUnitTests:iOSAppSwiftUnitTests",
],
diff --git a/test/internal/xcode_schemes/model_tests.bzl b/test/internal/xcode_schemes/model_tests.bzl
index 05aef43a53..84f0796dc3 100644
--- a/test/internal/xcode_schemes/model_tests.bzl
+++ b/test/internal/xcode_schemes/model_tests.bzl
@@ -165,6 +165,7 @@ def _test_action_test(ctx):
diagnostics = None,
env = None,
expand_variables_based_on = None,
+ options = None,
pre_actions = [],
post_actions = [],
)
@@ -180,6 +181,7 @@ def _test_action_test(ctx):
diagnostics = None,
env = custom_env,
expand_variables_based_on = None,
+ options = None,
pre_actions = [],
post_actions = [],
)
@@ -198,6 +200,7 @@ def _test_action_test(ctx):
diagnostics = None,
env = {},
expand_variables_based_on = "none",
+ options = None,
pre_actions = [],
post_actions = [],
)
@@ -219,6 +222,7 @@ def _test_action_test(ctx):
diagnostics = None,
env = None,
expand_variables_based_on = bazel_labels.normalize_string(targets[0]),
+ options = None,
pre_actions = [],
post_actions = [],
)
diff --git a/test/internal/xcschemes/info_constructors_tests.bzl b/test/internal/xcschemes/info_constructors_tests.bzl
index cd3dcdfa7d..3036f69e82 100644
--- a/test/internal/xcschemes/info_constructors_tests.bzl
+++ b/test/internal/xcschemes/info_constructors_tests.bzl
@@ -259,6 +259,37 @@ def info_constructors_test_suite(name):
),
)
+ # make_test_options
+
+ _add_test(
+ name = "{}_make_test_options_minimal".format(name),
+
+ # Inputs
+ info = xcscheme_infos_testable.make_test_options(),
+
+ # Expected
+ expected_info = struct(
+ app_language = "",
+ app_region = "",
+ ),
+ )
+
+ _add_test(
+ name = "{}_make_test_options_full".format(name),
+
+ # Inputs
+ info = xcscheme_infos_testable.make_test_options(
+ app_language = "en",
+ app_region = "US",
+ ),
+
+ # Expected
+ expected_info = struct(
+ app_language = "en",
+ app_region = "US",
+ ),
+ )
+
# make_launch_target
_add_test(
@@ -688,6 +719,7 @@ def info_constructors_test_suite(name):
diagnostics = xcscheme_infos_testable.make_diagnostics(),
env = None,
env_include_defaults = "0",
+ options = xcscheme_infos_testable.make_test_options(),
test_targets = [],
use_run_args_and_env = "1",
xcode_configuration = "",
@@ -721,6 +753,10 @@ def info_constructors_test_suite(name):
"VAR 1": xcscheme_infos_testable.make_env("value\n1"),
},
env_include_defaults = "1",
+ options = xcscheme_infos_testable.make_test_options(
+ app_language = "en",
+ app_region = "US",
+ ),
test_targets = [
xcscheme_infos_testable.make_test_target("tt 9"),
xcscheme_infos_testable.make_test_target("tt 0"),
@@ -754,6 +790,10 @@ def info_constructors_test_suite(name):
"VAR 1": xcscheme_infos_testable.make_env("value\n1"),
},
env_include_defaults = "1",
+ options = xcscheme_infos_testable.make_test_options(
+ app_language = "en",
+ app_region = "US",
+ ),
test_targets = [
xcscheme_infos_testable.make_test_target("tt 9"),
xcscheme_infos_testable.make_test_target("tt 0"),
diff --git a/test/internal/xcschemes/infos_from_json_tests.bzl b/test/internal/xcschemes/infos_from_json_tests.bzl
index 5c6d421783..fd0776a91d 100644
--- a/test/internal/xcschemes/infos_from_json_tests.bzl
+++ b/test/internal/xcschemes/infos_from_json_tests.bzl
@@ -904,6 +904,7 @@ def infos_from_json_test_suite(name):
diagnostics = None,
env = "inherit",
env_include_defaults = "0",
+ options = None,
test_targets = [],
use_run_args_and_env = "1",
xcode_configuration = "",
@@ -952,6 +953,10 @@ def infos_from_json_test_suite(name):
),
env = full_env,
env_include_defaults = "1",
+ options = struct(
+ app_language = "en",
+ app_region = "US",
+ ),
test_targets = [
"tt 1 label",
struct(
@@ -1040,6 +1045,10 @@ def infos_from_json_test_suite(name):
),
env = expected_full_env,
env_include_defaults = "1",
+ options = xcscheme_infos_testable.make_test_options(
+ app_language = "en",
+ app_region = "US",
+ ),
test_targets = [
xcscheme_infos_testable.make_test_target("sim tt 1"),
xcscheme_infos_testable.make_test_target(
diff --git a/test/internal/xcschemes/utils.bzl b/test/internal/xcschemes/utils.bzl
index 9de3db75c7..0aa2fff8be 100644
--- a/test/internal/xcschemes/utils.bzl
+++ b/test/internal/xcschemes/utils.bzl
@@ -20,6 +20,12 @@ def _dict_to_diagnostics_info(d):
thread_performance_checker = d["thread_performance_checker"],
)
+def _dict_to_test_options_info(d):
+ return struct(
+ app_language = d["app_language"],
+ app_region = d["app_region"],
+ )
+
def _dict_to_launch_target_info(d):
if d["is_path"] == "1":
return struct(
@@ -68,6 +74,7 @@ def _dict_to_test_info(d):
diagnostics = _dict_to_diagnostics_info(d["diagnostics"]),
env = _dict_of_dicts_to_env_infos(d["env"]),
env_include_defaults = d["env_include_defaults"],
+ options = _dict_to_test_options_info(d["options"]),
test_targets = _dicts_to_test_target_infos(d["test_targets"]),
use_run_args_and_env = d["use_run_args_and_env"],
xcode_configuration = d["xcode_configuration"],
diff --git a/test/internal/xcschemes/write_schemes_tests.bzl b/test/internal/xcschemes/write_schemes_tests.bzl
index 0a1cd1ebb2..35b920991a 100644
--- a/test/internal/xcschemes/write_schemes_tests.bzl
+++ b/test/internal/xcschemes/write_schemes_tests.bzl
@@ -611,6 +611,10 @@ def write_schemes_test_suite(name):
),
},
env_include_defaults = "1",
+ options = xcscheme_infos_testable.make_test_options(
+ app_language = "en",
+ app_region = "US",
+ ),
test_targets = [
xcscheme_infos_testable.make_test_target(
enabled = "0",
@@ -693,317 +697,199 @@ def write_schemes_test_suite(name):
"some/consolidation_maps/1",
],
expected_writes = {
- _CUSTOM_SCHEMES_DECLARED_FILE: "\n".join([
- # schemeCount
- "3",
- # - name
- "Scheme 2",
- # - test - testTargetCount
- "0",
- # - test - buildTargets
- "",
- # - test - commandLineArguments count
- "-1",
- # - test - environmentVariables count
- "-1",
- # - test - environmentVariablesIncludeDefaults
- "0",
- # - test - useRunArgsAndEnv
- "1",
- # - test - enableAddressSanitizer
- "0",
- # - test - enableThreadSanitizer
- "0",
- # - test - enableUBSanitizer
- "0",
- # - test - enableMainThreadChecker
- "1",
- # - test - enableThreadPerformanceChecker
- "1",
- # - test - xcodeConfiguration
- "",
- # - run - buildTargets
- "",
- # - run - commandLineArguments count
- "-1",
- # - run - environmentVariables count
- "-1",
- # - run - environmentVariablesIncludeDefaults
+ _EXECUTION_ACTIONS_DECLARED_FILE: "\n".join([
+ # schemeName
+ "Scheme 1",
+ # action
+ "test",
+ # isPreAction
"1",
- # - run - enableAddressSanitizer
- "0",
- # - run - enableThreadSanitizer
- "0",
- # - run - enableUBSanitizer
- "0",
- # - test - enableMainThreadChecker
+ # title
+ "test tt 1 pre test title",
+ # scriptText
+ "test tt 1 pre test",
+ # id
+ "test tt 1",
+ # order
"1",
- # - test - enableThreadPerformanceChecker
+
+ # schemeName
+ "Scheme 1",
+ # action
+ "build",
+ # isPreAction
"1",
- # - run - xcodeConfiguration
+ # title
+ "test tt 1 pre build title",
+ # scriptText
+ "test tt 1 pre build",
+ # id
+ "test tt 1",
+ # order
"",
- # - run - launchTarget - isPath
+
+ # schemeName
+ "Scheme 1",
+ # action
+ "build",
+ # isPreAction
"0",
- # - run - launchTarget - id
- "",
- # - run - launchTarget - extensionHostID
- "",
- # - run - customWorkingDirectory
- "",
- # - profile - buildTargets
+ # title
+ "test tt 1 post build title",
+ # scriptText
+ "test tt 1 post\0build",
+ # id
+ "test tt 1",
+ # order
"",
- # - profile - commandLineArguments count
- "-1",
- # - profile - environmentVariables count
- "-1",
- # - profile - environmentVariablesIncludeDefaults
+
+ # schemeName
+ "Scheme 1",
+ # action
+ "test",
+ # isPreAction
"0",
- # - profile - useRunArgsAndEnv
+ # title
+ "test tt 1 post\0test title",
+ # scriptText
+ "test tt 1 post test",
+ # id
+ "test tt 1",
+ # order
+ "42",
+
+ # schemeName
+ "Scheme 1",
+ # action
+ "test",
+ # isPreAction
"1",
- # - profile - xcodeConfiguration
- "",
- # - profile - launchTarget - isPath
- "0",
- # - profile - launchTarget - id
- "",
- # - profile - launchTarget - extensionHostID
- "",
- # - profile - customWorkingDirectory
- "",
+ # title
+ "test bt 1 pre test title",
+ # scriptText
+ "test bt 1 pre test",
+ # id
+ "test bt 1",
+ # order
+ "6",
- # - name
+ # schemeName
"Scheme 1",
- # - test - testTargetCount
- "2",
- # - test - testTargets - id
- "test tt 1",
- # - test - testTargets - enabled
- "0",
- # - test - testTargets - id
- "test tt 2",
- # - test - testTargets - enabled
+ # action
+ "build",
+ # isPreAction
"1",
- # - test - buildTargets
- "test bt 2",
+ # title
+ "test bt 1 pre build title",
+ # scriptText
+ "test bt 1 pre build",
+ # id
+ "test bt 1",
+ # order
+ "7",
+
+ # schemeName
+ "Scheme 1",
+ # action
+ "test",
+ # isPreAction
+ "0",
+ # title
+ "test bt 1 post test title",
+ # scriptText
+ "test bt 1 post test",
+ # id
"test bt 1",
+ # order
"",
- # - test - commandLineArguments count
- "1",
- # - test - commandLineArguments - value
- "-v",
- # - test - commandLineArguments - enabled
+
+ # schemeName
+ "Scheme 1",
+ # action
+ "build",
+ # isPreAction
"0",
- # - test - commandLineArguments - literalString
- "1",
- # - test - environmentVariables count
+ # title
+ "test bt 1 post build title",
+ # scriptText
+ "test bt 1 post build",
+ # id
+ "test bt 1",
+ # order
+ "2",
+
+ # schemeName
+ "Scheme 1",
+ # action
+ "run",
+ # isPreAction
"1",
- # - test - environmentVariables - key
- "VAR\0WITH\0NEWLINES",
- # - test - environmentVariables - value
- "simple",
- # - test - environmentVariables - enabled
- "0",
- # - test - environmentVariablesIncludeDefaults
+ # title
+ "run bt pre run title",
+ # scriptText
+ "run bt pre run",
+ # id
+ "run bt",
+ # order
+ "10",
+
+ # schemeName
+ "Scheme 1",
+ # action
+ "build",
+ # isPreAction
"1",
- # - test - useRunArgsAndEnv
+ # title
+ "run bt\0pre build title",
+ # scriptText
+ "run bt pre build",
+ # id
+ "run bt",
+ # order
+ "100",
+
+ # schemeName
+ "Scheme 1",
+ # action
+ "run",
+ # isPreAction
"0",
- # - test - enableAddressSanitizer
- "1",
- # - test - enableThreadSanitizer
- "1",
- # - test - enableUBSanitizer
- "1",
- # - test - enableMainThreadChecker
- "1",
- # - test - enableThreadPerformanceChecker
- "1",
- # - test - xcodeConfiguration
- "Test",
- # - run - buildTargets
+ # title
+ "run bt post run title",
+ # scriptText
+ "run bt post run",
+ # id
"run bt",
- "",
- # - run - commandLineArguments count
- "2",
- # - run - commandLineArguments - value
- "a",
- # - run - commandLineArguments - enabled
- "0",
- # - run - commandLineArguments - literalString
- "1",
- # - run - commandLineArguments - value
- "bb",
- # - run - commandLineArguments - enabled
- "1",
- # - run - commandLineArguments - literalString
- "1",
- # - run - environmentVariables count
- "2",
- # - run - environmentVariables - key
- "A",
- # - run - environmentVariables - value
- "value with spaces",
- # - run - environmentVariables - enabled
- "0",
- # - run - environmentVariables - key
- "VAR WITH SPACES",
- # - run - environmentVariables - value
- "value\0with\0newlines",
- # - run - environmentVariables - enabled
- "1",
- # - run - environmentVariablesIncludeDefaults
- "0",
- # - run - enableAddressSanitizer
- "1",
- # - run - enableThreadSanitizer
- "1",
- # - run - enableUBSanitizer
- "1",
- # - test - enableMainThreadChecker
- "1",
- # - test - enableThreadPerformanceChecker
- "1",
- # - run - xcodeConfiguration
- "Run",
- # - run - launchTarget - isPath
- "0",
- # - run - launchTarget - id
- "run launch id",
- # - run - launchTarget - extensionHostID
- "run extension host id",
- # - run - customWorkingDirectory
- "run working dir",
- # - profile - buildTargets
- "profile bt",
- "",
- # - profile - commandLineArguments count
- "3",
- # - profile - commandLineArguments - value
- "simple value",
- # - profile - commandLineArguments - enabled
- "1",
- # - profile - commandLineArguments - literalString
- "1",
- # - profile - commandLineArguments - value
- "simple value",
- # - profile - commandLineArguments - enabled
- "1",
- # - profile - commandLineArguments - literalString
- "0",
- # - profile - commandLineArguments - value
- "value\0with\0newlines",
- # - profile - commandLineArguments - enabled
- "0",
- # - profile - commandLineArguments - literalString
- "1",
- # - profile - environmentVariables count
- "1",
- # - profile - environmentVariables - key
- "B",
- # - profile - environmentVariables - value
- "a",
- # - profile - environmentVariables - enabled
- "1",
- # - profile - environmentVariablesIncludeDefaults
- "1",
- # - profile - useRunArgsAndEnv
- "0",
- # - profile - xcodeConfiguration
- "Profile",
- # - profile - launchTarget - isPath
- "0",
- # - profile - launchTarget - id
- "profile launch id",
- # - profile - launchTarget - extensionHostID
- "profile extension host id",
- # - profile - customWorkingDirectory
- "profile working dir",
+ # order
+ "9",
- # - name
- "Scheme 3",
- # - test - testTargetCount
- "0",
- # - test - buildTargets
- "",
- # - test - commandLineArguments count
- "-1",
- # - test - environmentVariables count
- "-1",
- # - test - environmentVariablesIncludeDefaults
- "0",
- # - test - useRunArgsAndEnv
- "1",
- # - test - enableAddressSanitizer
- "0",
- # - test - enableThreadSanitizer
- "0",
- # - test - enableUBSanitizer
- "0",
- # - test - enableMainThreadChecker
- "1",
- # - test - enableThreadPerformanceChecker
- "1",
- # - test - xcodeConfiguration
- "",
- # - run - buildTargets
- "",
- # - run - commandLineArguments count
- "-1",
- # - run - environmentVariables count
- "-1",
- # - run - environmentVariablesIncludeDefaults
- "1",
- # - run - enableAddressSanitizer
- "0",
- # - run - enableThreadSanitizer
- "0",
- # - run - enableUBSanitizer
- "0",
- # - test - enableMainThreadChecker
- "1",
- # - test - enableThreadPerformanceChecker
- "1",
- # - run - xcodeConfiguration
- "",
- # - run - launchTarget - isPath
- "1",
- # - run - launchTarget - path
- "/Foo/Bar.app",
- # - run - customWorkingDirectory
- "",
- # - profile - buildTargets
- "",
- # - profile - commandLineArguments count
- "-1",
- # - profile - environmentVariables count
- "-1",
- # - profile - environmentVariablesIncludeDefaults
- "0",
- # - profile - useRunArgsAndEnv
- "1",
- # - profile - xcodeConfiguration
- "",
- # - profile - launchTarget - isPath
+ # schemeName
+ "Scheme 1",
+ # action
+ "build",
+ # isPreAction
"0",
- # - profile - launchTarget - id
- "",
- # - profile - launchTarget - extensionHostID
- "",
- # - profile - customWorkingDirectory
- "",
- ]) + "\n",
- _EXECUTION_ACTIONS_DECLARED_FILE: "\n".join([
+ # title
+ "run bt post build title",
+ # scriptText
+ "run\0bt post build",
+ # id
+ "run bt",
+ # order
+ "11",
+
# schemeName
"Scheme 1",
# action
- "test",
+ "run",
# isPreAction
"1",
# title
- "test tt 1 pre test title",
+ "run launch pre run title",
# scriptText
- "test tt 1 pre test",
+ "run launch pre run",
# id
- "test tt 1",
+ "run launch id",
# order
"1",
@@ -1014,58 +900,58 @@ def write_schemes_test_suite(name):
# isPreAction
"1",
# title
- "test tt 1 pre build title",
+ "run launch\0pre build title",
# scriptText
- "test tt 1 pre build",
+ "run launch pre build",
# id
- "test tt 1",
+ "run launch id",
# order
"",
# schemeName
"Scheme 1",
# action
- "build",
+ "run",
# isPreAction
"0",
# title
- "test tt 1 post build title",
+ "run launch post run title",
# scriptText
- "test tt 1 post\0build",
+ "run launch post run",
# id
- "test tt 1",
+ "run launch id",
# order
"",
# schemeName
"Scheme 1",
# action
- "test",
+ "build",
# isPreAction
"0",
# title
- "test tt 1 post\0test title",
+ "run launch post build title",
# scriptText
- "test tt 1 post test",
+ "run\0launch post build",
# id
- "test tt 1",
+ "run launch id",
# order
- "42",
+ "2",
# schemeName
"Scheme 1",
# action
- "test",
+ "profile",
# isPreAction
"1",
# title
- "test bt 1 pre test title",
+ "profile bt pre profile title",
# scriptText
- "test bt 1 pre test",
+ "profile bt pre profile",
# id
- "test bt 1",
+ "profile bt",
# order
- "6",
+ "8",
# schemeName
"Scheme 1",
@@ -1074,28 +960,28 @@ def write_schemes_test_suite(name):
# isPreAction
"1",
# title
- "test bt 1 pre build title",
+ "profile bt\0pre build title",
# scriptText
- "test bt 1 pre build",
+ "profile bt pre build",
# id
- "test bt 1",
+ "profile bt",
# order
- "7",
+ "4",
# schemeName
"Scheme 1",
# action
- "test",
+ "profile",
# isPreAction
"0",
# title
- "test bt 1 post test title",
+ "profile bt post profile title",
# scriptText
- "test bt 1 post test",
+ "profile bt post profile",
# id
- "test bt 1",
+ "profile bt",
# order
- "",
+ "2",
# schemeName
"Scheme 1",
@@ -1104,28 +990,28 @@ def write_schemes_test_suite(name):
# isPreAction
"0",
# title
- "test bt 1 post build title",
+ "profile bt post build title",
# scriptText
- "test bt 1 post build",
+ "profile\0bt post build",
# id
- "test bt 1",
+ "profile bt",
# order
- "2",
+ "3",
# schemeName
"Scheme 1",
# action
- "run",
+ "profile",
# isPreAction
"1",
# title
- "run bt pre run title",
+ "profile launch pre profile title",
# scriptText
- "run bt pre run",
+ "profile launch pre profile",
# id
- "run bt",
+ "profile launch id",
# order
- "10",
+ "1",
# schemeName
"Scheme 1",
@@ -1134,28 +1020,28 @@ def write_schemes_test_suite(name):
# isPreAction
"1",
# title
- "run bt\0pre build title",
+ "profile launch\0pre build title",
# scriptText
- "run bt pre build",
+ "profile launch pre build",
# id
- "run bt",
+ "profile launch id",
# order
- "100",
+ "",
# schemeName
"Scheme 1",
# action
- "run",
+ "profile",
# isPreAction
"0",
# title
- "run bt post run title",
+ "profile launch post profile title",
# scriptText
- "run bt post run",
+ "profile launch post profile",
# id
- "run bt",
+ "profile launch id",
# order
- "9",
+ "",
# schemeName
"Scheme 1",
@@ -1164,195 +1050,325 @@ def write_schemes_test_suite(name):
# isPreAction
"0",
# title
- "run bt post build title",
+ "profile launch post build title",
# scriptText
- "run\0bt post build",
+ "profile\0launch post build",
# id
- "run bt",
+ "profile launch id",
# order
- "11",
-
- # schemeName
- "Scheme 1",
- # action
- "run",
- # isPreAction
+ "2",
+ ]) + "\n",
+ _TARGETS_ARGS_ENV_DECLARED_FILE: no_target_args_and_env_content,
+ _CUSTOM_SCHEMES_DECLARED_FILE: "\n".join([
+ # schemeCount
+ "3",
+ # - name
+ "Scheme 2",
+ # - test - testTargetCount
+ "0",
+ # - test - buildTargets
+ "",
+ # - test - commandLineArguments count
+ "-1",
+ # - test - environmentVariables count
+ "-1",
+ # - test - environmentVariablesIncludeDefaults
+ "0",
+ # - test - useRunArgsAndEnv
"1",
- # title
- "run launch pre run title",
- # scriptText
- "run launch pre run",
- # id
- "run launch id",
- # order
+ # - test - enableAddressSanitizer
+ "0",
+ # - test - enableThreadSanitizer
+ "0",
+ # - test - enableUBSanitizer
+ "0",
+ # - test - enableMainThreadChecker
"1",
-
- # schemeName
- "Scheme 1",
- # action
- "build",
- # isPreAction
+ # - test - enableThreadPerformanceChecker
"1",
- # title
- "run launch\0pre build title",
- # scriptText
- "run launch pre build",
- # id
- "run launch id",
- # order
+ # - test - app_language
"",
-
- # schemeName
- "Scheme 1",
- # action
- "run",
- # isPreAction
+ # - test - app_region
+ "",
+ # - test - xcodeConfiguration
+ "",
+ # - run - buildTargets
+ "",
+ # - run - commandLineArguments count
+ "-1",
+ # - run - environmentVariables count
+ "-1",
+ # - run - environmentVariablesIncludeDefaults
+ "1",
+ # - run - enableAddressSanitizer
"0",
- # title
- "run launch post run title",
- # scriptText
- "run launch post run",
- # id
- "run launch id",
- # order
+ # - run - enableThreadSanitizer
+ "0",
+ # - run - enableUBSanitizer
+ "0",
+ # - test - enableMainThreadChecker
+ "1",
+ # - test - enableThreadPerformanceChecker
+ "1",
+ # - run - xcodeConfiguration
"",
-
- # schemeName
- "Scheme 1",
- # action
- "build",
- # isPreAction
+ # - run - launchTarget - isPath
"0",
- # title
- "run launch post build title",
- # scriptText
- "run\0launch post build",
- # id
- "run launch id",
- # order
- "2",
-
- # schemeName
- "Scheme 1",
- # action
- "profile",
- # isPreAction
+ # - run - launchTarget - id
+ "",
+ # - run - launchTarget - extensionHostID
+ "",
+ # - run - customWorkingDirectory
+ "",
+ # - profile - buildTargets
+ "",
+ # - profile - commandLineArguments count
+ "-1",
+ # - profile - environmentVariables count
+ "-1",
+ # - profile - environmentVariablesIncludeDefaults
+ "0",
+ # - profile - useRunArgsAndEnv
"1",
- # title
- "profile bt pre profile title",
- # scriptText
- "profile bt pre profile",
- # id
- "profile bt",
- # order
- "8",
+ # - profile - xcodeConfiguration
+ "",
+ # - profile - launchTarget - isPath
+ "0",
+ # - profile - launchTarget - id
+ "",
+ # - profile - launchTarget - extensionHostID
+ "",
+ # - profile - customWorkingDirectory
+ "",
- # schemeName
+ # - name
"Scheme 1",
- # action
- "build",
- # isPreAction
+ # - test - testTargetCount
+ "2",
+ # - test - testTargets - id
+ "test tt 1",
+ # - test - testTargets - enabled
+ "0",
+ # - test - testTargets - id
+ "test tt 2",
+ # - test - testTargets - enabled
"1",
- # title
- "profile bt\0pre build title",
- # scriptText
- "profile bt pre build",
- # id
- "profile bt",
- # order
- "4",
-
- # schemeName
- "Scheme 1",
- # action
- "profile",
- # isPreAction
+ # - test - buildTargets
+ "test bt 2",
+ "test bt 1",
+ "",
+ # - test - commandLineArguments count
+ "1",
+ # - test - commandLineArguments - value
+ "-v",
+ # - test - commandLineArguments - enabled
"0",
- # title
- "profile bt post profile title",
- # scriptText
- "profile bt post profile",
- # id
- "profile bt",
- # order
+ # - test - commandLineArguments - literalString
+ "1",
+ # - test - environmentVariables count
+ "1",
+ # - test - environmentVariables - key
+ "VAR\0WITH\0NEWLINES",
+ # - test - environmentVariables - value
+ "simple",
+ # - test - environmentVariables - enabled
+ "0",
+ # - test - environmentVariablesIncludeDefaults
+ "1",
+ # - test - useRunArgsAndEnv
+ "0",
+ # - test - enableAddressSanitizer
+ "1",
+ # - test - enableThreadSanitizer
+ "1",
+ # - test - enableUBSanitizer
+ "1",
+ # - test - enableMainThreadChecker
+ "1",
+ # - test - enableThreadPerformanceChecker
+ "1",
+ # - test - app_language
+ "en",
+ # - test - app_region
+ "US",
+ # - test - xcodeConfiguration
+ "Test",
+ # - run - buildTargets
+ "run bt",
+ "",
+ # - run - commandLineArguments count
"2",
-
- # schemeName
- "Scheme 1",
- # action
- "build",
- # isPreAction
+ # - run - commandLineArguments - value
+ "a",
+ # - run - commandLineArguments - enabled
"0",
- # title
- "profile bt post build title",
- # scriptText
- "profile\0bt post build",
- # id
+ # - run - commandLineArguments - literalString
+ "1",
+ # - run - commandLineArguments - value
+ "bb",
+ # - run - commandLineArguments - enabled
+ "1",
+ # - run - commandLineArguments - literalString
+ "1",
+ # - run - environmentVariables count
+ "2",
+ # - run - environmentVariables - key
+ "A",
+ # - run - environmentVariables - value
+ "value with spaces",
+ # - run - environmentVariables - enabled
+ "0",
+ # - run - environmentVariables - key
+ "VAR WITH SPACES",
+ # - run - environmentVariables - value
+ "value\0with\0newlines",
+ # - run - environmentVariables - enabled
+ "1",
+ # - run - environmentVariablesIncludeDefaults
+ "0",
+ # - run - enableAddressSanitizer
+ "1",
+ # - run - enableThreadSanitizer
+ "1",
+ # - run - enableUBSanitizer
+ "1",
+ # - test - enableMainThreadChecker
+ "1",
+ # - test - enableThreadPerformanceChecker
+ "1",
+ # - run - xcodeConfiguration
+ "Run",
+ # - run - launchTarget - isPath
+ "0",
+ # - run - launchTarget - id
+ "run launch id",
+ # - run - launchTarget - extensionHostID
+ "run extension host id",
+ # - run - customWorkingDirectory
+ "run working dir",
+ # - profile - buildTargets
"profile bt",
- # order
+ "",
+ # - profile - commandLineArguments count
"3",
-
- # schemeName
- "Scheme 1",
- # action
- "profile",
- # isPreAction
+ # - profile - commandLineArguments - value
+ "simple value",
+ # - profile - commandLineArguments - enabled
"1",
- # title
- "profile launch pre profile title",
- # scriptText
- "profile launch pre profile",
- # id
- "profile launch id",
- # order
+ # - profile - commandLineArguments - literalString
"1",
-
- # schemeName
- "Scheme 1",
- # action
- "build",
- # isPreAction
+ # - profile - commandLineArguments - value
+ "simple value",
+ # - profile - commandLineArguments - enabled
"1",
- # title
- "profile launch\0pre build title",
- # scriptText
- "profile launch pre build",
- # id
+ # - profile - commandLineArguments - literalString
+ "0",
+ # - profile - commandLineArguments - value
+ "value\0with\0newlines",
+ # - profile - commandLineArguments - enabled
+ "0",
+ # - profile - commandLineArguments - literalString
+ "1",
+ # - profile - environmentVariables count
+ "1",
+ # - profile - environmentVariables - key
+ "B",
+ # - profile - environmentVariables - value
+ "a",
+ # - profile - environmentVariables - enabled
+ "1",
+ # - profile - environmentVariablesIncludeDefaults
+ "1",
+ # - profile - useRunArgsAndEnv
+ "0",
+ # - profile - xcodeConfiguration
+ "Profile",
+ # - profile - launchTarget - isPath
+ "0",
+ # - profile - launchTarget - id
"profile launch id",
- # order
- "",
+ # - profile - launchTarget - extensionHostID
+ "profile extension host id",
+ # - profile - customWorkingDirectory
+ "profile working dir",
- # schemeName
- "Scheme 1",
- # action
- "profile",
- # isPreAction
+ # - name
+ "Scheme 3",
+ # - test - testTargetCount
"0",
- # title
- "profile launch post profile title",
- # scriptText
- "profile launch post profile",
- # id
- "profile launch id",
- # order
+ # - test - buildTargets
"",
-
- # schemeName
- "Scheme 1",
- # action
- "build",
- # isPreAction
+ # - test - commandLineArguments count
+ "-1",
+ # - test - environmentVariables count
+ "-1",
+ # - test - environmentVariablesIncludeDefaults
"0",
- # title
- "profile launch post build title",
- # scriptText
- "profile\0launch post build",
- # id
- "profile launch id",
- # order
- "2",
+ # - test - useRunArgsAndEnv
+ "1",
+ # - test - enableAddressSanitizer
+ "0",
+ # - test - enableThreadSanitizer
+ "0",
+ # - test - enableUBSanitizer
+ "0",
+ # - test - enableMainThreadChecker
+ "1",
+ # - test - enableThreadPerformanceChecker
+ "1",
+ # - test - app_language
+ "",
+ # - test - app_region
+ "",
+ # - test - xcodeConfiguration
+ "",
+ # - run - buildTargets
+ "",
+ # - run - commandLineArguments count
+ "-1",
+ # - run - environmentVariables count
+ "-1",
+ # - run - environmentVariablesIncludeDefaults
+ "1",
+ # - run - enableAddressSanitizer
+ "0",
+ # - run - enableThreadSanitizer
+ "0",
+ # - run - enableUBSanitizer
+ "0",
+ # - test - enableMainThreadChecker
+ "1",
+ # - test - enableThreadPerformanceChecker
+ "1",
+ # - run - xcodeConfiguration
+ "",
+ # - run - launchTarget - isPath
+ "1",
+ # - run - launchTarget - path
+ "/Foo/Bar.app",
+ # - run - customWorkingDirectory
+ "",
+ # - profile - buildTargets
+ "",
+ # - profile - commandLineArguments count
+ "-1",
+ # - profile - environmentVariables count
+ "-1",
+ # - profile - environmentVariablesIncludeDefaults
+ "0",
+ # - profile - useRunArgsAndEnv
+ "1",
+ # - profile - xcodeConfiguration
+ "",
+ # - profile - launchTarget - isPath
+ "0",
+ # - profile - launchTarget - id
+ "",
+ # - profile - launchTarget - extensionHostID
+ "",
+ # - profile - customWorkingDirectory
+ "",
]) + "\n",
- _TARGETS_ARGS_ENV_DECLARED_FILE: no_target_args_and_env_content,
},
)
diff --git a/tools/generators/lib/XCScheme/src/CreateTestAction.swift b/tools/generators/lib/XCScheme/src/CreateTestAction.swift
index bfaa764e83..26c945f774 100644
--- a/tools/generators/lib/XCScheme/src/CreateTestAction.swift
+++ b/tools/generators/lib/XCScheme/src/CreateTestAction.swift
@@ -10,6 +10,8 @@ public struct CreateTestAction {
/// Creates the `TestAction` element of an Xcode scheme.
public func callAsFunction(
+ appLanguage: String?,
+ appRegion: String?,
buildConfiguration: String,
commandLineArguments: [CommandLineArgument],
enableAddressSanitizer: Bool,
@@ -25,6 +27,8 @@ public struct CreateTestAction {
useLaunchSchemeArgsEnv: Bool
) -> String {
return callable(
+ /*appLanguage:*/ appLanguage,
+ /*appRegion:*/ appRegion,
/*buildConfiguration:*/ buildConfiguration,
/*commandLineArguments:*/ commandLineArguments,
/*enableAddressSanitizer:*/ enableAddressSanitizer,
@@ -46,6 +50,8 @@ public struct CreateTestAction {
extension CreateTestAction {
public typealias Callable = (
+ _ appLanguage: String?,
+ _ appRegion: String?,
_ buildConfiguration: String,
_ commandLineArguments: [CommandLineArgument],
_ enableAddressSanitizer: Bool,
@@ -62,6 +68,8 @@ extension CreateTestAction {
) -> String
public static func defaultCallable(
+ appLanguage: String?,
+ appRegion: String?,
buildConfiguration: String,
commandLineArguments: [CommandLineArgument],
enableAddressSanitizer: Bool,
@@ -104,6 +112,13 @@ buildConfiguration = "\#(buildConfiguration)"
components.append(#"disablePerformanceAntipatternChecker = "YES""#)
}
+ if let appLanguage {
+ components.append("language = \"\(appLanguage)\"")
+ }
+ if let appRegion {
+ components.append("region = \"\(appRegion)\"")
+ }
+
let macroExpansion: String
if let macroReference {
macroExpansion = #"""
diff --git a/tools/generators/lib/XCScheme/test/CreateTestActionTests.swift b/tools/generators/lib/XCScheme/test/CreateTestActionTests.swift
index 19e619526f..e8c7ea1372 100644
--- a/tools/generators/lib/XCScheme/test/CreateTestActionTests.swift
+++ b/tools/generators/lib/XCScheme/test/CreateTestActionTests.swift
@@ -384,9 +384,44 @@ final class CreateTestActionTests: XCTestCase {
XCTAssertNoDifference(action, expectedAction)
}
+
+ func test_appLanguageAndAppRegion() {
+ // Arrange
+
+ let buildConfiguration = "Release"
+ let useLaunchSchemeArgsEnv = false
+
+ let expectedAction = #"""
+
+
+
+
+"""#
+
+ // Act
+
+ let action = createTestActionWithDefaults(
+ appLanguage: "en",
+ appRegion: "US",
+ buildConfiguration: buildConfiguration,
+ useLaunchSchemeArgsEnv: useLaunchSchemeArgsEnv
+ )
+
+ // Assert
+
+ XCTAssertNoDifference(action, expectedAction)
+ }
}
private func createTestActionWithDefaults(
+ appLanguage: String? = nil,
+ appRegion: String? = nil,
buildConfiguration: String,
commandLineArguments: [CommandLineArgument] = [],
enableAddressSanitizer: Bool = false,
@@ -402,6 +437,8 @@ private func createTestActionWithDefaults(
useLaunchSchemeArgsEnv: Bool = true
) -> String {
return CreateTestAction.defaultCallable(
+ appLanguage: appLanguage,
+ appRegion: appRegion,
buildConfiguration: buildConfiguration,
commandLineArguments: commandLineArguments,
enableAddressSanitizer: enableAddressSanitizer,
diff --git a/tools/generators/xcschemes/src/Generator/AutogenerationConfigArguments.swift b/tools/generators/xcschemes/src/Generator/AutogenerationConfigArguments.swift
index d6102b0bc9..919d9f1c11 100644
--- a/tools/generators/xcschemes/src/Generator/AutogenerationConfigArguments.swift
+++ b/tools/generators/xcschemes/src/Generator/AutogenerationConfigArguments.swift
@@ -2,6 +2,8 @@ import Foundation
import ToolCommon
struct AutogenerationConfigArguments {
+ let appLanguage: String?
+ let appRegion: String?
let schemeNameExcludePatterns: [String]
static func parse(
@@ -9,12 +11,24 @@ struct AutogenerationConfigArguments {
) async throws -> Self {
var rawArgs = ArraySlice(try await url.allLines.collect())
+ let appLanguage = try rawArgs.consumeArg(
+ "app-language",
+ as: String?.self,
+ in: url
+ )
+ let appRegion = try rawArgs.consumeArg(
+ "app-region",
+ as: String?.self,
+ in: url
+ )
let schemeNameExcludePatterns = try rawArgs.consumeArgs(
"scheme-name-exclude-patterns",
in: url
)
return AutogenerationConfigArguments(
+ appLanguage: appLanguage,
+ appRegion: appRegion,
schemeNameExcludePatterns: schemeNameExcludePatterns
)
}
diff --git a/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfo.swift b/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfo.swift
index 3de219f26b..ea1dcc5072 100644
--- a/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfo.swift
+++ b/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfo.swift
@@ -20,14 +20,16 @@ extension Generator {
customSchemeNames: Set,
environmentVariables: [EnvironmentVariable],
extensionHost: Target?,
- target: Target
+ target: Target,
+ testOptions: SchemeInfo.Test.Options?
) throws -> SchemeInfo? {
return try callable(
/*commandLineArguments:*/ commandLineArguments,
/*customSchemeNames:*/ customSchemeNames,
/*environmentVariables:*/ environmentVariables,
/*extensionHost:*/ extensionHost,
- /*target:*/ target
+ /*target:*/ target,
+ /*testOptions:*/ testOptions
)
}
}
@@ -41,7 +43,8 @@ extension Generator.CreateAutomaticSchemeInfo {
_ customSchemeNames: Set,
_ environmentVariables: [EnvironmentVariable],
_ extensionHost: Target?,
- _ target: Target
+ _ target: Target,
+ _ testOptions: SchemeInfo.Test.Options?
) throws -> SchemeInfo?
static func defaultCallable(
@@ -49,7 +52,8 @@ extension Generator.CreateAutomaticSchemeInfo {
customSchemeNames: Set,
environmentVariables: [EnvironmentVariable],
extensionHost: Target?,
- target: Target
+ target: Target,
+ testOptions: SchemeInfo.Test.Options?
) throws -> SchemeInfo? {
let baseSchemeName = target.buildableReference.blueprintName.schemeName
@@ -118,6 +122,7 @@ extension Generator.CreateAutomaticSchemeInfo {
enableMainThreadChecker: false,
enableThreadPerformanceChecker: false,
environmentVariables: testEnvironmentVariables,
+ options: testOptions,
testTargets: isTest ?
[.init(target: target, isEnabled: true)] : [],
useRunArgsAndEnv: testUseRunArgsAndEnv,
diff --git a/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfos.swift b/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfos.swift
index 0232dd1b7b..3596259a36 100644
--- a/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfos.swift
+++ b/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfos.swift
@@ -32,7 +32,8 @@ extension Generator {
extensionHostIDs: [TargetID: [TargetID]],
targets: [Target],
targetsByID: [TargetID: Target],
- targetsByKey: [Target.Key: Target]
+ targetsByKey: [Target.Key: Target],
+ testOptions: SchemeInfo.Test.Options?
) throws -> [SchemeInfo] {
return try callable(
/*autogenerationMode:*/ autogenerationMode,
@@ -44,7 +45,8 @@ extension Generator {
/*targetsByID:*/ targetsByID,
/*targetsByKey:*/ targetsByKey,
/*createTargetAutomaticSchemeInfos:*/
- createTargetAutomaticSchemeInfos
+ createTargetAutomaticSchemeInfos,
+ /*testOptions:*/ testOptions
)
}
}
@@ -63,7 +65,8 @@ extension Generator.CreateAutomaticSchemeInfos {
_ targetsByID: [TargetID: Target],
_ targetsByKey: [Target.Key: Target],
_ createTargetAutomaticSchemeInfos:
- Generator.CreateTargetAutomaticSchemeInfos
+ Generator.CreateTargetAutomaticSchemeInfos,
+ _ testOptions: SchemeInfo.Test.Options?
) throws -> [SchemeInfo]
static func defaultCallable(
@@ -76,7 +79,8 @@ extension Generator.CreateAutomaticSchemeInfos {
targetsByID: [TargetID: Target],
targetsByKey: [Target.Key: Target],
createTargetAutomaticSchemeInfos:
- Generator.CreateTargetAutomaticSchemeInfos
+ Generator.CreateTargetAutomaticSchemeInfos,
+ testOptions: SchemeInfo.Test.Options?
) throws -> [SchemeInfo] {
let autogenerateSchemes: Bool
switch autogenerationMode {
@@ -118,7 +122,8 @@ extension Generator.CreateAutomaticSchemeInfos {
extensionHostIDs: extensionHostIDs,
target: target,
targetsByID: targetsByID,
- targetsByKey: targetsByKey
+ targetsByKey: targetsByKey,
+ testOptions: testOptions
)
}
}
diff --git a/tools/generators/xcschemes/src/Generator/CreateCustomSchemeInfos.swift b/tools/generators/xcschemes/src/Generator/CreateCustomSchemeInfos.swift
index ba915d3e00..566aec6a4d 100644
--- a/tools/generators/xcschemes/src/Generator/CreateCustomSchemeInfos.swift
+++ b/tools/generators/xcschemes/src/Generator/CreateCustomSchemeInfos.swift
@@ -634,6 +634,16 @@ set
as: String?.self,
in: url
)
+ let appLanguage = try consumeArg(
+ "test-app-language",
+ as: String?.self,
+ in: url
+ )
+ let appRegion = try consumeArg(
+ "test-app-region",
+ as: String?.self,
+ in: url
+ )
let firstTestTargetID = testTargets.first?.target.key.sortedIds.first!
@@ -708,6 +718,8 @@ set
enableMainThreadChecker: enableMainThreadChecker,
enableThreadPerformanceChecker: enableThreadPerformanceChecker,
environmentVariables: environmentVariables,
+ options: .init(appLanguage: appLanguage,
+ appRegion: appRegion),
testTargets: testTargets,
useRunArgsAndEnv: useRunArgsAndEnv,
xcodeConfiguration: xcodeConfiguration
diff --git a/tools/generators/xcschemes/src/Generator/CreateScheme.swift b/tools/generators/xcschemes/src/Generator/CreateScheme.swift
index 2aa1a351ed..e60a83aac9 100644
--- a/tools/generators/xcschemes/src/Generator/CreateScheme.swift
+++ b/tools/generators/xcschemes/src/Generator/CreateScheme.swift
@@ -360,6 +360,8 @@ extension Generator.CreateScheme {
.map(\.action)
),
testAction: createTestAction(
+ appLanguage: schemeInfo.test.options?.appLanguage,
+ appRegion: schemeInfo.test.options?.appRegion,
buildConfiguration: schemeInfo.test.xcodeConfiguration ??
defaultXcodeConfiguration,
commandLineArguments: schemeInfo.test.commandLineArguments,
diff --git a/tools/generators/xcschemes/src/Generator/CreateTargetAutomaticSchemeInfo.swift b/tools/generators/xcschemes/src/Generator/CreateTargetAutomaticSchemeInfo.swift
index 6388b2d2ac..3aa07587e0 100644
--- a/tools/generators/xcschemes/src/Generator/CreateTargetAutomaticSchemeInfo.swift
+++ b/tools/generators/xcschemes/src/Generator/CreateTargetAutomaticSchemeInfo.swift
@@ -29,7 +29,8 @@ extension Generator {
extensionHostIDs: [TargetID: [TargetID]],
target: Target,
targetsByID: [TargetID: Target],
- targetsByKey: [Target.Key: Target]
+ targetsByKey: [Target.Key: Target],
+ testOptions: SchemeInfo.Test.Options?
) throws -> [SchemeInfo] {
return try callable(
/*commandLineArguments:*/ commandLineArguments,
@@ -39,6 +40,7 @@ extension Generator {
/*target:*/ target,
/*targetsByID:*/ targetsByID,
/*targetsByKey:*/ targetsByKey,
+ /*testOptions:*/ testOptions,
/*createAutomaticSchemeInfo:*/ createAutomaticSchemeInfo
)
}
@@ -56,6 +58,7 @@ extension Generator.CreateTargetAutomaticSchemeInfos {
_ target: Target,
_ targetsByID: [TargetID: Target],
_ targetsByKey: [Target.Key: Target],
+ _ testOptions: SchemeInfo.Test.Options?,
_ createAutomaticSchemeInfo: Generator.CreateAutomaticSchemeInfo
) throws -> [SchemeInfo]
@@ -67,6 +70,7 @@ extension Generator.CreateTargetAutomaticSchemeInfos {
target: Target,
targetsByID: [TargetID: Target],
targetsByKey: [Target.Key: Target],
+ testOptions: SchemeInfo.Test.Options?,
createAutomaticSchemeInfo: Generator.CreateAutomaticSchemeInfo
) throws -> [SchemeInfo] {
let extensionHostKeys: Set
@@ -93,7 +97,8 @@ extension Generator.CreateTargetAutomaticSchemeInfos {
customSchemeNames: customSchemeNames,
environmentVariables: environmentVariables,
extensionHost: nil,
- target: target
+ target: target,
+ testOptions: testOptions
) else {
return []
}
@@ -105,7 +110,8 @@ extension Generator.CreateTargetAutomaticSchemeInfos {
customSchemeNames: customSchemeNames,
environmentVariables: environmentVariables,
extensionHost: targetsByKey[key]!,
- target: target
+ target: target,
+ testOptions: testOptions
)
}
}
diff --git a/tools/generators/xcschemes/src/Generator/Generator.swift b/tools/generators/xcschemes/src/Generator/Generator.swift
index ea19b3d969..25fc2ed0d3 100644
--- a/tools/generators/xcschemes/src/Generator/Generator.swift
+++ b/tools/generators/xcschemes/src/Generator/Generator.swift
@@ -35,6 +35,10 @@ struct Generator {
.readTargetArgsAndEnvFile(arguments.targetsArgsEnvFile)
let extensionHostIDs = arguments.calculateExtensionHostIDs()
+ let autogenerationConfigArguments = try await AutogenerationConfigArguments.parse(
+ from: arguments.autogenerationConfigFile
+ )
+
let customSchemeInfos = try await environment.createCustomSchemeInfos(
commandLineArguments: commandLineArguments,
customSchemesFile: arguments.customSchemesFile,
@@ -52,11 +56,9 @@ struct Generator {
extensionHostIDs: extensionHostIDs,
targets: targets,
targetsByID: targetsByID,
- targetsByKey: targetsByKey
- )
-
- let autogenerationConfigArguments = try await AutogenerationConfigArguments.parse(
- from: arguments.autogenerationConfigFile
+ targetsByKey: targetsByKey,
+ testOptions: .init(appLanguage: autogenerationConfigArguments.appLanguage,
+ appRegion: autogenerationConfigArguments.appRegion)
)
let filteredAutomaticSchemeInfos = try automaticSchemeInfos.filter { scheme in
diff --git a/tools/generators/xcschemes/src/Generator/SchemeInfo.swift b/tools/generators/xcschemes/src/Generator/SchemeInfo.swift
index 28cda95c5f..b9b05e1714 100644
--- a/tools/generators/xcschemes/src/Generator/SchemeInfo.swift
+++ b/tools/generators/xcschemes/src/Generator/SchemeInfo.swift
@@ -35,6 +35,11 @@ struct SchemeInfo: Equatable {
}
struct Test: Equatable {
+ struct Options: Equatable {
+ let appLanguage: String?
+ let appRegion: String?
+ }
+
let buildTargets: [Target]
let commandLineArguments: [CommandLineArgument]
let enableAddressSanitizer: Bool
@@ -43,6 +48,7 @@ struct SchemeInfo: Equatable {
let enableMainThreadChecker: Bool
let enableThreadPerformanceChecker: Bool
let environmentVariables: [EnvironmentVariable]
+ let options: Options?
let testTargets: [TestTarget]
let useRunArgsAndEnv: Bool
let xcodeConfiguration: String?
diff --git a/tools/generators/xcschemes/test/CreateAutomaticSchemeInfo+Testing.swift b/tools/generators/xcschemes/test/CreateAutomaticSchemeInfo+Testing.swift
index 913e8c9dfb..c780447e76 100644
--- a/tools/generators/xcschemes/test/CreateAutomaticSchemeInfo+Testing.swift
+++ b/tools/generators/xcschemes/test/CreateAutomaticSchemeInfo+Testing.swift
@@ -13,6 +13,7 @@ extension Generator.CreateAutomaticSchemeInfo {
let environmentVariables: [EnvironmentVariable]
let extensionHost: Target?
let target: Target
+ let testOptions: SchemeInfo.Test.Options?
}
fileprivate(set) var called: [Called] = []
@@ -42,13 +43,15 @@ extension Generator.CreateAutomaticSchemeInfo {
customSchemeNames,
environmentVariables,
extensionHost,
- target in
+ target,
+ testOptions in
mockTracker.called.append(.init(
commandLineArguments: commandLineArguments,
customSchemeNames: customSchemeNames,
environmentVariables: environmentVariables,
extensionHost: extensionHost,
- target: target
+ target: target,
+ testOptions: testOptions
))
return mockTracker.nextResult()
}
diff --git a/tools/generators/xcschemes/test/CreateAutomaticSchemeInfoTests.swift b/tools/generators/xcschemes/test/CreateAutomaticSchemeInfoTests.swift
index d71a53a1ef..95aff2f5a8 100644
--- a/tools/generators/xcschemes/test/CreateAutomaticSchemeInfoTests.swift
+++ b/tools/generators/xcschemes/test/CreateAutomaticSchemeInfoTests.swift
@@ -136,6 +136,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase {
enableMainThreadChecker: false,
enableThreadPerformanceChecker: false,
environmentVariables: [],
+ options: nil,
testTargets: [],
useRunArgsAndEnv: true,
xcodeConfiguration: nil
@@ -217,6 +218,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase {
enableMainThreadChecker: false,
enableThreadPerformanceChecker: false,
environmentVariables: [],
+ options: nil,
testTargets: [],
useRunArgsAndEnv: true,
xcodeConfiguration: nil
@@ -294,6 +296,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase {
enableMainThreadChecker: false,
enableThreadPerformanceChecker: false,
environmentVariables: [],
+ options: nil,
testTargets: [],
useRunArgsAndEnv: true,
xcodeConfiguration: nil
@@ -370,6 +373,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase {
enableMainThreadChecker: false,
enableThreadPerformanceChecker: false,
environmentVariables: [],
+ options: nil,
testTargets: [],
useRunArgsAndEnv: true,
xcodeConfiguration: nil
@@ -445,6 +449,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase {
enableMainThreadChecker: false,
enableThreadPerformanceChecker: false,
environmentVariables: [],
+ options: nil,
testTargets: [],
useRunArgsAndEnv: true,
xcodeConfiguration: nil
@@ -512,6 +517,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase {
enableMainThreadChecker: false,
enableThreadPerformanceChecker: false,
environmentVariables: baseEnvironmentVariables,
+ options: nil,
testTargets: [.init(target: test, isEnabled: true)],
useRunArgsAndEnv: false,
xcodeConfiguration: nil
@@ -582,6 +588,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase {
enableMainThreadChecker: false,
enableThreadPerformanceChecker: false,
environmentVariables: baseEnvironmentVariables,
+ options: nil,
testTargets: [.init(target: test, isEnabled: true)],
useRunArgsAndEnv: false,
xcodeConfiguration: nil
@@ -653,6 +660,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase {
enableThreadPerformanceChecker: false,
environmentVariables:
baseEnvironmentVariables + environmentVariables,
+ options: nil,
testTargets: [.init(target: test, isEnabled: true)],
useRunArgsAndEnv: false,
xcodeConfiguration: nil
@@ -693,6 +701,73 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase {
XCTAssertNoDifference(schemeInfo, expectedSchemeInfo)
}
+
+ func test_test_options() throws {
+ // Arrange
+
+ let test = Target(
+ key: "Test",
+ productType: .unitTestBundle,
+ buildableReference: .init(
+ blueprintIdentifier: "BLUEPRINT_IDENTIFIER_Test",
+ buildableName: "BUILDABLE_NAME_Test",
+ blueprintName: "BLUEPRINT_NAME_Test",
+ referencedContainer: "REFERENCED_CONTAINER_Test"
+ )
+ )
+
+ let expectedSchemeInfo = SchemeInfo(
+ name: "BLUEPRINT_NAME_Test",
+ test: .init(
+ buildTargets: [],
+ commandLineArguments: [],
+ enableAddressSanitizer: false,
+ enableThreadSanitizer: false,
+ enableUBSanitizer: false,
+ enableMainThreadChecker: false,
+ enableThreadPerformanceChecker: false,
+ environmentVariables: baseEnvironmentVariables,
+ options: .init(appLanguage: "en", appRegion: "US"),
+ testTargets: [.init(target: test, isEnabled: true)],
+ useRunArgsAndEnv: false,
+ xcodeConfiguration: nil
+ ),
+ run: .init(
+ buildTargets: [test],
+ commandLineArguments: [],
+ customWorkingDirectory: nil,
+ enableAddressSanitizer: false,
+ enableThreadSanitizer: false,
+ enableUBSanitizer: false,
+ enableMainThreadChecker: false,
+ enableThreadPerformanceChecker: false,
+ environmentVariables: [],
+ launchTarget: nil,
+ xcodeConfiguration: nil
+ ),
+ profile: .init(
+ buildTargets: [],
+ commandLineArguments: [],
+ customWorkingDirectory: nil,
+ environmentVariables: [],
+ launchTarget: nil,
+ useRunArgsAndEnv: true,
+ xcodeConfiguration: nil
+ ),
+ executionActions: []
+ )
+
+ // Act
+
+ let schemeInfo = try createAutomaticSchemeInfoWithDefaults(
+ target: test,
+ testOptions: .init(appLanguage: "en", appRegion: "US")
+ )
+
+ // Assert
+
+ XCTAssertNoDifference(schemeInfo, expectedSchemeInfo)
+ }
}
private let baseEnvironmentVariables: [EnvironmentVariable] = [
@@ -708,14 +783,16 @@ private func createAutomaticSchemeInfoWithDefaults(
customSchemeNames: Set = [],
environmentVariables: [EnvironmentVariable] = [],
extensionHost: Target? = nil,
- target: Target
+ target: Target,
+ testOptions: SchemeInfo.Test.Options? = nil
) throws -> SchemeInfo? {
return try Generator.CreateAutomaticSchemeInfo.defaultCallable(
commandLineArguments: commandLineArguments,
customSchemeNames: customSchemeNames,
environmentVariables: environmentVariables,
extensionHost: extensionHost,
- target: target
+ target: target,
+ testOptions: testOptions
)
}
diff --git a/tools/generators/xcschemes/test/CreateAutomaticSchemeInfosTests.swift b/tools/generators/xcschemes/test/CreateAutomaticSchemeInfosTests.swift
index 9eff921f10..1cee69d301 100644
--- a/tools/generators/xcschemes/test/CreateAutomaticSchemeInfosTests.swift
+++ b/tools/generators/xcschemes/test/CreateAutomaticSchemeInfosTests.swift
@@ -216,7 +216,8 @@ final class CreateAutomaticSchemeInfosTests: XCTestCase {
extensionHostIDs: extensionHostIDs,
target: .mock(key: "C", productType: .application),
targetsByID: targetsByID,
- targetsByKey: targetsByKey
+ targetsByKey: targetsByKey,
+ testOptions: nil
),
.init(
commandLineArguments: [
@@ -229,7 +230,8 @@ final class CreateAutomaticSchemeInfosTests: XCTestCase {
extensionHostIDs: extensionHostIDs,
target: .mock(key: "A", productType: .messagesExtension),
targetsByID: targetsByID,
- targetsByKey: targetsByKey
+ targetsByKey: targetsByKey,
+ testOptions: nil
),
.init(
commandLineArguments: [],
@@ -241,7 +243,8 @@ final class CreateAutomaticSchemeInfosTests: XCTestCase {
extensionHostIDs: extensionHostIDs,
target: .mock(key: "B", productType: .appExtension),
targetsByID: targetsByID,
- targetsByKey: targetsByKey
+ targetsByKey: targetsByKey,
+ testOptions: nil
),
]
let createTargetAutomaticSchemeInfos =
@@ -293,7 +296,8 @@ private func createAutomaticSchemeInfosWithDefaults(
targets: [Target],
targetsByID: [TargetID : Target] = [:],
targetsByKey: [Target.Key : Target] = [:],
- createTargetAutomaticSchemeInfos: Generator.CreateTargetAutomaticSchemeInfos
+ createTargetAutomaticSchemeInfos: Generator.CreateTargetAutomaticSchemeInfos,
+ testOptions: SchemeInfo.Test.Options? = nil
) throws -> [SchemeInfo] {
return try Generator.CreateAutomaticSchemeInfos.defaultCallable(
autogenerationMode: autogenerationMode,
@@ -304,6 +308,7 @@ private func createAutomaticSchemeInfosWithDefaults(
targets: targets,
targetsByID: targetsByID,
targetsByKey: targetsByKey,
- createTargetAutomaticSchemeInfos: createTargetAutomaticSchemeInfos
+ createTargetAutomaticSchemeInfos: createTargetAutomaticSchemeInfos,
+ testOptions: testOptions
)
}
diff --git a/tools/generators/xcschemes/test/CreateTargetAutomaticSchemeInfos+Testing.swift b/tools/generators/xcschemes/test/CreateTargetAutomaticSchemeInfos+Testing.swift
index 3d0f1b00b2..ed0098fd30 100644
--- a/tools/generators/xcschemes/test/CreateTargetAutomaticSchemeInfos+Testing.swift
+++ b/tools/generators/xcschemes/test/CreateTargetAutomaticSchemeInfos+Testing.swift
@@ -15,6 +15,7 @@ extension Generator.CreateTargetAutomaticSchemeInfos {
let target: Target
let targetsByID: [TargetID: Target]
let targetsByKey: [Target.Key: Target]
+ let testOptions: SchemeInfo.Test.Options?
}
fileprivate(set) var called: [Called] = []
@@ -49,6 +50,7 @@ extension Generator.CreateTargetAutomaticSchemeInfos {
target,
targetsByID,
targetsByKey,
+ testOptions,
_ in
mockTracker.called.append(.init(
commandLineArguments: commandLineArguments,
@@ -57,7 +59,8 @@ extension Generator.CreateTargetAutomaticSchemeInfos {
extensionHostIDs: extensionHostIDs,
target: target,
targetsByID: targetsByID,
- targetsByKey: targetsByKey
+ targetsByKey: targetsByKey,
+ testOptions: testOptions
))
return mockTracker.nextResult()
}
diff --git a/tools/generators/xcschemes/test/SchemeInfo+Testing.swift b/tools/generators/xcschemes/test/SchemeInfo+Testing.swift
index 89f40f093e..9868cd1bd9 100644
--- a/tools/generators/xcschemes/test/SchemeInfo+Testing.swift
+++ b/tools/generators/xcschemes/test/SchemeInfo+Testing.swift
@@ -83,6 +83,7 @@ extension SchemeInfo.Test {
enableMainThreadChecker: Bool = false,
enableThreadPerformanceChecker: Bool = false,
environmentVariables: [EnvironmentVariable] = [],
+ options: SchemeInfo.Test.Options = .init(appLanguage: nil, appRegion: nil),
testTargets: [SchemeInfo.TestTarget] = [],
useRunArgsAndEnv: Bool = true,
xcodeConfiguration: String? = nil
@@ -96,6 +97,7 @@ extension SchemeInfo.Test {
enableMainThreadChecker: enableMainThreadChecker,
enableThreadPerformanceChecker: enableThreadPerformanceChecker,
environmentVariables: environmentVariables,
+ options: options,
testTargets: testTargets,
useRunArgsAndEnv: useRunArgsAndEnv,
xcodeConfiguration: xcodeConfiguration
diff --git a/xcodeproj/internal/xcode_schemes.bzl b/xcodeproj/internal/xcode_schemes.bzl
index 3c27fdec0a..5daca94bbf 100644
--- a/xcodeproj/internal/xcode_schemes.bzl
+++ b/xcodeproj/internal/xcode_schemes.bzl
@@ -68,6 +68,7 @@ def focus_schemes(schemes, focused_labels):
args = test_action.args,
diagnostics = test_action.diagnostics,
env = test_action.env,
+ options = test_action.options,
pre_actions = [
pre_action
for pre_action in test_action.pre_actions
@@ -433,6 +434,7 @@ also be modified in Xcode.
diagnostics = None,
env = None,
expand_variables_based_on = None,
+ options = None,
pre_actions = [],
post_actions = []):
"""Constructs a test action for an Xcode scheme.
@@ -462,6 +464,8 @@ also be modified in Xcode.
If no value is provided, one of the test targets will be
selected. If no expansion context is desired, use the `string`
value `none`.
+ options: Optional. A value returned by
+ `xcode_schemes.test_options`.
pre_actions: Optional. A `sequence` of `struct` values as created by
`xcode_schemes.pre_post_action`.
post_actions: Optional. A `sequence` of `struct` values as created
@@ -490,6 +494,7 @@ also be modified in Xcode.
diagnostics = diagnostics,
env = env,
expand_variables_based_on = expand_variables_based_on,
+ options = options,
pre_actions = _pre_post_actions(pre_actions),
post_actions = _pre_post_actions(post_actions),
)
diff --git a/xcodeproj/internal/xcode_schemes_internal.bzl b/xcodeproj/internal/xcode_schemes_internal.bzl
index eb8f06020f..f20b609da5 100644
--- a/xcodeproj/internal/xcode_schemes_internal.bzl
+++ b/xcodeproj/internal/xcode_schemes_internal.bzl
@@ -124,6 +124,7 @@ def _test_action(
diagnostics = None,
env = None,
expand_variables_based_on = None,
+ options = None,
pre_actions = [],
post_actions = []):
"""Constructs a test action for an Xcode scheme.
@@ -144,6 +145,7 @@ def _test_action(
expand_variables_based_on: Optional. One of the specified test target labels.
If no value is provided, one of the test targets will be selected.
If no expansion context is desired, use the `string` value `none`.
+ options: Optional. A value returned by `xcode_schemes.test_options`.
pre_actions: Optional. A `sequence` of `struct` values as created by
`xcode_schemes.pre_post_action`.
post_actions: Optional. A `sequence` of `struct` values as created by
@@ -171,6 +173,7 @@ or one of the test targets.
diagnostics = diagnostics,
env = env,
expand_variables_based_on = expand_variables_based_on,
+ options = options,
pre_actions = pre_actions,
post_actions = post_actions,
)
diff --git a/xcodeproj/internal/xcodeproj_incremental_rule.bzl b/xcodeproj/internal/xcodeproj_incremental_rule.bzl
index 6f04c038f7..34e4a09a27 100644
--- a/xcodeproj/internal/xcodeproj_incremental_rule.bzl
+++ b/xcodeproj/internal/xcodeproj_incremental_rule.bzl
@@ -219,6 +219,7 @@ def _write_autogeneration_config_file(
args = actions.args()
args.set_param_file_format("multiline")
+ args.add_all(config.get("test_options"))
args.add_all(
config.get("scheme_name_exclude_patterns", []),
omit_if_empty = False,
diff --git a/xcodeproj/internal/xcschemes/xcscheme_infos.bzl b/xcodeproj/internal/xcschemes/xcscheme_infos.bzl
index 74d9ca032a..333e98b3f0 100644
--- a/xcodeproj/internal/xcschemes/xcscheme_infos.bzl
+++ b/xcodeproj/internal/xcschemes/xcscheme_infos.bzl
@@ -49,6 +49,15 @@ def _make_diagnostics(
thread_performance_checker = thread_performance_checker,
)
+def _make_test_options(
+ *,
+ app_region = EMPTY_STRING,
+ app_language = EMPTY_STRING):
+ return struct(
+ app_region = app_region,
+ app_language = app_language,
+ )
+
def _make_launch_target(
id = EMPTY_STRING,
*,
@@ -152,6 +161,7 @@ def _make_test(
diagnostics = _make_diagnostics(),
env = None,
env_include_defaults = FALSE_ARG,
+ options = _make_test_options(),
test_targets = EMPTY_LIST,
use_run_args_and_env = TRUE_ARG,
xcode_configuration = EMPTY_STRING):
@@ -161,6 +171,7 @@ def _make_test(
diagnostics = diagnostics,
env = env,
env_include_defaults = env_include_defaults,
+ options = options,
test_targets = test_targets,
use_run_args_and_env = use_run_args_and_env,
xcode_configuration = xcode_configuration,
@@ -294,6 +305,15 @@ def _diagnostics_info_from_dict(diagnostics):
),
)
+def _options_info_from_dict(options):
+ if not options:
+ return _make_test_options()
+
+ return _make_test_options(
+ app_region = options["app_region"],
+ app_language = options["app_language"],
+ )
+
def _env_infos_from_dict(env):
if env == "inherit":
return None
@@ -646,6 +666,7 @@ def _test_info_from_dict(
diagnostics = _diagnostics_info_from_dict(test["diagnostics"]),
env = _env_infos_from_dict(test["env"]),
env_include_defaults = test["env_include_defaults"],
+ options = _options_info_from_dict(test["options"]),
test_targets = test_targets,
use_run_args_and_env = test["use_run_args_and_env"],
xcode_configuration = xcode_configuration,
@@ -759,6 +780,7 @@ xcscheme_infos_testable = struct(
make_env = _make_env,
make_diagnostics = _make_diagnostics,
make_launch_target = _make_launch_target,
+ make_test_options = _make_test_options,
make_pre_post_action = _make_pre_post_action,
make_profile = _make_profile,
make_run = _make_run,
diff --git a/xcodeproj/internal/xcschemes/xcscheme_labels.bzl b/xcodeproj/internal/xcschemes/xcscheme_labels.bzl
index ef7b5d0c32..bdc4617fc4 100644
--- a/xcodeproj/internal/xcschemes/xcscheme_labels.bzl
+++ b/xcodeproj/internal/xcschemes/xcscheme_labels.bzl
@@ -127,6 +127,7 @@ def _resolve_test_labels(test):
diagnostics = test.diagnostics,
env = test.env,
env_include_defaults = test.env_include_defaults,
+ options = test.test_options,
test_targets = [
_resolve_test_target_labels(test_target)
for test_target in test.test_targets
diff --git a/xcodeproj/internal/xcschemes/xcschemes.bzl b/xcodeproj/internal/xcschemes/xcschemes.bzl
index d3b6bf84eb..c43793736a 100644
--- a/xcodeproj/internal/xcschemes/xcschemes.bzl
+++ b/xcodeproj/internal/xcschemes/xcschemes.bzl
@@ -361,6 +361,7 @@ def _test(
diagnostics = None,
env = "inherit",
env_include_defaults = True,
+ test_options = None,
test_targets = [],
use_run_args_and_env = None,
xcode_configuration = None):
@@ -478,6 +479,11 @@ def _test(
default Bazel environment variables (e.g.
`BUILD_WORKING_DIRECTORY` and `BUILD_WORKSPACE_DIRECTORY`), in
addition to any set by [`env`](#xcschemes.test-env).
+ test_options: The test options to set for testing.
+ Can be `None` or a value returned by
+ [`xcschemes.test_options`](#xcschemes.test_options). If `None`,
+ `xcschemes.test_options()` will be used, which means no additional
+ test options be set.
test_targets: The test targets to build, and possibly run, when testing.
Each element of the `list` can be a label string or a value returned
@@ -539,6 +545,7 @@ def _test(
diagnostics = diagnostics,
env = env or {},
env_include_defaults = TRUE_ARG if env_include_defaults else FALSE_ARG,
+ test_options = test_options,
test_targets = test_targets or [],
use_run_args_and_env = TRUE_ARG if use_run_args_and_env else FALSE_ARG,
xcode_configuration = xcode_configuration or "",
@@ -1189,7 +1196,42 @@ Address Sanitizer cannot be used together with Thread Sanitizer.
),
)
-def _autogeneration_config(scheme_name_exclude_patterns = None):
+def _test_options(*, app_language = None, app_region = None):
+ """Defines the test options for a custom scheme.
+
+ Args:
+ app_region: Region to set in scheme.
+
+ Defaults to system settings if not set.
+ app_language: Language to set in scheme.
+
+ Defaults to system settings if not set.
+ """
+
+ return struct(
+ app_region = app_region,
+ app_language = app_language,
+ )
+
+def _autogeneration_test(*, options = None):
+ """Creates a value for the `test` argument of `xcschemes.autogeneration_config`.
+
+ Args:
+ options: Test options for autogeneration.
+
+ Defaults to `None`.
+
+ Returns:
+ An opaque value for the
+ [`test`](user-content-xcschemes.autogeneration_config-test)
+ argument of `xcschemes.autogeneration_config`.
+ """
+
+ return struct(
+ test_options = options,
+ )
+
+def _autogeneration_config(*, scheme_name_exclude_patterns = None, test = None):
"""Creates a value for the [`scheme_autogeneration_config`](xcodeproj-scheme_autogeneration_config) attribute of `xcodeproj`.
Args:
@@ -1206,10 +1248,27 @@ def _autogeneration_config(scheme_name_exclude_patterns = None):
".*somePattern.*",
"^AnotherPattern.*",
],
- )
+ ),
)
```
+ test: Options to use for the test action.
+
+ Example:
+
+ ```starlark
+ xcodeproj(
+ ...
+ scheme_autogeneration_config = xcschemes.autogeneration_config(
+ test = xcschemes.autogeneration.test(
+ options = xcschemes.test_options(
+ app_language = "en",
+ app_region = "US",
+ )
+ )
+ )
+ )
+
Returns:
An opaque value for the [`scheme_autogeneration_config`](xcodeproj-scheme_autogeneration_config) attribute of `xcodeproj`.
"""
@@ -1217,12 +1276,21 @@ def _autogeneration_config(scheme_name_exclude_patterns = None):
if scheme_name_exclude_patterns:
d["scheme_name_exclude_patterns"] = scheme_name_exclude_patterns
+ if test:
+ d["test_options"] = [
+ test.test_options.app_language or "",
+ test.test_options.app_region or "",
+ ]
+
return d
# API
xcschemes = struct(
arg = _arg,
+ autogeneration = struct(
+ test = _autogeneration_test,
+ ),
autogeneration_config = _autogeneration_config,
diagnostics = _diagnostics,
env_value = _env_value,
@@ -1234,6 +1302,7 @@ xcschemes = struct(
run = _run,
scheme = _scheme,
test = _test,
+ test_options = _test_options,
test_target = _test_target,
top_level_anchor_target = _top_level_anchor_target,
top_level_build_target = _top_level_build_target,
diff --git a/xcodeproj/internal/xcschemes/xcschemes_execution.bzl b/xcodeproj/internal/xcschemes/xcschemes_execution.bzl
index 69eff46e89..8c2d05f1de 100644
--- a/xcodeproj/internal/xcschemes/xcschemes_execution.bzl
+++ b/xcodeproj/internal/xcschemes/xcschemes_execution.bzl
@@ -215,6 +215,10 @@ def _write_schemes(
custom_scheme_args.add(diagnostics.main_thread_checker)
custom_scheme_args.add(diagnostics.thread_performance_checker)
+ def _add_test_options(test_options):
+ custom_scheme_args.add(test_options.app_language)
+ custom_scheme_args.add(test_options.app_region)
+
def _add_env(env):
if env == None:
custom_scheme_args.add(-1)
@@ -322,6 +326,7 @@ def _write_schemes(
custom_scheme_args.add(info.test.env_include_defaults)
custom_scheme_args.add(info.test.use_run_args_and_env)
_add_diagnostics(info.test.diagnostics)
+ _add_test_options(info.test.options)
custom_scheme_args.add(info.test.xcode_configuration)
# Run