Skip to content

Add support for specific simulator IDs for iOS tests#648

Closed
keith wants to merge 1 commit intobazelbuild:masterfrom
keith:ks/specific-simulator
Closed

Add support for specific simulator IDs for iOS tests#648
keith wants to merge 1 commit intobazelbuild:masterfrom
keith:ks/specific-simulator

Conversation

@keith
Copy link
Copy Markdown
Member

@keith keith commented Nov 1, 2019

This allows users to pass configurable simulator UDIDs to run tests
with. This allows them to run test jobs on the same simulator without
the overhead of creating one each time.

Another benefit of this is if you want to setup simulators ahead of time for example for UI tests where you may need to set some simulator defaults to not show iOS' onboarding flows

This allows users to pass configurable simulator UDIDs to run tests
with. This allows them to run test jobs on the same simulator without
the overhead of creating one each time.
@keith keith force-pushed the ks/specific-simulator branch from 1547e15 to 9124df1 Compare November 1, 2019 01:52
@keith
Copy link
Copy Markdown
Member Author

keith commented Nov 1, 2019

Example usage:

string_flag(
    name = "ios_simulator_id",
    build_setting_default = "",
    visibility = ["//visibility:public"],
)

ios_test_runner(
    name = "custom_test_runner",
    simulator_id = "//:ios_simulator_id",
    visibility = ["//visibility:public"],
)
bazel test //... --//:ios_simulator_id="21461F1A-68DD-43E0-A795-D0329CB1E217"

I would have put this string_flag in rules_apple but it seems that you can not use it from external repos, so --@build_bazel_rules_apple//apple:ios_simulator_id=... doesn't work

@thomasvl
Copy link
Copy Markdown
Member

thomasvl commented Nov 1, 2019

Can you file a bug against bazel for rules sets not being able to define these and have them work? We'll get it raised internally.

@keith
Copy link
Copy Markdown
Member Author

keith commented Nov 1, 2019

I filed bazelbuild/bazel#10152 about this. I think in the meantime this would probably still be a fine way to handle this, but I guess it depends on how you feel about the public API changing if this starts working because I initial made simulator_id a private attr referencing the flag that was in rules_apple

@khandpur
Copy link
Copy Markdown

khandpur commented Nov 4, 2019

Can you use test arguments for this? we've added support for these in our internal test runner:
“--destination=platform=ios_device,id={UUID}” targets on a local iOS real device.
“--destination=platform=ios_simulator,id={UUID}” targets on an existing iOS simulator.

and invoke it with blaze as such:
blaze test <target> --test_arg=--destination=id={UUID},platform=ios_simulator or you can also pass it in args of the ios_{unit,ui}_test targets in the BUILD file

@keith
Copy link
Copy Markdown
Member Author

keith commented Nov 5, 2019

I've submitted the --test_arg option here #653

@keith keith closed this Aug 10, 2020
@keith keith deleted the ks/specific-simulator branch August 10, 2020 23:25
@keith
Copy link
Copy Markdown
Member Author

keith commented Aug 10, 2020

#653 is the better approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants