Skip to content

Commit

Permalink
Check if exit_code file is None
Browse files Browse the repository at this point in the history
If we have a lint aspect that has no files to lint and run with fail-on-validation
the exit_code file will be set to None. Which is why we need to check
that its not None before trying to access its path.
  • Loading branch information
Tobias Slettemoen Kongsvik authored and tokongs committed Aug 9, 2024
1 parent 6c59e30 commit 2513d43
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lint/private/lint_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,17 @@ def noop_lint_action(ctx, outputs):
commands.append("touch {}".format(outputs.human.out.path))
commands.append("touch {}".format(outputs.machine.out.path))

outs = [outputs.human.out, outputs.machine.out]

# NB: if we write JSON machine-readable outputs, then an empty file won't be appropriate
commands.append("echo 0 > {}".format(outputs.human.exit_code.path))
commands.append("echo 0 > {}".format(outputs.machine.exit_code.path))
if outputs.human.exit_code:
commands.append("echo 0 > {}".format(outputs.human.exit_code.path))
outs += [outputs.human.exit_code]

if outputs.machine.exit_code:
commands.append("echo 0 > {}".format(outputs.machine.exit_code.path))
outs += [outputs.machine.exit_code]

outs = [outputs.human.out, outputs.human.exit_code, outputs.machine.out, outputs.machine.exit_code]
if hasattr(outputs, "patch"):
commands.append("touch {}".format(outputs.patch.path))
outs.append(outputs.patch)
Expand Down

0 comments on commit 2513d43

Please sign in to comment.