Skip to content

Commit 00ba108

Browse files
test(ui): add comprehensive tests for PanelUI and BootstrapEditorUI (#612)
Add unit tests for internal UI editor classes: - PanelUITests: tests for JEngine Panel build configuration UI - BootstrapEditorUITests: tests for Bootstrap inspector UI Integration tests (Build All, Build Assets Only with XOR/AES/ChaCha20): - Marked with [Category("Integration")] for separate execution - Test real build functionality against active build target Test infrastructure improvements: - JEngineTestBase: base class with LogAssert.ignoreFailingMessages - TestsSetUp: assembly-level setup to disable auto-baking - AssemblyInfo.cs: InternalsVisibleTo for test assembly access BuildManager improvements: - Simplified error filtering with unified IgnoredErrors array - Added "Bake Ambient Probe" to ignored errors (Unity lighting issue) - Added "catalog file failed" to ignored errors (YooAsset bug) Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7d7b302 commit 00ba108

File tree

12 files changed

+1415
-26
lines changed

12 files changed

+1415
-26
lines changed

UnityProject/Packages/com.jasonxudeveloper.jengine.core/Editor/CustomEditor/BuildManager.cs

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using System;
2727
using System.Collections.Generic;
2828
using System.IO;
29+
using System.Linq;
2930
using HybridCLR.Editor;
3031
using HybridCLR.Editor.Commands;
3132
using HybridCLR.Editor.Settings;
@@ -234,11 +235,10 @@ private void ExecuteCurrentStep()
234235
UpdateProgress(0.3f, "Compiling and Obfuscating");
235236

236237
ExecuteMenuItem("HybridCLR/ObfuzExtension/GenerateAll", "Step 3/4");
237-
CheckForErrorsExcluding("Step 3/4 failed - HybridCLR generation failed",
238-
"Create package main catalog file failed");
238+
CheckForErrors("Step 3/4 failed - HybridCLR generation failed");
239239

240240
// Reset error baseline after filtering excluded errors
241-
// so subsequent steps don't see the ignored YooAsset catalog errors
241+
// so subsequent steps don't see the ignored errors
242242
_errorCountAtStart = GetUnityErrorCount();
243243

244244
_currentStep = BuildStep.GeneratePolymorphicCodes;
@@ -451,38 +451,37 @@ private void ExecuteMenuItem(string menuPath, string stepName)
451451
}
452452
}
453453

454-
private void CheckForErrors(string context)
454+
// Error messages that should always be ignored during build
455+
// These are Unity internal errors or known issues unrelated to the actual build process
456+
private static readonly string[] IgnoredErrors =
455457
{
456-
int currentErrorCount = GetUnityErrorCount();
457-
if (currentErrorCount > _errorCountAtStart)
458-
{
459-
throw new Exception($"{context}: {currentErrorCount - _errorCountAtStart} error(s) occurred. Check Unity Console for details.");
460-
}
461-
}
458+
"Bake Ambient Probe", // Unity lighting error that occurs during editor operations
459+
"catalog file failed", // YooAsset catalog bug during HybridCLR generation (any package)
460+
};
462461

463-
private void CheckForErrorsExcluding(string context, string excludeMessageContaining)
462+
private void CheckForErrors(string context)
464463
{
465464
int currentErrorCount = GetUnityErrorCount();
466465
if (currentErrorCount > _errorCountAtStart)
467466
{
468-
// Check if the new errors are only the excluded error
467+
// Check if the new errors are only ignored errors
469468
int newErrorCount = currentErrorCount - _errorCountAtStart;
470-
int nonExcludedErrors = CountNonExcludedErrors(excludeMessageContaining, newErrorCount);
469+
int realErrors = CountRealErrors(newErrorCount);
471470

472-
if (nonExcludedErrors > 0)
471+
if (realErrors > 0)
473472
{
474-
throw new Exception($"{context}: {nonExcludedErrors} error(s) occurred. Check Unity Console for details.");
473+
throw new Exception($"{context}: {realErrors} error(s) occurred. Check Unity Console for details.");
475474
}
476475

477-
// If we have errors but they're all excluded, log a warning but continue
476+
// If we have errors but they're all ignored, log a note but continue
478477
if (newErrorCount > 0)
479478
{
480-
Log($"Note: {newErrorCount} known error(s) ignored (YooAsset catalog bug)");
479+
Log($"Note: {newErrorCount} known error(s) ignored");
481480
}
482481
}
483482
}
484483

485-
private int CountNonExcludedErrors(string excludeMessageContaining, int recentErrorCount)
484+
private int CountRealErrors(int recentErrorCount)
486485
{
487486
try
488487
{
@@ -505,7 +504,7 @@ private int CountNonExcludedErrors(string excludeMessageContaining, int recentEr
505504
int totalCount = (int)getCountMethod.Invoke(null, null);
506505
startGettingEntriesMethod.Invoke(null, null);
507506

508-
int nonExcludedCount = 0;
507+
int realErrorCount = 0;
509508
int checkedErrors = 0;
510509

511510
// Check recent errors from the end of the log
@@ -528,21 +527,21 @@ private int CountNonExcludedErrors(string excludeMessageContaining, int recentEr
528527
if (messageField != null)
529528
{
530529
string message = (string)messageField.GetValue(entry);
531-
if (!message.Contains(excludeMessageContaining))
530+
if (!IsIgnoredError(message))
532531
{
533-
nonExcludedCount++;
532+
realErrorCount++;
534533
}
535534
}
536535
else
537536
{
538-
nonExcludedCount++;
537+
realErrorCount++;
539538
}
540539
}
541540
}
542541
}
543542

544543
endGettingEntriesMethod.Invoke(null, null);
545-
return nonExcludedCount;
544+
return realErrorCount;
546545
}
547546
catch
548547
{
@@ -551,6 +550,11 @@ private int CountNonExcludedErrors(string excludeMessageContaining, int recentEr
551550
}
552551
}
553552

553+
private static bool IsIgnoredError(string errorMessage)
554+
{
555+
return IgnoredErrors.Any(ignoredError => errorMessage.Contains(ignoredError));
556+
}
557+
554558
private int GetUnityErrorCount()
555559
{
556560
var logEntriesType = typeof(UnityEditor.Editor).Assembly.GetType("UnityEditor.LogEntries");
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// AssemblyInfo.cs
2+
//
3+
// Author:
4+
// JasonXuDeveloper <jason@xgamedev.net>
5+
//
6+
// Copyright (c) 2025 JEngine
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in
16+
// all copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
// THE SOFTWARE.
25+
26+
using System.Runtime.CompilerServices;
27+
28+
// Allow test assembly to access internal types
29+
[assembly: InternalsVisibleTo("JEngine.UI.Editor.Tests")]

UnityProject/Packages/com.jasonxudeveloper.jengine.ui/Editor/AssemblyInfo.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityProject/Packages/com.jasonxudeveloper.jengine.ui/Tests/Editor/Internal.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)