Shared data-source instances are reused after disposal by tests registered later in the session
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C#
- Stelle
- 4k
- Fork
- 139
- Merge medio
- 7h 44m
- PR unite (30g)
- 271
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di thomhurst/TUnit
-
Flaky: RpcTests Discovery_ReturnsFullTestCatalogue times out waiting for TCP connection on macOS CIApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
bug github_actions
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
thomhurst/TUnit#7229 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
JSON output still uses assembly-qualified Type.FullName for parameter and return typesForse già presa @Saad-elnagar l’ha presa oggi. Apertabug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
thomhurst/TUnit#7201 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
thomhurst/TUnit#7194 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di thomhurst/TUnit
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
KnifeLemon/Filee#363 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
area-Native untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
dotnet/machinelearning#7837 ·
I maintainer di solito rispondono entro 2 giorni
-
[CI] .trgen-ignore required for several grammars.Forse già presa @kaby76 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
antlr/grammars-v4#5073 ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement]: Add a search box to the Time Zone dropdownForse già presa @idumlupinar l’ha presa oggi. ApertaStatus: New
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
dnnsoftware/Dnn.Platform#7579 ·
I maintainer di solito rispondono entro 2 giorni