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
4 changes: 2 additions & 2 deletions Assets/Editor/CompileCheckWindow/CompileCheckerExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static async void TestCompileChecker()

CompileResult result = await compileController.TryCompileAsync(
forceRecompile: false,
pausePointWarning: null,
playModeStopWarning: null,
ct: CancellationToken.None);
CompilerMessage[] err = result.Errors;
CompilerMessage[] warning = result.Warnings;
Expand Down Expand Up @@ -72,7 +72,7 @@ public static async void TestForceCompileChecker()
// Example of forced re-compilation
CompileResult result = await compileController.TryCompileAsync(
forceRecompile: true,
pausePointWarning: null,
playModeStopWarning: null,
ct: CancellationToken.None);
CompilerMessage[] err = result.Errors;
CompilerMessage[] warning = result.Warnings;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Editor/CompileCheckWindow/CompileEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private async Task ExecuteCompileAsync()
return;
}

CompileResult result = await _compileController.TryCompileAsync(_forceRecompile, pausePointWarning: null, CancellationToken.None);
CompileResult result = await _compileController.TryCompileAsync(_forceRecompile, playModeStopWarning: null, CancellationToken.None);
if (ShouldRunExecuteDynamicCodeReadinessAfterCompile(result))
{
_isPostCompileReadinessRunning = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public async Task CompileAsync_WhenConsentWasDeclined_ReturnsDisclosure()
compileResultSessionRepository,
pendingCompileSessionRepository);
useCase.SetCompilationStateValidationForTesting(() => ValidationResult.Success());
useCase.SetCompilationExecutionForTesting((compileRequest, pausePointWarning, ct) =>
useCase.SetCompilationExecutionForTesting((compileRequest, playModeStopWarning, ct) =>
{
ct.ThrowIfCancellationRequested();
return Task.FromResult(executionResult);
Expand Down Expand Up @@ -131,7 +131,7 @@ public void CreateResponse_WhenDeclinedWithExistingWarning_AppendsFixedWarning()
CompileResponse response = CompileResponseFactory.CreateResponse(
result,
forceRecompile: false,
pausePointWarning: "Play Mode was active with 2 enabled pause point(s).");
playModeStopWarning: "Play Mode was active with 2 enabled pause point(s).");

Assert.That(
response.Warning,
Expand Down Expand Up @@ -160,7 +160,7 @@ public void CreateResponse_WhenDeclinedForceCompile_AppendsFixedNextAction()
CompileResponse response = CompileResponseFactory.CreateResponse(
result,
forceRecompile: true,
pausePointWarning: null);
playModeStopWarning: null);

Assert.That(response.Warning, Is.EqualTo(WarningText));
Assert.That(
Expand Down
74 changes: 74 additions & 0 deletions Assets/Tests/Editor/CompileControllerPlayModeStopWarningTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using NUnit.Framework;

using io.github.hatayama.UnityCliLoop.Domain;
using io.github.hatayama.UnityCliLoop.FirstPartyTools;
using io.github.hatayama.UnityCliLoop.Infrastructure;
using io.github.hatayama.UnityCliLoop.ToolContracts;

namespace io.github.hatayama.UnityCliLoop.Tests.Editor
{
/// <summary>
/// Verifies CompileController keeps the Play-stop Warning on the delayed status-polling path
/// when external Scene changes abort compile before Unity starts compiling.
/// </summary>
[TestFixture]
public sealed class CompileControllerPlayModeStopWarningTests
{
/// <summary>
/// What: an external Scene-change refusal stores the received Play-stop Warning for status polling.
/// </summary>
[Test]
public async Task TryCompileAsync_WhenExternalSceneChangeBlocks_PersistsReceivedPlayModeStopWarning()
{
const string expectedWarning =
"Play Mode was active when this compile was requested. The compile stops Play Mode and the domain reload discards the Play session state — re-establish your runtime state before continuing verification.";
UnityCliLoopCompileResultSessionRepository compileResultSessionRepository =
UnityCliLoopEditorSessionStateTestFactory.CreateCompileResultSessionRepository();
UnityCliLoopPendingCompileSessionRepository pendingCompileSessionRepository =
UnityCliLoopEditorSessionStateTestFactory.CreatePendingCompileSessionRepository();
UnityCliLoopEditorSessionStateSnapshot originalSnapshot =
UnityCliLoopEditorSessionStateTestFactory.CaptureSnapshot();
UnityCliLoopEditorSessionStateTestFactory.ClearAll();

try
{
using CompileController controller = new(
compileResultSessionRepository,
pendingCompileSessionRepository);
controller.SetResultRecordingContext(
CompileResultRecordingContext.Create(
new CompileSchema
{
WaitForDomainReload = true,
RequestId = "compile_scene_change_play_stop_warning",
ForceRecompile = false
}));
controller.SetExternalSceneChangeResolutionForTesting(_ => (
false,
"Open Scene files have changed externally and compile stopped.",
new[] { "Assets/Scenes/Sample.unity" }));

await controller.TryCompileAsync(
forceRecompile: false,
expectedWarning,
CancellationToken.None);

UnityCliLoopStoredCompileResult storedResult =
compileResultSessionRepository.GetCompileResult("compile_scene_change_play_stop_warning");
CompileResponse storedResponse = JsonConvert.DeserializeObject<CompileResponse>(
storedResult.ResultJson,
UnityCliLoopJsonResponseSerializerSettings.Settings);

Assert.That(storedResult.HasResult, Is.True);
Assert.That(storedResponse.Warning, Is.EqualTo(expectedWarning));
}
finally
{
originalSnapshot.Restore();
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Assets/Tests/Editor/CompileErrorNextActionsComposerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public void CreateResponse_WhenLanguageVersionError_ReturnsExactNextActions()
CompileResponse response = CompileResponseFactory.CreateResponse(
result,
forceRecompile: false,
pausePointWarning: null);
playModeStopWarning: null);

Assert.That(response.NextActions, Is.EqualTo(new[] { FileScopedNamespaceNextAction }));
}
Expand All @@ -271,7 +271,7 @@ public void CreateResponse_WhenForceCompileWithLanguageVersionError_DoesNotAddRe
CompileResponse response = CompileResponseFactory.CreateResponse(
result,
forceRecompile: true,
pausePointWarning: null);
playModeStopWarning: null);

Assert.That(response.NextActions, Is.EqualTo(new[] { ExistingNextAction }));
}
Expand All @@ -296,7 +296,7 @@ public void CreateResponse_WhenIndeterminateWithLanguageVersionError_DoesNotAddR
CompileResponse response = CompileResponseFactory.CreateResponse(
result,
forceRecompile: false,
pausePointWarning: null);
playModeStopWarning: null);

Assert.That(response.NextActions, Is.Null);
}
Expand All @@ -320,7 +320,7 @@ public void CreateResponse_WhenLanguageVersionErrorAndConsentDeclined_AppendsAft
CompileResponse response = CompileResponseFactory.CreateResponse(
result,
forceRecompile: false,
pausePointWarning: null);
playModeStopWarning: null);

Assert.That(
response.NextActions,
Expand Down Expand Up @@ -480,7 +480,7 @@ public void CreateResponse_WhenCs0234ForNUnitFramework_IncludesNunitFrameworkAss
CompileResponse response = CompileResponseFactory.CreateResponse(
result,
forceRecompile: false,
pausePointWarning: null);
playModeStopWarning: null);

Assert.That(response.NextActions, Is.EqualTo(new[] { NUnitFrameworkNextAction }));
}
Expand All @@ -496,7 +496,7 @@ public void CreateResponse_WhenCs0234HasNoDeclaringAssembly_ReturnsNoNextActions
CompileResponse response = CompileResponseFactory.CreateResponse(
result,
forceRecompile: false,
pausePointWarning: null);
playModeStopWarning: null);

Assert.That(response.NextActions, Is.Null);
}
Expand All @@ -512,7 +512,7 @@ public void CreateResponse_WhenCs0246Error_ReturnsNoNextActions()
CompileResponse response = CompileResponseFactory.CreateResponse(
result,
forceRecompile: false,
pausePointWarning: null);
playModeStopWarning: null);

Assert.That(response.NextActions, Is.Null);
}
Expand All @@ -536,7 +536,7 @@ public void CreateResponse_WhenCs0234AndConsentDeclined_AppendsAfterExistingNext
CompileResponse response = CompileResponseFactory.CreateResponse(
result,
forceRecompile: false,
pausePointWarning: null);
playModeStopWarning: null);

Assert.That(
response.NextActions,
Expand Down
49 changes: 0 additions & 49 deletions Assets/Tests/Editor/CompilePausePointWarningBuilderTests.cs

This file was deleted.

59 changes: 59 additions & 0 deletions Assets/Tests/Editor/CompilePlayModeStopWarningBuilderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using NUnit.Framework;

using io.github.hatayama.UnityCliLoop.FirstPartyTools;

namespace io.github.hatayama.UnityCliLoop.Tests.Editor
{
/// <summary>
/// Verifies compile Warning text for each Play-at-request-start branch: none, Play without
/// pause points, and Play with enabled pause points.
/// </summary>
[TestFixture]
public sealed class CompilePlayModeStopWarningBuilderTests
{
/// <summary>
/// What: no warning when Play Mode was not active, regardless of marker count.
/// </summary>
[Test]
public void BuildWarning_WhenNotPlayingAtRequestStart_ReturnsNull()
{
string warning = CompilePlayModeStopWarningBuilder.BuildWarning(
wasPlayingAtRequestStart: false,
activePausePointCount: 3);

Assert.That(warning, Is.Null);
}

/// <summary>
/// What: Play without enabled pause points warns that compile stops Play and discards session state.
/// </summary>
[Test]
public void BuildWarning_WhenPlayingButNoActivePausePoints_ReturnsPlaySessionDiscardWarning()
{
string warning = CompilePlayModeStopWarningBuilder.BuildWarning(
wasPlayingAtRequestStart: true,
activePausePointCount: 0);

Assert.That(
warning,
Is.EqualTo(
"Play Mode was active when this compile was requested. The compile stops Play Mode and the domain reload discards the Play session state — re-establish your runtime state before continuing verification."));
}

/// <summary>
/// What: Play with enabled pause points keeps the existing count-and-patch-loss wording exactly.
/// </summary>
[Test]
public void BuildWarning_WhenPlayingWithActivePausePoints_ReturnsExistingPausePointWording()
{
string warning = CompilePlayModeStopWarningBuilder.BuildWarning(
wasPlayingAtRequestStart: true,
activePausePointCount: 2);

Assert.That(
warning,
Is.EqualTo(
"Play Mode was active with 2 enabled pause point(s). The compile stops Play Mode and the domain reload discards the Play session state and all pause point patches — re-enable pause points after the compile completes."));
}
}
}
Loading
Loading