You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2017/07/28 00:13:21 UTC
kudu git commit: clang_tidy_gerrit.py: add a local mode
Repository: kudu
Updated Branches:
refs/heads/master 5b7626e3a -> ef8e46b40
clang_tidy_gerrit.py: add a local mode
This patch makes it possible to run clang_tidy_gerrit.py "locally" (i.e.
without posting anything to gerrit). The new argument parsing is such that
regular clang_tidy_gerrit.py runs should continue to work unmolested.
Here is some sample output:
$ build-support/clang_tidy_gerrit.py -n HEAD
42349 warnings generated.
83338 warnings generated.
Suppressed 83398 warnings (83331 in non-user code, 5 due to line filter, 61 NOLINT, 1 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
INFO:root:Clang output
INFO:root:/home/adar/Source/kudu/src/kudu/consensus/raft_consensus.cc:2253:69: warning: the parameter 'client_cb' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
StdStatusCallback client_cb,
^
Skipping gerrit
Change-Id: I2910d32e4318eea4ca947c52717ee386063fa45f
Reviewed-on: http://gerrit.cloudera.org:8080/7528
Reviewed-by: Todd Lipcon <to...@apache.org>
Tested-by: Adar Dembo <ad...@cloudera.com>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/ef8e46b4
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/ef8e46b4
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/ef8e46b4
Branch: refs/heads/master
Commit: ef8e46b401e782fc17462779b703d16e10e82402
Parents: 5b7626e
Author: Adar Dembo <ad...@cloudera.com>
Authored: Thu Jul 27 16:44:33 2017 -0700
Committer: Adar Dembo <ad...@cloudera.com>
Committed: Fri Jul 28 00:11:42 2017 +0000
----------------------------------------------------------------------
build-support/clang_tidy_gerrit.py | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/ef8e46b4/build-support/clang_tidy_gerrit.py
----------------------------------------------------------------------
diff --git a/build-support/clang_tidy_gerrit.py b/build-support/clang_tidy_gerrit.py
index 5e38f52..b98181c 100755
--- a/build-support/clang_tidy_gerrit.py
+++ b/build-support/clang_tidy_gerrit.py
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
+import argparse
import collections
import compile_flags
import json
@@ -152,14 +153,27 @@ class TestClangTidyGerrit(unittest.TestCase):
if __name__ == "__main__":
+ # Basic setup and argument parsing.
logging.basicConfig(level=logging.INFO)
-
- rev = sys.argv[1]
- revision_url = get_gerrit_revision_url(rev)
- print revision_url
- clang_output = run_tidy(rev)
+ parser = argparse.ArgumentParser(
+ description="Run clang-tidy on a patch, optionally posting warnings as comments to gerrit")
+ parser.add_argument("-n", "--no-gerrit", action="store_true",
+ help="Whether to run locally i.e. (no interaction with gerrit)")
+ parser.add_argument('rev', help="The git revision to process")
+ args = parser.parse_args()
+
+ # Find the gerrit revision URL, if applicable.
+ if not args.no_gerrit:
+ revision_url = get_gerrit_revision_url(args.rev)
+ print revision_url
+
+ # Run clang-tidy and parse the output.
+ clang_output = run_tidy(args.rev)
logging.info("Clang output")
logging.info(clang_output)
+ if args.no_gerrit:
+ print >>sys.stderr, "Skipping gerrit"
+ sys.exit(0)
logging.info("=" * 80)
parsed = parse_clang_output(clang_output)
if not parsed:
@@ -168,8 +182,8 @@ if __name__ == "__main__":
print "Parsed clang warnings:"
print json.dumps(parsed, indent=4)
+ # Post the output as comments to the gerrit URL.
gerrit_json_obj = create_gerrit_json_obj(parsed)
print "Will post to gerrit:"
print json.dumps(gerrit_json_obj, indent=4)
-
post_comments(revision_url, gerrit_json_obj)