Skip to content

tests(cli): add test coverage for jj run stub command#9016

Closed
RajPabnani03 wants to merge 2 commits into
jj-vcs:mainfrom
RajPabnani03:claude/analyze-test-coverage-91JDI
Closed

tests(cli): add test coverage for jj run stub command#9016
RajPabnani03 wants to merge 2 commits into
jj-vcs:mainfrom
RajPabnani03:claude/analyze-test-coverage-91JDI

Conversation

@RajPabnani03
Copy link
Copy Markdown

Summary

  • Adds cli/tests/test_run_command.rs with 6 tests covering the jj run stub command
  • Registers mod test_run_command in runner.rs in correct alphabetical order

Background

jj run is a stub command that unconditionally returns "This is a stub, do not use" after
performing argument parsing and revision resolution. It had zero test coverage, identified
during a broader test-coverage audit of the codebase.

Tests added

Test What it verifies
test_run_is_stub Baseline: stub error is returned for a valid in-repo invocation
test_run_accepts_jobs_flag --jobs N / -j N are parsed without a spurious pre-stub error
test_run_accepts_revset_flag -r @ resolves the revset before the stub is reached
test_run_accepts_hidden_x_flag Hidden -x compat flag (mirrors git rebase -x) is silently accepted
test_run_outside_repo workspace_helper check fires before the stub — returns "no jj repo" error
test_run_invalid_revset A bad revset returns a parse error, not the stub error, proving resolution runs first

Why test a stub?

  1. Regression guard — any future wiring of real implementation code must update these
    tests, making the activation visible in review rather than silently activating.
  2. CLI contract — the flags (--jobs, --revisions, -x) and their accepted values
    are part of the public CLI surface even before the command is implemented.
  3. Repo requirement — confirms workspace_helper takes priority over the stub for
    out-of-repo invocations.

Test plan

  • All 6 new tests pass: cargo test --package jj-cli --test runner test_run
  • test_no_forgotten_test_files guard passes
  • No regressions in existing tests

@RajPabnani03 RajPabnani03 requested a review from a team as a code owner March 3, 2026 16:58
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Mar 3, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@martinvonz
Copy link
Copy Markdown
Member

I'm sorry, but I don't think we need tests for a stub command. I'm very tempted to close this.

claude added 2 commits March 3, 2026 17:19
Adds `cli/tests/test_run_command.rs` with 6 tests covering the `jj run`
stub command:

- `test_run_is_stub` — baseline: correct stub error is returned
- `test_run_accepts_jobs_flag` — --jobs / -j flags are parsed without error
- `test_run_accepts_revset_flag` — -r flag resolves a valid revset before stub
- `test_run_accepts_hidden_x_flag` — hidden -x compat flag is accepted silently
- `test_run_outside_repo` — workspace check fires before stub is reached
- `test_run_invalid_revset` — bad revset yields parse error, not stub error

The tests document the CLI contract for the stub: flag parsing and revision
resolution are exercised, and the stub error is always the terminal failure
for valid invocations inside a repository. This acts as a regression guard so
that any future activation of real `run` logic must update these tests.

https://claude.ai/code/session_019cMU6DHSWoMYw4sP3hVP4D
Move `mod test_run_command` to its correct position after `mod test_root`
and before `mod test_show_command`, matching the alphabetical ordering
convention used throughout the file.

https://claude.ai/code/session_019cMU6DHSWoMYw4sP3hVP4D
@RajPabnani03 RajPabnani03 force-pushed the claude/analyze-test-coverage-91JDI branch from 8df0adc to 8b0d5e7 Compare March 3, 2026 17:23
@PhilipMetzger
Copy link
Copy Markdown
Contributor

I'm sorry, but I don't think we need tests for a stub command. I'm very tempted to close this.

It being mostly AI generated also is something you should consider in this.

@martinvonz
Copy link
Copy Markdown
Member

I'm fine with it being AI generated as long as the quality is good and the author doesn't just throw it over the wall and waste the reviewer's time by having the reviewer find all the problems the author should have found before sending it. That's basically what the proposed policy in #8897 says.

@RajPabnani03 RajPabnani03 marked this pull request as draft March 3, 2026 17:27
@martinvonz
Copy link
Copy Markdown
Member

@RajPabnani03: I just realized that my comment above could have been interpreted as being directed at you, so I wanted to clarify that it wasn't. I have only spent a few seconds looking at the code, so I couldn't say if it was well written. I think it's just not time for tests of the jj run command at this point regardless of how well-written they are.

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.

4 participants