Syntax check python files on testing (#6209)
Summary: Adds a python script to syntax check all python files in the repository and report any errors. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6209 Test Plan: 'make check' with and without seeded syntax errors. Also look for "No syntax errors in 34 .py files" on success, and in java_test CI output Differential Revision: D19166756 Pulled By: pdillinger fbshipit-source-id: 537df464b767260d66810b4cf4c9808a026c58a4main
parent
54f9092b0c
commit
5b18729d7d
@ -0,0 +1,17 @@ |
|||||||
|
#!/usr/bin/env python2 |
||||||
|
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. |
||||||
|
import glob |
||||||
|
|
||||||
|
# Checks that all python files in the repository are at least free of syntax |
||||||
|
# errors. This provides a minimal pre-/post-commit check for python file |
||||||
|
# modifications. |
||||||
|
|
||||||
|
count = 0 |
||||||
|
# Clean this up when we finally upgrade to Python 3 |
||||||
|
for filename in glob.glob("*.py") + glob.glob("*/*.py") + glob.glob("*/*/*.py") + glob.glob("*/*/*/*.py"): |
||||||
|
source = open(filename, 'r').read() + '\n' |
||||||
|
# Parses and syntax checks the file, throwing on error. (No pyc written.) |
||||||
|
_ = compile(source, filename, 'exec') |
||||||
|
count = count + 1 |
||||||
|
|
||||||
|
print("No syntax errors in {0} .py files".format(count)) |
Loading…
Reference in new issue