Skip to content

Commit 5edd643

Browse files
committed
update validate log count test
1 parent 398f4a7 commit 5edd643

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Unity-MCP-Plugin/Assets/root/Tests/Editor/Tool/Console/TestToolConsoleIntegration.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,19 @@ public IEnumerator GetLogs_Validate_LogCount()
239239
{
240240
// This test verifies that logs are being stored and read from the log cache properly.
241241
var testCount = 15;
242+
var timeout = 10000;
242243
var startCount = LogUtils.LogEntries;
243244
for (int i = 0; i < testCount; i++)
244245
{
245246
Debug.Log($"Test Log {i + 1}");
246247
}
247-
// Wait for log collection system to process (EditMode tests can only yield null)
248-
for (int i = 0; i < 10000; i++)
248+
249+
var frameCount = 0;
250+
while (LogUtils.LogEntries < startCount + testCount)
249251
{
250252
yield return null;
253+
frameCount++;
254+
Assert.Less(frameCount, timeout, "Timeout waiting for logs to be collected.");
251255
}
252256
Assert.AreEqual(startCount + testCount, LogUtils.LogEntries, "Log entry count should match the amount of logs generated by this test.");
253257
}
@@ -256,8 +260,8 @@ public IEnumerator GetLogs_Validate_LogCount()
256260
public IEnumerator GetLogs_Validate_ConsoleLogRetention()
257261
{
258262
// This test verifies that logs are being stored and read from the log cache properly.
259-
const int testCount = 15;
260-
const int timeout = 100000;
263+
var testCount = 15;
264+
var timeout = 100000;
261265

262266
// Ensure a clean slate
263267
LogUtils.ClearLogs();
@@ -272,7 +276,7 @@ public IEnumerator GetLogs_Validate_ConsoleLogRetention()
272276
}
273277

274278
// Wait for logs to be collected
275-
int frameCount = 0;
279+
var frameCount = 0;
276280
while (LogUtils.LogEntries < startCount + testCount)
277281
{
278282
yield return null;
@@ -282,7 +286,7 @@ public IEnumerator GetLogs_Validate_ConsoleLogRetention()
282286
Assert.AreEqual(startCount + testCount, LogUtils.LogEntries, "Log entries count should include new entries.");
283287

284288
// Save to file and wait for completion
285-
bool saveCompleted = false;
289+
var saveCompleted = false;
286290
LogUtils.SaveToFile(() => saveCompleted = true);
287291
frameCount = 0;
288292
while (!saveCompleted)
@@ -297,7 +301,7 @@ public IEnumerator GetLogs_Validate_ConsoleLogRetention()
297301
Assert.AreEqual(0, LogUtils.LogEntries, "Log entries should be cleared.");
298302

299303
// Load from file and wait for completion
300-
bool loadCompleted = false;
304+
var loadCompleted = false;
301305
LogUtils.LoadFromFile(() => loadCompleted = true);
302306
frameCount = 0;
303307
while (!loadCompleted)

0 commit comments

Comments
 (0)