diff options
author | Tobias Bosch <tbosch@google.com> | 2019-07-10 06:23:57 -0700 |
---|---|---|
committer | Tobias Bosch <tbosch@google.com> | 2019-07-11 08:28:16 +0000 |
commit | 9332d21c19199f99886b1476cab6f4dd89e82a72 (patch) | |
tree | 2825d3172d14a689305cb00fa9545d30040947e6 /compiler_wrapper/clang_tidy_flag.go | |
parent | 4044dab9b197cb72281b540750e425180028897f (diff) | |
download | toolchain-utils-9332d21c19199f99886b1476cab6f4dd89e82a72.tar.gz |
Unify command error handling
BUG=chromium:773875
TEST=unit test
Change-Id: Ibe32309c021d72e08cecc7d6830756fa1503e809
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1695801
Reviewed-by: Tobias Bosch <tbosch@google.com>
Tested-by: Tobias Bosch <tbosch@google.com>
Diffstat (limited to 'compiler_wrapper/clang_tidy_flag.go')
-rw-r--r-- | compiler_wrapper/clang_tidy_flag.go | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/compiler_wrapper/clang_tidy_flag.go b/compiler_wrapper/clang_tidy_flag.go index 9c1761ee..4a648ce1 100644 --- a/compiler_wrapper/clang_tidy_flag.go +++ b/compiler_wrapper/clang_tidy_flag.go @@ -73,18 +73,14 @@ func runClangTidy(env env, clangCmd *command, cSrcFile string) error { envUpdates: clangCmd.envUpdates, } - if err := env.run(clangTidyCmd, env.stdout(), env.stderr()); err != nil { - if _, ok := getExitCode(err); ok { - // Note: We continue on purpose when clang-tidy fails - // to maintain compatibility with the previous wrapper. - fmt.Fprintf(env.stderr(), "clang-tidy failed") - } else { - return wrapErrorwithSourceLocf(err, "failed to call clang tidy. Command: %#v", - clangTidyCmd) - } + exitCode, err := wrapSubprocessErrorWithSourceLoc(clangTidyCmd, + env.run(clangTidyCmd, env.stdout(), env.stderr())) + if err == nil && exitCode != 0 { + // Note: We continue on purpose when clang-tidy fails + // to maintain compatibility with the previous wrapper. + fmt.Fprintf(env.stderr(), "clang-tidy failed") } - - return nil + return err } func hasAtLeastOneSuffix(s string, suffixes []string) bool { |