Skip to content

When evals fail, exit with status code 1 #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

maraisr
Copy link
Member

@maraisr maraisr commented Jun 7, 2025

When running evals, I feel its a good idea to exit with status code of 1 that without parsing outputs we can know if evals passed or not.

Error: ❌ Some tests failed.
exit status 1

I did think maybe a CLI flag to invert this behaviour would be cool, but folk smarter than me say its something shell scripts can just do, see: jestjs/jest#10306 (comment)

@Copilot Copilot AI review requested due to automatic review settings June 7, 2025 07:21
@maraisr maraisr requested a review from a team as a code owner June 7, 2025 07:21
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures eval commands exit with status code 1 when tests fail by introducing a sentinel error and updating CLI handling and tests.

  • Adds FailedTests sentinel error and returns it when any test fails.
  • Updates the Cobra command to silence usage on FailedTests and propagate a non-zero exit.
  • Adjusts tests to expect FailedTests instead of no error.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/eval/eval.go Introduced FailedTests error, updated runEvaluation to return it, and silenced usage in RunE when it occurs.
cmd/eval/eval_test.go Changed assertions to expect FailedTests via require.ErrorIs instead of require.NoError.
Comments suppressed due to low confidence (2)

cmd/eval/eval.go:116

  • Add a unit test for the Cobra command to verify that SilenceUsage is set to true when FailedTests is returned, ensuring the CLI usage output is correctly suppressed.
cmd.SilenceUsage = true

cmd/eval/eval.go:111

  • Use a short variable declaration (err := handler.runEvaluation(...)) so err is defined in this scope rather than assigning to an undefined variable.
err = handler.runEvaluation(cmd.Context())

@maraisr maraisr requested a review from sgoedecke June 7, 2025 07:23
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