summaryrefslogtreecommitdiffstats
path: root/run_tests
diff options
context:
space:
mode:
Diffstat (limited to 'run_tests')
-rwxr-xr-xrun_tests26
1 files changed, 19 insertions, 7 deletions
diff --git a/run_tests b/run_tests
index 69ba2769..2d92cae3 100755
--- a/run_tests
+++ b/run_tests
@@ -13,7 +13,7 @@
13# See the License for the specific language governing permissions and 13# See the License for the specific language governing permissions and
14# limitations under the License. 14# limitations under the License.
15 15
16"""Wrapper to run black and pytest with the right settings.""" 16"""Wrapper to run linters and pytest with the right settings."""
17 17
18import os 18import os
19import subprocess 19import subprocess
@@ -21,19 +21,31 @@ import sys
21import pytest 21import pytest
22 22
23 23
24ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
25
26
24def run_black(): 27def run_black():
25 """Returns the exit code of running `black --check`.""" 28 """Returns the exit code from black."""
26 dirpath = os.path.dirname(os.path.realpath(__file__)) 29 return subprocess.run(
30 [sys.executable, "-m", "black", "--check", ROOT_DIR], check=False
31 ).returncode
32
33
34def run_flake8():
35 """Returns the exit code from flake8."""
27 return subprocess.run( 36 return subprocess.run(
28 [sys.executable, "-m", "black", "--check", dirpath], check=False 37 [sys.executable, "-m", "flake8", ROOT_DIR], check=False
29 ).returncode 38 ).returncode
30 39
31 40
32def main(argv): 41def main(argv):
33 """The main entry.""" 42 """The main entry."""
34 pytest_ret = pytest.main(argv) 43 checks = (
35 black_ret = run_black() 44 lambda: pytest.main(argv),
36 return 0 if not black_ret and not pytest_ret else 1 45 run_black,
46 run_flake8,
47 )
48 return 0 if all(not c() for c in checks) else 1
37 49
38 50
39if __name__ == "__main__": 51if __name__ == "__main__":