Skip to content

fix(refacto-p1): unified cmds execution flow (+ rm dead code)#904

Merged
aeppling merged 7 commits intodevelopfrom
refacto-folders-and-documentation
Mar 30, 2026
Merged

fix(refacto-p1): unified cmds execution flow (+ rm dead code)#904
aeppling merged 7 commits intodevelopfrom
refacto-folders-and-documentation

Conversation

@aeppling
Copy link
Copy Markdown
Contributor

Part 2 of codebase refacto

Summary

  • Standardize exit code handling across all modules: Result<()> → Result with a single process::exit() in main.rs — modules
    never call process::exit() directly
  • Standardize filter execution flow across commands
  • Fix critical bug in runner.rs where rtk err and rtk test always exited 0 regardless of command failure
  • Add exit_code_from_status() helper for passthrough commands and centralize signal handling (128+signal) in
    exit_code_from_output()

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test — 1123 passed, 0 failed
  • Zero std::process::exit() in src/cmds/ and src/core/ (verified via grep), exactly 1 in main.rs
  • golangci-lint exit 1 exception preserved (lint issues → exit 0, matching old behavior)
  • src/cmds/README.md updated with new Result contract, examples, and exit code tables
  • Manual testing: rtk ; echo $? for success (0) and failure (non-zero) paths

@aeppling aeppling closed this Mar 28, 2026
@aeppling aeppling deleted the refacto-folders-and-documentation branch March 28, 2026 23:18
@aeppling aeppling restored the refacto-folders-and-documentation branch March 29, 2026 00:41
@aeppling aeppling reopened this Mar 29, 2026
@aeppling aeppling changed the title fix(refacto): unified cmds execution flow (+ rm dead code) fix(refacto-p1): unified cmds execution flow (+ rm dead code) Mar 29, 2026
@aeppling aeppling force-pushed the refacto-folders-and-documentation branch from c7db13d to 48ec28d Compare March 29, 2026 12:22
Copy link
Copy Markdown
Collaborator

@FlorianBruniaux FlorianBruniaux left a comment

Choose a reason for hiding this comment

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

Good refactor overall. Single exit point is the right call, the exit_code_from_output helper is solid. One inconsistency survived the pass (see inline). All 1123 tests pass, 9/9 CI checks green. LGTM with minor fix.

Comment thread src/cmds/js/vitest_cmd.rs
// Propagate original exit code
std::process::exit(exit_code)
if !output.status.success() {
return Ok(exit_code);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This exit_code was computed with .code().unwrap_or(1) at line 265, not with exit_code_from_output(). Signal kills on vitest return 1 instead of 128+signal, which breaks the zero-.code().unwrap_or(1) invariant the PR description claims.

One-line fix at line 265:

let exit_code = exit_code_from_output(&output, "vitest");

Copy link
Copy Markdown
Collaborator

@FlorianBruniaux FlorianBruniaux left a comment

Choose a reason for hiding this comment

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

Good refactor. Single exit point is the right call and exit_code_from_output is solid. One thing that slipped through: vitest_cmd.rs line 265 still computes exit_code with .code().unwrap_or(1) instead of the new exit_code_from_output(&output, "vitest") helper. Signal kills on vitest will return 1 instead of 128+signal, breaking the zero-.code().unwrap_or(1) invariant the PR description claims. One-line fix, everything else looks good. All 1123 tests pass, 9/9 CI checks green.

@aeppling
Copy link
Copy Markdown
Contributor Author

Thanks for the review @FlorianBruniaux , missing migration have been addressed in last commit

@aeppling aeppling merged commit 75bd607 into develop Mar 30, 2026
9 checks passed
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.

2 participants