Skip to content

chore: Collapse the RunTests tool's redundant intermediate DTO layer#1515

Merged
hatayama merged 3 commits into
v3-betafrom
refactor/c2-collapse-runtests-dto-layers
Jul 5, 2026
Merged

chore: Collapse the RunTests tool's redundant intermediate DTO layer#1515
hatayama merged 3 commits into
v3-betafrom
refactor/c2-collapse-runtests-dto-layers

Conversation

@hatayama

@hatayama hatayama commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Removes the RunTests tool's intermediate DTO layer (IUnityCliLoopTestExecutionService, UnityCliLoopTestExecutionRequest, UnityCliLoopTestExecutionResult), which only performed field-by-field copies between the wire DTOs and the test-execution pipeline. Follows the same collapse applied to the Compile tool in chore: Collapse the Compile tool's redundant intermediate DTO layer #1514.

User Impact

  • No user-visible change. The run-tests tool response stays identical.

Changes

  • RunTestsUseCase now takes RunTestsSchema and returns RunTestsResponse directly; RunTestsTool no longer needs its ToRequest/ToResponse mapping helpers.
  • The response is constructed with every derived field passed explicitly (named arguments), so RunTestsResponse's null-triggered derivation branches stay skipped exactly as before — output is unchanged.
  • The domain enums (UnityCliLoopTestMode, TestFilterType, RunTestsExecutionStatus) stay in place: they are the real shared vocabulary, not mapping artifacts.
  • The RunTestsAsync pass-through (which only existed to satisfy the deleted interface) is removed; ExecuteAsync is the single entry point.
  • Unit tests retyped to the wire DTOs; the assembly-boundary guard test for the deleted types is removed (the sibling RunTestsUseCase guard remains). Repo-wide grep confirms no remaining references, including non-C# files.

Verification

  • dist/darwin-arm64/uloop compile → 0 errors, 0 warnings.
  • dist/darwin-arm64/uloop run-tests --filter-type regex --filter-value "(RunTests|OnionAssemblyDependency).*Tests" → 124 passed, 0 failed, 0 skipped.

Review in cubic

hatayama added 2 commits July 5, 2026 19:07
The RunTests pipeline previously carried a UnityCliLoopTestExecutionRequest /
UnityCliLoopTestExecutionResult pair and an IUnityCliLoopTestExecutionService
interface between RunTestsSchema and RunTestsResponse. Every hop was a pure
field-for-field copy into an identically shaped record, so the intermediate
layer only added indirection without changing behavior. Drop the interface and
the two DTOs and thread RunTestsSchema / RunTestsResponse through the pipeline
directly.

RunTestsResponse is still constructed with every derived field passed
explicitly so the constructor's derivation branches stay skipped, matching the
pre-collapse wire output byte-for-byte. The UnityCliLoopTestMode,
TestFilterType, and RunTestsExecutionStatus enums are the real domain
vocabulary shared by the schema and services (for example
TestExecutionStateValidationService.Validate takes UnityCliLoopTestMode), so
they stay in the same file to preserve the .meta GUID.
The wrapper only existed to satisfy the deleted
IUnityCliLoopTestExecutionService interface; the tool and every test
call ExecuteAsync, so keeping two public entry points invited drift.
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@hatayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 20 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3ad34429-4030-4a6f-91df-0ea90cb99d91

📥 Commits

Reviewing files that changed from the base of the PR and between fb5a5c5 and f93773d.

📒 Files selected for processing (1)
  • Packages/src/Editor/FirstPartyTools/RunTests/RunTestsUseCase.cs
📝 Walkthrough

Walkthrough

RunTestsUseCase, RunTestsTool, and UnityCliLoopTestExecutionTypes are migrated from the UnityCliLoopTestExecutionRequest/Result and IUnityCliLoopTestExecutionService shape to RunTestsSchema/RunTestsResponse. The old interface, DTOs, and RunTestsAsync method are removed; RunTestsUseCaseTests and OnionAssemblyDependencyTests are updated accordingly.

Changes

RunTests schema migration

Layer / File(s) Summary
Remove old request/result DTOs and interface
Packages/src/Editor/FirstPartyTools/RunTests/UnityCliLoopTestExecutionTypes.cs
Removes IUnityCliLoopTestExecutionService, UnityCliLoopTestExecutionRequest, and UnityCliLoopTestExecutionResult, retaining only the documented UnityCliLoopTestMode enum.
RunTestsUseCase converted to RunTestsSchema/RunTestsResponse
Packages/src/Editor/FirstPartyTools/RunTests/RunTestsUseCase.cs
ExecuteAsync now takes RunTestsSchema and returns RunTestsResponse; exception handling throws InvalidOperationException after logging; response-building helpers (IsSupportedTestMode, CreateTestFrameworkUnavailableResponse, CreateFailureResponse) are rewritten for the new type; RunTestsAsync and the interface implementation are removed.
RunTestsTool delegates directly to updated ExecuteAsync
Packages/src/Editor/FirstPartyTools/RunTests/RunTestsTool.cs
ExecuteAsync calls RunTestsUseCase.ExecuteAsync(parameters, ct) directly, removing the prior ToRequest/ToResponse mapping helpers.
Update tests for new schema types
Assets/Tests/Editor/RunTestsUseCaseTests.cs, Assets/Tests/Editor/OnionAssemblyDependencyTests.cs
Test cases now construct RunTestsSchema inputs and capture RunTestsResponse outputs; the obsolete compile-check test referencing removed types is deleted.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • hatayama/unity-cli-loop#940: Both PRs update RunTestsUseCaseTests.cs to align with the RunTestsSchema/RunTestsResponse API for RunTestsUseCase.
  • hatayama/unity-cli-loop#1192: Both PRs modify RunTestsUseCase.ExecuteAsync's flow and its test-framework/response handling.
  • hatayama/unity-cli-loop#1347: Both PRs modify RunTestsUseCase.ExecuteAsync's execution flow around Test Runner cleanup and update corresponding tests.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: removing the RunTests tool's redundant intermediate DTO layer.
Description check ✅ Passed The description is detailed and directly matches the changeset, including the DTO collapse, test updates, and preserved behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/c2-collapse-runtests-dto-layers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
Packages/src/Editor/FirstPartyTools/RunTests/RunTestsUseCase.cs (1)

112-113: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Stale comment contradicts the throw.

The comment says "Create a minimal error result", but the code now throws instead of building a result. Update or drop the comment to avoid misleading future readers of the error path.

♻️ Suggested tweak
-                // Create a minimal error result
+                // Surface the failure; the tool layer converts it into an error response.
                 throw new System.InvalidOperationException("Test execution failed. Please check the logs for details.", ex);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Packages/src/Editor/FirstPartyTools/RunTests/RunTestsUseCase.cs` around lines
112 - 113, The comment in RunTestsUseCase’s error path is stale and contradicts
the current behavior: the code now throws an InvalidOperationException instead
of creating a minimal error result. Update or remove that comment near the throw
in the RunTestsUseCase flow so it accurately reflects the exception-based
handling and does not mislead readers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Packages/src/Editor/FirstPartyTools/RunTests/RunTestsUseCase.cs`:
- Around line 112-113: The comment in RunTestsUseCase’s error path is stale and
contradicts the current behavior: the code now throws an
InvalidOperationException instead of creating a minimal error result. Update or
remove that comment near the throw in the RunTestsUseCase flow so it accurately
reflects the exception-based handling and does not mislead readers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3e689779-3f3b-4a7a-904e-1db8152bd64f

📥 Commits

Reviewing files that changed from the base of the PR and between bf0cb79 and fb5a5c5.

📒 Files selected for processing (5)
  • Assets/Tests/Editor/OnionAssemblyDependencyTests.cs
  • Assets/Tests/Editor/RunTestsUseCaseTests.cs
  • Packages/src/Editor/FirstPartyTools/RunTests/RunTestsTool.cs
  • Packages/src/Editor/FirstPartyTools/RunTests/RunTestsUseCase.cs
  • Packages/src/Editor/FirstPartyTools/RunTests/UnityCliLoopTestExecutionTypes.cs
💤 Files with no reviewable changes (1)
  • Assets/Tests/Editor/OnionAssemblyDependencyTests.cs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Re-trigger cubic

Restore the explicit ArgumentNullException guard to match the Compile
pipeline's Fail Fast precedent, reuse the existing
RunTestsResponse.CreateTestFrameworkUnavailable factory instead of
rebuilding the same shape by hand, and reword comments that referenced
the deleted intermediate DTO or contradicted the exception-based error
path.
@hatayama
hatayama merged commit 76c957e into v3-beta Jul 5, 2026
10 checks passed
@hatayama
hatayama deleted the refactor/c2-collapse-runtests-dto-layers branch July 5, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant