Skip to content

Commit 0b102d2

Browse files
committed
checkpoint: Passes tests
1 parent 3e334b4 commit 0b102d2

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

lint/clippy.bzl

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,25 @@ load("//lint/private:lint_aspect.bzl", "LintOptionsInfo", "OPTIONAL_SARIF_PARSER
4848

4949
_MNEMONIC = "AspectRulesLintClippy"
5050

51-
def _parse_wrapper_output_into_files(ctx, outputs, raw_process_wrapper_wrapper_output):
51+
def _parse_wrapper_output_into_files(ctx, output_file, exit_code_file, raw_process_wrapper_wrapper_output):
5252
ctx.actions.run_shell(
5353
command = """
5454
exit_code=$(head -n 1 $1)
55-
output=$(tail -n +1 $1)
55+
output=$(tail -n +2 $1)
5656
echo "${output}" > $2
5757
echo "${exit_code}" > $3
58-
echo "${exit_code}" > $4
5958
""",
6059
arguments = [
6160
raw_process_wrapper_wrapper_output.path,
62-
outputs.human.out.path,
63-
outputs.human.exit_code.path,
64-
outputs.machine.exit_code.path,
61+
output_file.path,
62+
exit_code_file.path,
6563
],
6664
inputs = [
6765
raw_process_wrapper_wrapper_output,
6866
],
6967
outputs = [
70-
outputs.human.out,
71-
outputs.human.exit_code,
72-
outputs.machine.exit_code,
68+
output_file,
69+
exit_code_file,
7370
],
7471
)
7572

@@ -106,21 +103,37 @@ def _clippy_aspect_impl(target, ctx):
106103
# (1) modify the patcher so that it can run an action through a macro, or
107104
# (2) modify rules_rust so that it gives us a struct with a command line we can run it with the patcher.
108105

109-
raw_process_wrapper_wrapper_output = ctx.actions.declare_file(OUTFILE_FORMAT.format(label = target.label.name, mnemonic = _MNEMONIC, suffix = "raw_process_wrapper_wrapper_output"))
106+
raw_outputs = struct(
107+
human = ctx.actions.declare_file(OUTFILE_FORMAT.format(label = target.label.name, mnemonic = _MNEMONIC, suffix = "raw_process_wrapper_wrapper_output_human")),
108+
machine = ctx.actions.declare_file(OUTFILE_FORMAT.format(label = target.label.name, mnemonic = _MNEMONIC, suffix = "raw_process_wrapper_wrapper_output_machine")),
109+
)
110+
111+
rust_clippy_action.action(
112+
ctx,
113+
clippy_executable = clippy_bin,
114+
process_wrapper = ctx.executable._process_wrapper_wrapper,
115+
crate_info = crate_info,
116+
config = ctx.file._config_file,
117+
output = raw_outputs.human,
118+
cap_at_warnings = False,
119+
extra_clippy_flags = extra_options,
120+
)
121+
122+
_parse_wrapper_output_into_files(ctx, outputs.human.out, outputs.human.exit_code, raw_outputs.human)
110123

111124
rust_clippy_action.action(
112125
ctx,
113126
clippy_executable = clippy_bin,
114127
process_wrapper = ctx.executable._process_wrapper_wrapper,
115128
crate_info = crate_info,
116129
config = ctx.file._config_file,
117-
output = raw_process_wrapper_wrapper_output,
130+
output = raw_outputs.machine,
118131
cap_at_warnings = False,
119132
extra_clippy_flags = extra_options,
120-
clippy_diagnostics_file = outputs.machine.out,
133+
error_format = "json",
121134
)
122135

123-
_parse_wrapper_output_into_files(ctx, outputs, raw_process_wrapper_wrapper_output)
136+
_parse_wrapper_output_into_files(ctx, outputs.machine.out, outputs.machine.exit_code, raw_outputs.machine)
124137

125138
# FIXME: Rustc only gives us JSON output, which we can't turn into SARIF yet.
126139
# clippy uses rustc's IO format, which doesn't have a SARIF output mode built in,

0 commit comments

Comments
 (0)