Skip to content

Re-enable tests for Sys.RT.Caching#118508

Closed
StephenMolloy wants to merge 4 commits intodotnet:mainfrom
StephenMolloy:SRC_Re-enable_Tests-old
Closed

Re-enable tests for Sys.RT.Caching#118508
StephenMolloy wants to merge 4 commits intodotnet:mainfrom
StephenMolloy:SRC_Re-enable_Tests-old

Conversation

@StephenMolloy
Copy link
Copy Markdown
Member

This pull request updates the System.Runtime.Caching test suite to improve coverage and maintainability. The main changes include removing obsolete or restrictive test annotations, refactoring test helpers for better isolation, and adding a new test to verify cache item expiration behavior when file dependencies change.

Test coverage and reliability improvements:

  • Added a new [OuterLoop] test Reasonable_Delay in HostFileChangeMonitorTest.cs to verify that cache items expire promptly when a monitored file changes.
  • Refactored the SetupMonitoring helper to accept a unique ID, ensuring test file isolation and reducing interference between tests. [1] [2]

Test annotation and platform restriction cleanup:

  • Removed [ActiveIssue], [PlatformSpecific], and [SkipOnPlatform] annotations from several tests in both HostFileChangeMonitorTest.cs and MemoryCacheTest.cs, enabling broader test execution across platforms and configurations. [1] [2] [3] [4] [5] [6] [7]

General code and import maintenance:

  • Cleaned up using directives in HostFileChangeMonitorTest.cs to remove unnecessary imports and improve code clarity.

@StephenMolloy StephenMolloy added this to the 10.0.0 milestone Aug 8, 2025
@StephenMolloy StephenMolloy self-assigned this Aug 8, 2025
Copilot AI review requested due to automatic review settings August 8, 2025 00:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request re-enables previously disabled tests for the System.Runtime.Caching library by removing restrictive test annotations and improving test reliability. The changes focus on expanding test coverage across platforms and adding new functionality testing.

Key changes include:

  • Removal of [ActiveIssue], [PlatformSpecific], and [SkipOnPlatform] annotations from multiple tests
  • Addition of a new [OuterLoop] test to verify cache expiration behavior with file dependencies
  • Refactoring of test helper methods to improve test isolation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
MemoryCacheTest.cs Removes test skip annotations from 7 different test methods, enabling broader platform execution
HostFileChangeMonitorTest.cs Removes test skip annotations, adds new cache expiration test, and refactors helper method for better test isolation

if (!mc.Contains("key"))
break;
Thread.Sleep(20);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When there are a lot of tests running in parallel (which xunit attempts to achieve), there can be a lot of thread contention and this might not return within 20ms. I would create a Stopwatch before the loop and use a while loop checking if the required amount of time has elapsed yet. This would be immune to CPU contention causing the test to take significantly longer due to the iteration count.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought about that. Decided to just keep it simple though. The exact timing isn't important. The cache item should be removed relatively quickly - just not instantly, which is why we check on it in a loop. I'd be shocked if it ever took longer than 1s, but I wanted to be flexible enough so the test isn't noisy. 5s felt like an eternity for this, but in reality, the condition for breaking the loop should be met much, much sooner... and what that exact time is isn't important.

Do you think the potential for running so much longer than 5s that it becomes a problem in the test harness is a realistic problem?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ooh! Also, I switched from Thread.Sleep() to Task.Delay() and re-created the PR instead of mucking around with some re-basing/conflict resolution... and proceeded to use the old branch again. :/

I'm going to close this PR and assign the new one for the correct branch to you. It's all the same changes except with one more commit updating to Task.Delay().

@github-actions github-actions Bot locked and limited conversation to collaborators Sep 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants