Skip to content

Commit 7957441

Browse files
committed
fix(sprite): give full_setup's scene step the same refusal shape as the others
Steps 1-3 refuse through Stop(), which returns success/step/message/diagnostics. A step-4 failure fell through to the success-shaped return with the flag flipped, so it was the only refusal in the tool with no 'message' and no 'step' - the reason lived only inside the diagnostics array. The existing test passed because it asserted on that array; it now asserts on the message and the step too, which is what let the shape drift in the first place. The asset fields stay on the failure: by step 4 the slice, the clips and the controller are all on disk, and the caller needs to know that.
1 parent ad89fa9 commit 7957441

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

MCPForUnity/Editor/Tools/Sprite2D/SpriteFullSetup.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,27 @@ public static object Run(JObject @params, SpriteDiagnosticBuilder diagnostics)
136136
}
137137
}
138138

139+
// Shaped like the other three steps' refusals rather than like a success with the
140+
// flag flipped: a step-4 failure used to be the one refusal in the tool carrying
141+
// neither 'step' nor 'message', leaving the reason only inside the diagnostics
142+
// array. The asset fields stay on it, because by this point steps 1-3 have written
143+
// and the caller needs to know what is already on disk.
144+
if (diagnostics.HasErrors)
145+
return new
146+
{
147+
success = false,
148+
step = "add_to_scene",
149+
message = diagnostics.FirstError,
150+
sprite_path = path,
151+
controller_path = controller.path,
152+
state_count = controller.stateCount,
153+
clip_count = clips.Count,
154+
diagnostics = diagnostics.Build(),
155+
};
156+
139157
return new
140158
{
141-
success = !diagnostics.HasErrors,
159+
success = true,
142160
sprite_path = path,
143161
controller_path = controller.path,
144162
state_count = controller.stateCount,

TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageSpriteTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,10 @@ public void FullSetup_RequestedSceneTargetMissing_IsNotReportedAsSuccess()
12611261
Assert.IsFalse(result.Value<bool>("success"),
12621262
"an attachment that was asked for and did not happen is not a success");
12631263
Assert.That(result["diagnostics"].ToString(), Does.Contain("SCENE_TARGET_NOT_FOUND"));
1264+
// Asserted on the message rather than only the diagnostics array, because reading
1265+
// the array was what let this refusal keep a shape no other refusal in the tool has.
1266+
Assert.AreEqual("add_to_scene", result.Value<string>("step"));
1267+
Assert.That(ErrorText(result), Does.Contain("NoSuchObject"));
12641268
}
12651269

12661270
[Test]

0 commit comments

Comments
 (0)