Skip to content

fix(tests): Fix flaky SentryCrashInstallationReporterTests#7682

Open
itaybre wants to merge 1 commit intomainfrom
itay/fix_flaky_test_crash
Open

fix(tests): Fix flaky SentryCrashInstallationReporterTests#7682
itaybre wants to merge 1 commit intomainfrom
itay/fix_flaky_test_crash

Conversation

@itaybre
Copy link
Contributor

@itaybre itaybre commented Mar 12, 2026

Description

SentryCrashInstallationReporterTests.testShouldCaptureCrashReportWithLegacyStorageInfo is flaky on CI — all assertions fail with 0 reports processed.

The C-level sentrycrash_install() has a global g_installed guard: if another test class left it at 1, the call returns early without reinitializing the report store (i.e., sentrycrashcrs_initialize is skipped and g_reportsPath stays stale). If that stale path's directory was deleted by a previous test's cleanup, sentrycrashcrs_addUserReport silently fails to write the report file, and allReports returns an empty array.

Changes

  1. Call sentrycrash_uninstall() before sut.install() in test setup — resets the global g_installed flag so sentrycrash_install() fully reinitializes the report store path.
  2. Reorder tearDown so sut.uninstall() runs before clearTestState() — ensures uninstall operates on the original dependency container rather than creating a throwaway one after the container is reset.

Motivation

Fix flaky test: SentryCrashInstallationReporterTests.testShouldCaptureCrashReportWithLegacyStorageInfo

How it was tested

Ran the full test class locally — all 4 tests pass.

#skip-changelog

Closes #7683

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.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@itaybre itaybre added the ready-to-merge Use this label to trigger all PR workflows label Mar 12, 2026
@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.307%. Comparing base (1364456) to head (842453c).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1364456...842453c. Read the comment docs.

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

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(tests): Fix flaky SentryCrashInstallationReporterTests

1 participant