Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions changelog.d/unreleased/2775.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
category: fixed
issues:
- 2775
affected:
- tests/CodeIndex.Tests/TestConsoleLock.cs
- tests/CodeIndex.Tests/ConsoleCaptureTests.cs
- tests/CodeIndex.Tests/ChangelogToolTests.cs
---

## English

- **net9 test runs no longer close shared console capture writers (#2775)** - console capture helpers now restore global streams without disposing captured writers, and changelog console tests run in the non-parallel test collection.

## 日本語

- **net9 テスト実行で共有 console capture writer を閉じないようになりました (#2775)** - console capture helper は global stream を復元しても捕捉 writer を dispose せず、changelog の console テストも非並列 test collection で実行します。
1 change: 1 addition & 0 deletions tests/CodeIndex.Tests/ChangelogToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace CodeIndex.Tests;

[Collection("SQLite pool sensitive")]
public sealed class ChangelogToolTests
{
[Fact]
Expand Down
20 changes: 20 additions & 0 deletions tests/CodeIndex.Tests/ConsoleCaptureTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace CodeIndex.Tests;

[Collection("SQLite pool sensitive")]
public class ConsoleCaptureTests
{
[Fact]
Expand Down Expand Up @@ -33,4 +34,23 @@ public void Capture_RestoresConsoleStreams_WhenActionThrows()
Assert.Same(originalError, Console.Error);
}
}

[Fact]
public void Dispose_DoesNotCloseCapturedWriters()
{
var stdout = new StringWriter();
var stderr = new StringWriter();

using (var capture = ConsoleCapture.Start(stdout, stderr))
{
Console.Write("out");
Console.Error.Write("err");
}

stdout.Write(" after");
stderr.Write(" after");

Assert.Equal("out after", stdout.ToString());
Assert.Equal("err after", stderr.ToString());
}
}
4 changes: 0 additions & 4 deletions tests/CodeIndex.Tests/TestConsoleLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ public void Dispose()

Restore();
disposed = true;
if (Out is not null)
Out.Dispose();
if (Error is not null)
Error.Dispose();
System.Threading.Monitor.Exit(TestConsoleLock.Gate);
}

Expand Down
Loading