This is an automated email from the ASF dual-hosted git repository.

uwe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new ae5e4b8  ARROW-2809: [C++] Only print cpplint and clang-format output 
for failures by default
ae5e4b8 is described below

commit ae5e4b867077151eb672ae461176ca7b5c5beb7f
Author: Wes McKinney <[email protected]>
AuthorDate: Sun Jul 8 20:18:05 2018 +0200

    ARROW-2809: [C++] Only print cpplint and clang-format output for failures 
by default
    
    I added a `ARROW_VERBOSE_LINT` CMake option so this can be turned on and 
off. This helps trim down on the verbosity in our Travis CI logs
    
    Author: Wes McKinney <[email protected]>
    
    Closes #2229 from wesm/ARROW-2809 and squashes the following commits:
    
    292b6e2d <Wes McKinney> Only print cpplint and clang-format output for 
failures by default
---
 cpp/CMakeLists.txt                    | 16 +++++++++++-----
 cpp/build-support/run_clang_format.py | 26 +++++++++++++++++---------
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 9ac59e9..f5477d9 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -239,6 +239,10 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL 
"${CMAKE_CURRENT_SOURCE_DIR}")
     "If off, output from ExternalProjects will be logged to files rather than 
shown"
     OFF)
 
+  option(ARROW_VERBOSE_LINT
+    "If off, 'quiet' flags will be passed to linting tools"
+    OFF)
+
   if (MSVC)
     option(ARROW_USE_CLCACHE
       "Use clcache if available"
@@ -470,6 +474,10 @@ endif (UNIX)
 ############################################################
 # "make lint" target
 ############################################################
+if (NOT ARROW_VERBOSE_LINT)
+  set(ARROW_LINT_QUIET "--quiet")
+endif()
+
 if (UNIX)
 
   file(GLOB_RECURSE LINT_FILES
@@ -498,7 +506,7 @@ if (UNIX)
   # so process 12 files per invocation, while still ensuring parallelism
   add_custom_target(lint echo ${FILTERED_LINT_FILES} | xargs -n12 -P8
   ${CPPLINT_BIN}
-  --verbose=2
+  --verbose=2 ${ARROW_LINT_QUIET}
   --linelength=90
   
--filter=-whitespace/comments,-readability/todo,-build/header_guard,-build/c++11,-runtime/references,-build/include_order
   )
@@ -513,15 +521,13 @@ endif (UNIX)
 add_custom_target(format ${BUILD_SUPPORT_DIR}/run_clang_format.py
   ${CLANG_FORMAT_BIN}
   ${BUILD_SUPPORT_DIR}/clang_format_exclusions.txt
-  ${CMAKE_CURRENT_SOURCE_DIR}/src --fix)
+  ${CMAKE_CURRENT_SOURCE_DIR}/src --fix ${ARROW_LINT_QUIET})
 
 # runs clang format and exits with a non-zero exit code if any files need to 
be reformatted
-
-# TODO(wesm): Make this work in run_clang_format.py
 add_custom_target(check-format ${BUILD_SUPPORT_DIR}/run_clang_format.py
    ${CLANG_FORMAT_BIN}
    ${BUILD_SUPPORT_DIR}/clang_format_exclusions.txt
-   ${CMAKE_CURRENT_SOURCE_DIR}/src)
+   ${CMAKE_CURRENT_SOURCE_DIR}/src ${ARROW_LINT_QUIET})
 
 ############################################################
 # "make clang-tidy" and "make check-clang-tidy" targets
diff --git a/cpp/build-support/run_clang_format.py 
b/cpp/build-support/run_clang_format.py
index 29938f6..6edac5f 100755
--- a/cpp/build-support/run_clang_format.py
+++ b/cpp/build-support/run_clang_format.py
@@ -35,38 +35,45 @@ if __name__ == "__main__":
     parser.add_argument("exclude_globs",
                         help="Filename containing globs for files "
                         "that should be excluded from the checks")
-    parser.add_argument("source_dir", 
+    parser.add_argument("source_dir",
                         help="Root directory of the source code")
     parser.add_argument("--fix", default=False,
                         action="store_true",
                         help="If specified, will re-format the source "
                         "code instead of comparing the re-formatted "
                         "output, defaults to %(default)s")
+    parser.add_argument("--quiet", default=False,
+                        action="store_true",
+                        help="If specified, only print errors")
 
     arguments = parser.parse_args()
 
     formatted_filenames = []
     exclude_globs = [line.strip() for line in open(arguments.exclude_globs)]
     for directory, subdirs, filenames in os.walk(arguments.source_dir):
-        fullpaths = (os.path.join(directory, filename) for filename in 
filenames)
-        source_files = filter(lambda x: x.endswith(".h") or x.endswith(".cc"), 
fullpaths)
+        fullpaths = (os.path.join(directory, filename)
+                     for filename in filenames)
+        source_files = [x for x in fullpaths
+                        if x.endswith(".h") or x.endswith(".cc")]
         formatted_filenames.extend(
             # Filter out files that match the globs in the globs file
             [filename for filename in source_files
              if not any((fnmatch.fnmatch(filename, exclude_glob)
                          for exclude_glob in exclude_globs))])
-        
+
     error = False
     if arguments.fix:
-        # Print out each file on its own line, but run
-        # clang format once for all of the files
-        print("\n".join(map(lambda x: "Formatting {}".format(x),
-                            formatted_filenames)))
+        if not arguments.quiet:
+            # Print out each file on its own line, but run
+            # clang format once for all of the files
+            print("\n".join(map(lambda x: "Formatting {}".format(x),
+                                formatted_filenames)))
         subprocess.check_call([arguments.clang_format_binary,
                                "-i"] + formatted_filenames)
     else:
         for filename in formatted_filenames:
-            print("Checking {}".format(filename))
+            if not arguments.quiet:
+                print("Checking {}".format(filename))
             #
             # Due to some incompatibilities between Python 2 and
             # Python 3, there are some specific actions we take here
@@ -101,6 +108,7 @@ if __name__ == "__main__":
                     tofile="{} (after clang format)".format(
                         filename)))
                 if diff:
+                    print("{} had clang-format style issues".format(filename))
                     # Print out the diff to stderr
                     error = True
                     sys.stderr.writelines(diff)

Reply via email to