aspect-build / aspect-build/rules_js

[FR]: Ability to specify expected exit codes for js_run_binary

Open
#1,166 1 comment 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
Starlark
Stars
378
Forks
183
Avg merge
1d 9h
Merged PRs (30d)
32

Description

### What is the current behavior?

A `js_run_binary` target will succeed on exit code 0, or fail on any other. Alternatively, by setting `exit_code_out`, you can capture the exit code to a file, but then any exit code will pass, and you need a separate test to assert that the exit code matches what you expect.

### Describe the feature

Introduce an `allowed_exit_codes` or similar to `js_run_binary`, that checks the exit code matches one of the expected exit codes.

We are running ESLint as a `js_run_binary` to generate a checkstyle report, and the `exit_code_out` is not fine-grained enough:

> ## Exit Codes
>
> When linting files, ESLint exits with one of the following exit codes:
>
> - `0`: Linting was successful and there are no linting errors. If the [`--max-warnings`](https://eslint.org/docs/latest/use/command-line-interface#--max-warnings) flag is set to n, the number of linting warnings is at most `n`.
> - `1`: Linting was successful and there is at least one linting error, or there are more linting warnings than allowed by the `--max-warnings` option.
> - `2`: Linting was unsuccessful due to a configuration problem or an internal error.

I would like our Bazel target to pass on exit codes 0 or 1, but fail on exit code 2.

Contributor guide

Open the contributing guide

Research direction

Start at the js_run_binary rule and trace how exit_code_out currently handles process status. Define the expected behavior for the new exit-code setting: codes 0 and 1 should pass, while code 2 should fail, and verify the existing rule behavior around nonzero exits before determining the relevant coverage to update.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.