fix(tests): Fix flaky SentryCrashInstallationReporterTests#7682
Open
fix(tests): Fix flaky SentryCrashInstallationReporterTests#7682
Conversation
Call `sentrycrash_uninstall()` before `sut.install()` in test setup to reset the global `g_installed` C flag. When `g_installed` is left at 1 by a previous test class, `sentrycrash_install()` skips reinitialization — including `sentrycrashcrs_initialize()` which sets `g_reportsPath`. This can leave the report store pointing at a stale or deleted directory, causing `sentrycrashcrs_addUserReport` to silently fail and `allReports` to return 0 results. Also reorder tearDown so `sut.uninstall()` runs before `clearTestState()`, ensuring it operates on the original dependency container rather than creating a throwaway one.
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7682 +/- ##
=============================================
- Coverage 85.345% 85.307% -0.039%
=============================================
Files 485 485
Lines 28837 28837
Branches 12515 12520 +5
=============================================
- Hits 24611 24600 -11
- Misses 4179 4190 +11
Partials 47 47 see 6 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SentryCrashInstallationReporterTests.testShouldCaptureCrashReportWithLegacyStorageInfois flaky on CI — all assertions fail with 0 reports processed.The C-level
sentrycrash_install()has a globalg_installedguard: if another test class left it at1, the call returns early without reinitializing the report store (i.e.,sentrycrashcrs_initializeis skipped andg_reportsPathstays stale). If that stale path's directory was deleted by a previous test's cleanup,sentrycrashcrs_addUserReportsilently fails to write the report file, andallReportsreturns an empty array.Changes
sentrycrash_uninstall()beforesut.install()in test setup — resets the globalg_installedflag sosentrycrash_install()fully reinitializes the report store path.tearDownsosut.uninstall()runs beforeclearTestState()— ensuresuninstalloperates on the original dependency container rather than creating a throwaway one after the container is reset.Motivation
Fix flaky test:
SentryCrashInstallationReporterTests.testShouldCaptureCrashReportWithLegacyStorageInfoHow it was tested
Ran the full test class locally — all 4 tests pass.
#skip-changelog
Closes #7683