Repository navigation
fix: Cancelled test runs no longer hang, and log retrieval responds faster #1321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
61825b5
Fix test execution hanging forever when the CLI cancels mid-run
hatayama 13443f6
Cache reflection handles in ConsoleLogRetriever instead of per-entry …
hatayama b203ae7
Reuse JSON serializers and parameter schemas across tool requests
hatayama 64f1e45
Cut redundant copies and regex rebuilds from the get-logs path
hatayama 0f979ed
Stop the client disconnect monitor promptly and guard package event r…
hatayama 61edd80
Reduce per-iteration work in Go CLI polling loops
hatayama f4a1594
Fail fast when Unity-internal log API members are missing
hatayama a4f22e0
Bound user search regex matching with a timeout
hatayama 7d264cf
Bump CLI contract and minimum required CLI version to 3.0.0-beta.31
hatayama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| using System; | ||
| using NUnit.Framework; | ||
|
|
||
| using io.github.hatayama.UnityCliLoop.FirstPartyTools; | ||
|
|
||
| namespace io.github.hatayama.UnityCliLoop.Tests.Editor | ||
| { | ||
| /// <summary> | ||
| /// Unit tests for LogFilteringService | ||
| /// Related classes: LogFilteringService, GetLogsUseCase, LogEntry | ||
| /// </summary> | ||
| [TestFixture] | ||
| public class LogFilteringServiceTests | ||
| { | ||
| private LogFilteringService _service; | ||
|
|
||
| [SetUp] | ||
| public void SetUp() | ||
| { | ||
| _service = new LogFilteringService(); | ||
| } | ||
|
|
||
| private static UnityCliLoopConsoleLogEntry CreateEntry(string message) | ||
| { | ||
| return new UnityCliLoopConsoleLogEntry(UnityCliLoopLogType.Log, message, $"stack of {message}"); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verifies entries are returned newest-first (input order reversed) | ||
| /// </summary> | ||
| [Test] | ||
| public void FilterAndLimitLogs_ReturnsEntriesNewestFirst() | ||
| { | ||
| UnityCliLoopConsoleLogEntry[] entries = { CreateEntry("oldest"), CreateEntry("middle"), CreateEntry("newest") }; | ||
|
|
||
| LogEntry[] result = _service.FilterAndLimitLogs(entries, 10, includeStackTrace: false); | ||
|
|
||
| Assert.That(result.Length, Is.EqualTo(3)); | ||
| Assert.That(result[0].Message, Is.EqualTo("newest")); | ||
| Assert.That(result[1].Message, Is.EqualTo("middle")); | ||
| Assert.That(result[2].Message, Is.EqualTo("oldest")); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verifies maxCount keeps only the newest entries when input exceeds the limit | ||
| /// </summary> | ||
| [Test] | ||
| public void FilterAndLimitLogs_LimitsToNewestEntries() | ||
| { | ||
| UnityCliLoopConsoleLogEntry[] entries = { CreateEntry("first"), CreateEntry("second"), CreateEntry("third"), CreateEntry("fourth") }; | ||
|
|
||
| LogEntry[] result = _service.FilterAndLimitLogs(entries, 2, includeStackTrace: false); | ||
|
|
||
| Assert.That(result.Length, Is.EqualTo(2)); | ||
| Assert.That(result[0].Message, Is.EqualTo("fourth")); | ||
| Assert.That(result[1].Message, Is.EqualTo("third")); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verifies stack traces are included when includeStackTrace is true | ||
| /// </summary> | ||
| [Test] | ||
| public void FilterAndLimitLogs_IncludesStackTraceWhenRequested() | ||
| { | ||
| UnityCliLoopConsoleLogEntry[] entries = { CreateEntry("message") }; | ||
|
|
||
| LogEntry[] result = _service.FilterAndLimitLogs(entries, 10, includeStackTrace: true); | ||
|
|
||
| Assert.That(result[0].StackTrace, Is.EqualTo("stack of message")); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verifies stack traces are null when includeStackTrace is false | ||
| /// </summary> | ||
| [Test] | ||
| public void FilterAndLimitLogs_OmitsStackTraceWhenNotRequested() | ||
| { | ||
| UnityCliLoopConsoleLogEntry[] entries = { CreateEntry("message") }; | ||
|
|
||
| LogEntry[] result = _service.FilterAndLimitLogs(entries, 10, includeStackTrace: false); | ||
|
|
||
| Assert.That(result[0].StackTrace, Is.Null); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verifies maxCount of zero returns an empty array | ||
| /// </summary> | ||
| [Test] | ||
| public void FilterAndLimitLogs_WithZeroMaxCount_ReturnsEmptyArray() | ||
| { | ||
| UnityCliLoopConsoleLogEntry[] entries = { CreateEntry("message") }; | ||
|
|
||
| LogEntry[] result = _service.FilterAndLimitLogs(entries, 0, includeStackTrace: false); | ||
|
|
||
| Assert.That(result, Is.Empty); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verifies empty input returns an empty array | ||
| /// </summary> | ||
| [Test] | ||
| public void FilterAndLimitLogs_WithEmptyInput_ReturnsEmptyArray() | ||
| { | ||
| LogEntry[] result = _service.FilterAndLimitLogs(Array.Empty<UnityCliLoopConsoleLogEntry>(), 10, includeStackTrace: false); | ||
|
|
||
| Assert.That(result, Is.Empty); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verifies null entries are rejected with ArgumentNullException | ||
| /// </summary> | ||
| [Test] | ||
| public void FilterAndLimitLogs_WithNullEntries_ThrowsArgumentNullException() | ||
| { | ||
| Assert.Throws<ArgumentNullException>(() => _service.FilterAndLimitLogs(null, 10, includeStackTrace: false)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verifies negative maxCount is rejected with ArgumentOutOfRangeException | ||
| /// </summary> | ||
| [Test] | ||
| public void FilterAndLimitLogs_WithNegativeMaxCount_ThrowsArgumentOutOfRangeException() | ||
| { | ||
| UnityCliLoopConsoleLogEntry[] entries = { CreateEntry("message") }; | ||
|
|
||
| Assert.Throws<ArgumentOutOfRangeException>(() => _service.FilterAndLimitLogs(entries, -1, includeStackTrace: false)); | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.