test(cmdtest): default to an executor that fails clearly

Description

cmdtest.NewTestFactory sets a default for every stub except the executor, so Factory.Executor() returns nil. A test that reaches the executor without cmdtest.WithExecutor panics with a nil pointer dereference, and the panic stops the whole package's test run. Every existing test passes WithExecutor, so nothing fails today. This guards future tests.

This MR adds a default, failingExecutor, whose methods return an error that names cmdtest.WithExecutor. A test that forgets the option now fails on its own, with a message that says how to fix it. WithExecutor still overrides the default.

A test whose expected outcome is a LookPath failure, such as the dependency-firewall "git is required" hint, still passes without WithExecutor, because WithGitRequiredHint treats any LookPath error as git missing.

Stacked on !4421 (merged). Merge that one first.

Follow-up from !4421 (comment 4244655893), related to https://gitlab.com/gitlab-org/cli/-/work_items/8741.

How has this been tested?

  • TestNewTestFactoryWithoutExecutorFailsWithHint checks that each of the four executor methods returns the cmdtest.WithExecutor error. It panics when the default is removed, and fails when the hint is dropped from the message.
  • With WithExecutor removed from TestPackageBaseRepoErrorWithGitInstalledHasNoGitHint, the test panicked before this change. With it, the test fails on its assertion.
  • The existing unit tests pass.

Merge request reports

Loading
Loading