Shared data-source instances are reused after disposal by tests registered later in the session
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Read src/TUnit.Core/Tracking/ObjectTracker.cs around UntrackObject, then inspect the shared-instance lookup methods in src/TUnit.Core/TestDataContainer.cs. Reproduce the issue with a disposable shared data source and a dynamic test registered after its original holder completes; verify the later test receives a new, undisposed instance. The report says the repro has not yet been run.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happens
When the last test holding a shared data-source instance (Shared = SharedType.Keyed, PerClass, PerAssembly or PerTestSession) completes, ObjectTracker.UntrackObject brings its reference count to zero and disposes it. TestDataContainer still caches the instance (ScopedDictionary.GetOrCreate), and it is only cleared by TestDataContainer.Reset() at the end of the session. A test that is registered later in the same session asks the container for the same key or scope, gets the disposed instance back, and gets a fresh reference count of 1 on it.
The usual way to register a test later is a dynamic test added at run time, after the original holders have completed.
Where
src/TUnit.Core/Tracking/ObjectTracker.cs,UntrackObject: disposes when the count reaches 0 and removes only the tracker entry.src/TUnit.Core/TestDataContainer.cs,GetInstanceForKey/GetInstanceForClass/GetInstanceForAssembly/GetGlobalInstance: these return the cached instance whether or not it has been disposed.
How to reproduce
- Test A:
[ClassDataSource<MyDisposable>(Shared = SharedType.Keyed, Key = "k")], whereMyDisposablerecordsIsDisposed. - Test B:
[DependsOn(nameof(A))]adds a dynamic test at run time whose class or method takes[ClassDataSource<MyDisposable>(Shared = SharedType.Keyed, Key = "k")]. - The dynamic test receives the instance that A's completion already disposed (
IsDisposed == true).
This applies whatever A's outcome is (passed, failed, or skipped once #7191 merges). I found it by reading the code while reviewing #7191, where Greptile raised it for skipped tests. I have not run the repro yet.
Expected
A test registered after a shared instance has been disposed gets a new instance. For example, the container could drop its cache entry when the tracker disposes the object (ObjectTracker.OnDisposed), or the container could skip disposed entries.
- Ngôn ngữ chính
- C#
- Star
- 4k
- Fork
- 139
- Merge trung bình
- 7 giờ 44 phút
- Pull request đã merge (30 ngày)
- 271
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của thomhurst/TUnit
-
Flaky: RpcTests Discovery_ReturnsFullTestCatalogue times out waiting for TCP connection on macOS CIĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug github_actions
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
thomhurst/TUnit#7229 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
JSON output still uses assembly-qualified Type.FullName for parameter and return typesCó thể đã có người làm @Saad-elnagar đã nhận hôm nay. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
thomhurst/TUnit#7201 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
thomhurst/TUnit#7194 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của thomhurst/TUnit
Issue tương tự
-
[BUG]: Position intent set on a simple order is dropped when it becomes a bracket, OCO or OTO orderCó thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
alpacahq/alpaca-trade-api-csharp#903 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
joinrpg/joinrpg-net#5752 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CodeForFire/lagebuch#714 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
dimitar-radenkov/Pointframe#294 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/feature-request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Altinn/altinn-correspondence#2154 ·
Maintainer thường phản hồi trong vòng 1 ngày