summaryrefslogtreecommitdiff
path: root/java/lint.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2022-10-11 11:22:24 -0700
committer Colin Cross <ccross@android.com> 2022-10-11 11:22:24 -0700
commit1b9e68389deca10dc849befcf83101e8dbdcc507 (patch)
tree49050134e9dbf6720d7ce9ad2df3ccef189653d5 /java/lint.go
parent17e0b7607a640dd419ba39cd10a189ae2103ec93 (diff)
Create suggested-fixes.zip before exiting on error
suggested-fixes.zip is useful even when lint is exiting with an error. Save the exit code from the lint executable, create the zip file, then re-exit with the exit code. Bug: 216456886 Test: Introduce lint error, verify suggested-fixes.zip is created. Change-Id: I0ba6190e3de0744e53b2a59ba3016861f2f115e2
Diffstat (limited to 'java/lint.go')
-rw-r--r--java/lint.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/java/lint.go b/java/lint.go
index 931820d74..fcd6d31ff 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -473,20 +473,23 @@ func (l *linter) lint(ctx android.ModuleContext) {
cmd.FlagWithOutput("--write-reference-baseline ", baseline)
- cmd.Text("|| (").Text("if [ -e").Input(text).Text("]; then cat").Input(text).Text("; fi; exit 7)")
-
- rule.Command().Text("rm -rf").Flag(lintPaths.cacheDir.String()).Flag(lintPaths.homeDir.String())
-
- // The HTML output contains a date, remove it to make the output deterministic.
- rule.Command().Text(`sed -i.tmp -e 's|Check performed at .*\(</nav>\)|\1|'`).Output(html)
+ cmd.Text("; EXITCODE=$?; ")
// The sources in the sandbox may have been modified by --apply-suggestions, zip them up and
- // export them out of the sandbox.
- rule.Command().BuiltTool("soong_zip").
+ // export them out of the sandbox. Do this before exiting so that the suggestions exit even after
+ // a fatal error.
+ cmd.BuiltTool("soong_zip").
FlagWithOutput("-o ", android.PathForModuleOut(ctx, "lint", "suggested-fixes.zip")).
FlagWithArg("-C ", cmd.PathForInput(android.PathForSource(ctx))).
FlagWithInput("-r ", srcsList)
+ cmd.Text("; if [ $EXITCODE != 0 ]; then if [ -e").Input(text).Text("]; then cat").Input(text).Text("; fi; exit $EXITCODE; fi")
+
+ rule.Command().Text("rm -rf").Flag(lintPaths.cacheDir.String()).Flag(lintPaths.homeDir.String())
+
+ // The HTML output contains a date, remove it to make the output deterministic.
+ rule.Command().Text(`sed -i.tmp -e 's|Check performed at .*\(</nav>\)|\1|'`).Output(html)
+
rule.Build("lint", "lint")
l.outputs = lintOutputs{