generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 90
fix(clippy): Store exit code to respect errors #707
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
blorente
wants to merge
4
commits into
aspect-build:main
Choose a base branch
from
blorente:blorente/keep-clippy-errors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+166
−71
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,5 @@ | ||
| --- a/MODULE.bazel | ||
| +++ b/MODULE.bazel | ||
| @@ -34,7 +34,7 @@ use_repo(multitool, "multitool") | ||
|
|
||
| # To allow /tools to be built from source | ||
| # NOTE: when publishing to BCR, we patch this to be True, as we publish pre-built binaries with our releases. | ||
| @@ -9,1 +9,1 @@ | ||
| -IS_RELEASE = False | ||
| +IS_RELEASE = True | ||
|
|
||
| bazel_dep( | ||
| name = "toolchains_protoc", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| fn main() { | ||
| // Will fail clippy because we could just write println!("Hello World"). | ||
| println!("{}", "Hello World"); | ||
| // Will fail clippy because of the missing comma | ||
| let _missing_comma = &[ | ||
| -1, -2, -3 // <= no comma here | ||
| -4, -5, -6 | ||
| ]; | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| fn bad() { | ||
| // Will fail clippy because we could just write println!("Hello World"). | ||
| println!("{}", "Hello World"); | ||
| // Will fail clippy because of the missing comma | ||
| let _missing_comma = &[ | ||
| -1, -2, -3 // <= no comma here | ||
| -4, -5, -6 | ||
| ]; | ||
|
|
||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| fn main() { | ||
| // Will emit a clippy warning because we could just write println!("Hello World"). | ||
| println!("{}", "Hello World"); | ||
|
|
||
| // Will fail clippy because of the missing comma | ||
| let _missing_comma = &[ | ||
| -1, -2, -3 // <= no comma here | ||
| -4, -5, -6 | ||
| ]; | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| # Run the rustc process wrapper, but: | ||
| # - Instead of forwarding the exit code of the child process, capture it. | ||
| # - Instead of passing --stderr-file to the process wrapper, capture the output and write to that file after everything has finished, with the following format: | ||
| # ``` | ||
| # <exit code of process wrapper> | ||
| # <stderr of process wrapper> | ||
| # ``` | ||
|
|
||
| # --- begin runfiles.bash initialization v3 --- | ||
| # Copy-pasted from the Bazel Bash runfiles library v3. | ||
| set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash | ||
| # shellcheck disable=SC1090 | ||
| source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ | ||
| source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ | ||
| source "$0.runfiles/$f" 2>/dev/null || \ | ||
| source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ | ||
| source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ | ||
| { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e | ||
| # --- end runfiles.bash initialization v3 --- | ||
|
|
||
| process_wrapper_path=$(rlocation "rules_rust/util/process_wrapper/process_wrapper") | ||
|
|
||
| stderr_file="" | ||
| cmd=("${process_wrapper_path}") | ||
|
|
||
| # Parse arguments | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --stderr-file) | ||
| if [[ $# -lt 2 ]]; then | ||
| echo "Error: --stderr-file requires a value" >&2 | ||
| exit 1 | ||
| fi | ||
| stderr_file="$2" | ||
| shift 2 | ||
| ;; | ||
| *) | ||
| cmd+=("$1") | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| # Ensure that _some_ command is left | ||
| if [[ ${#cmd[@]} -eq 0 ]]; then | ||
| echo "Error: no command to execute" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| set +e # We allow failing for this command as we want to capture the exit code | ||
|
|
||
| out=$(${cmd[@]} 2>&1) | ||
| exit_code="$?" | ||
|
|
||
| set -e | ||
|
|
||
| cat <<EOF > "${stderr_file}" | ||
| ${exit_code} | ||
| ${out} | ||
| EOF | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in a follow-up, I'd like to evaluate if https://github.com/malt3/hermetic-launcher would be better (less Bash dependency, more likely to work on Windows)