-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests generated by the ios_unit_test target take very long time to run #607
Comments
If you pass |
Thanks for your hint @keith, I tried the flag. The result is as follows:
Note the time difference between timestamps in the following lines (around 15 seconds):
The source code for that test is the following: import XCTest
import SwiftWithTestsTarget
final class Tests: XCTestCase {
func test() {
XCTAssertEqual(text, "Hello, World!")
}
} |
Based on airbnb/BuckSample#121 (comment) I suspect that the delay may go away if the simulator to be used is already opened before the test run. In order to test this, I have been looking into how to tell the test runner https://github.com/google/xctestrunner (I am running latest release |
There is currently not a way to do that with the test runner that rules_apple provides. You can pass a specific device / os version by creating a ios_test_runner target, and setting that as the runner of the ios_unit_test target but it will still create a new one each time. This is an intentional decision to keep your test runs as hermetic as possible. Because of these performance issues we wrote our own test runner that uses an already running simulator. Depending on your use case this time overhead might not be too bad. If you use Tulsi to use Bazel in Xcode it won't go through this codepath and will instead use Xcode to run the test bundles so you won't have this. In which case you'd likely only hit this on CI so if you only have a few test bundles it might be ok. |
Thanks @keith. Is your custom test runner open source? |
No it's not, but generally it's the same as the one in this repo, except instead of calling xctestrunner with the device / version we first create a simulator using |
Mmm. I just tried that, without success.
With:
To:
When opening the "D2B0934F-572F-4E2A-901C-E5EBC2352695" simulator and then running the tests, I can see that the tests are passing successfully with the new |
This doesn't look related to rules_apple, but https://github.com/google/xctestrunner does not have Issues enabled, so we'll keep it here, but the rules_apple team will likely not look into this. I'll forward this issue to the xctestrunner team internally. |
Hi Andrés, Do you mind sharing the instructions or code how to reproduce the issue? I can not reproduce this issue with my local simple Swift logic test and did not found the test target //Libraries/SwiftWithTests:SwiftWithTestsTargetTests under the codebase https://github.com/acecilia/BazelVSBuckSample |
@albertdai You can see the length of the tests in CI here: https://dev.azure.com/acecilia/BazelVSBuckSample/_build/results?buildId=58&view=logs&jobId=12f1170f-54f2-53f3-20dd-22fc7dff55f9&taskId=e7d422da-e621-5d9c-7d76-ef2f3144435b&lineStart=63&lineEnd=63&colStart=1&colEnd=9 In https://github.com/acecilia/BazelVSBuckSample I renamed
For cleaning and running with 100% miss cache, you can do |
HI Andrés, I can reproduce this issue in Xcode 10.2~10.3: the logic test execution hang ~15 seconds randomly. If you use Xcode 10.1 or Xcode 11+, the issue will go away. It looks a bug in Apple side. So neither bazel or xctestrunner can help this issue. |
Awesome, @albertdai thanks for your help. I am trying to add Xcode11 to my CI in https://github.com/acecilia/BazelVSBuckSample but I am having some problems. As soon as I do that and can compare the build times I will update this issue. |
@albertdai I have an update on this.
As you commented, using Xcode 11 gets rid of the 10-15 seconds delay we were talking about. Thank you very much! |
Hello:
I am making a sample repository for bazel, in order to see if it will fit my needs for ios development.
In order to create a test target for a swift library I am using
ios_unit_test
, and doing the following:When running unit tests for swift libraries:
Expectation: they run in the order of
ms
.Reality: they are taking usually 15 seconds to run, or even more.
You can see this in CI here:
19.2
and21.5
seconds to run.The source code is here: https://github.com/acecilia/BazelVSBuckSample
I already tried to find a similar problem in the issues in this repository, and in the
bazel
github repository. The only issue that I could find that may be related to this is bazelbuild/bazel#2985 (comment).Any idea why those tests are taking so long?
Thanks!
The text was updated successfully, but these errors were encountered: