Proposal: Add ability to create multiple test targets with different kwargs #1589
Replies: 3 comments 2 replies
-
Having an improved /standard pattern and solution for this would be awesome 👍 . I assumed this was in the context where you have a large Today you can have custom fanout in Bazel w/o rules_apple: e.g. generating a
Of course, now you'd need to feed The other thing to consider is reproducing the CI runs locally with Xcode's specialized GUI inside via rules_ios/XCHammer. Should we somehow indicate if shards should be brought into Xcode or not? Say, you had sharded optimally for remote execution at the method level: how that would work in the GUI? You may want |
Beta Was this translation helpful? Give feedback.
-
In our case we actually took the same splits idea, but instead we just created separate bazel targets from each of those splits instead. At which point they're just kinda "normal" tests, so you get multiple schemes in Xcode etc based on what splits people define. Of course this meant we had to split out any shared code into a separate library they both depended on, but we had actually already done that since we had different targets per app before. In general doing something the way you're suggesting sounds totally reasonable, I think Jerry's example is pretty close to something that would work and probably makes sense to just have for your use case vs a custom rule? The only thing is right now test selection is only determined using this env var bazel sets rules_apple/apple/testing/default_runner/ios_test_runner.template.sh Lines 136 to 140 in 77155d9 |
Beta Was this translation helpful? Give feedback.
-
@keith @jerrymarino Let me play around with this and see what I come up with. I remember trying to do this and there were issues creating the same library twice, specifically this error: "Error in resources_filegroup: resources_filegroup rule 'Foo_Unit_Tests_data' in package 'Foo' conflicts with existing resources_filegroup rule" This comes from creating the same test library multiple times under the hood of We could abstract that so we can create all the internal libraries (and middlemen) into it's own library then have an optional module passed into @keith IRT:
Do you do this manually in the build file? Something like:
|
Beta Was this translation helpful? Give feedback.
-
What
Add an ability to create multiple test targets with the same bundle with different kwargs sent into each rule. Bundle them all into a single test_suite at the end.
Why
Tests on iOS can be long running, specifically UI tests. Bazel has a sharding mechanism that is per target on iOS this means to create multiple sims (1 per shard on the target) to run. These simulators take up a lot of resources and you can't run very many at a time without having simulator and underlying test issues. This proposal will allow for splitting up of test targets to do your own sharding which can be split across multiple machines, thus can lower the time for each "shard"
You could ask then why not just use the
--test_filter
and have it send the same target to different machines with different filters. The main reason for that is keeping the sanctity of usingbazel test //Foo
to run all of the shards, similar to how it would be done today. However, if we want to test a specific shard it would be as easy as runningbazel test //Foo_shard_1
or however we name it.Other reasons to create a thing like this would be to create production vs staging targets or any other variances that you would want to have running.
How
Add a new rule to rules_apple to take in a dictionary of suffixes -> kwargs
We'd then want to add a way to handle this in the
apple_test_assembler
This would call into the normal _assemble for creating a test target with the suffix and kwargs passed in, then wrap those tests into a suite on the outside.
Conclusion
This could be way off-base for something like bazel and there maybe better ways to achieve this. However this is something i felt like warranted discussion as I feel this could be a common thing folks run into. Would love feedback and hear folks thoughts ❤️
Beta Was this translation helpful? Give feedback.
All reactions