Skip to content

test(remoteconfig): wait for the fetch status in testFetchConfigWithNilCallback - #17144

Open
paulb777 wants to merge 2 commits into
mainfrom
pb-rc-nil-callback-flake
Open

paulb777 wants to merge 2 commits into
mainfrom
pb-rc-nil-callback-flake

Conversation

@paulb777

Copy link
Copy Markdown
Member

Discussion

RCNRemoteConfigTest.testFetchConfigWithNilCallback fails intermittently on slow simulators, for example in the spm_1 / spm (xcode-27, visionOS) job of sdk.remoteconfig.yml: the scheduled run on main on 2026-11-20, and #17133's run, where it failed in two retry attempts in a row with ((self->_configInstances[i].lastFetchStatus) equal to (FIRRemoteConfigFetchStatusSuccess)) failed: ("0") is not equal to ("1").

The test fetches with a nil completion handler, then checks lastFetchStatus after a fixed delay (_checkCompletionTimeout, 1 second) with dispatch_after. The fetch completes asynchronously, so when it takes longer than a second, the status is still FIRRemoteConfigFetchStatusNoFetchYet (0) when the check runs.

The test now waits with an XCTNSPredicateExpectation until each instance's lastFetchStatus is no longer NoFetchYet (up to the existing _expectationTimeout of 5 seconds), then asserts that it's FIRRemoteConfigFetchStatusSuccess. A fetch that finishes with a different status still fails the test.

Not changed / known limitations

Other tests in the file also check results after _checkCompletionTimeout with dispatch_after. I didn't change them: none has failed in the recent sdk.remoteconfig runs I checked, and most of them check state that is set synchronously.

Testing

Locally with Xcode 27.2, I made the mocked fetch response arrive 2 seconds late (a temporary change to the test's URLSessionDataTaskWithContent: stub, not part of this PR) to simulate a slow simulator. On macOS:

  • Old test, no delay: passed. Old test, 2 s delay: failed with the same three assertion failures as CI.
  • New test, no delay: passed (1.1 s). New test, 2 s delay: passed (3.1 s).

With this change, the full RemoteConfigUnit scheme passed 170 of 170 tests on macOS, the iPhone 17 simulator (iOS 27.2), and the Apple Vision Pro simulator (visionOS 27.2). No compiler warnings in RCNRemoteConfigTest.m. scripts/style.sh reports the file as formatted (clang-format 23.1.0).

API Changes

None.

#no-changelog

This PR was prepared with AI assistance.

…ilCallback

The test checked lastFetchStatus one second after starting a fetch with a nil completion handler, which fails when the fetch is slower, as on the Xcode 27 visionOS simulator in CI. Wait until the status changes from NoFetchYet, then assert that the fetch succeeded.
@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@paulb777

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the testFetchConfigWithNilCallback unit test in RCNRemoteConfigTest.m to use predicate-based expectations instead of a fixed delay, preventing potential test flakiness. The review feedback suggests a cleaner, more idiomatic approach for the NSPredicate block by utilizing its object parameter rather than capturing the outer config variable.

Read the fetch status from the object passed to the NSPredicate block instead of capturing the config instance.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants