mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
run_tests: Check flake8
This also gets enforced in CQ. Bug: b/267675342 Change-Id: I8ffcc5d583275072fd61ae65ae4214b36bfa59f3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/366799 Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
This commit is contained in:
parent
e74d9046ee
commit
57cb42861d
26
run_tests
26
run_tests
@ -13,7 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
"""Wrapper to run black and pytest with the right settings."""
|
"""Wrapper to run linters and pytest with the right settings."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -21,19 +21,31 @@ import sys
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
|
||||||
def run_black():
|
def run_black():
|
||||||
"""Returns the exit code of running `black --check`."""
|
"""Returns the exit code from black."""
|
||||||
dirpath = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
return subprocess.run(
|
return subprocess.run(
|
||||||
[sys.executable, "-m", "black", "--check", dirpath], check=False
|
[sys.executable, "-m", "black", "--check", ROOT_DIR], check=False
|
||||||
|
).returncode
|
||||||
|
|
||||||
|
|
||||||
|
def run_flake8():
|
||||||
|
"""Returns the exit code from flake8."""
|
||||||
|
return subprocess.run(
|
||||||
|
[sys.executable, "-m", "flake8", ROOT_DIR], check=False
|
||||||
).returncode
|
).returncode
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
"""The main entry."""
|
"""The main entry."""
|
||||||
pytest_ret = pytest.main(argv)
|
checks = (
|
||||||
black_ret = run_black()
|
lambda: pytest.main(argv),
|
||||||
return 0 if not black_ret and not pytest_ret else 1
|
run_black,
|
||||||
|
run_flake8,
|
||||||
|
)
|
||||||
|
return 0 if all(not c() for c in checks) else 1
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -100,3 +100,26 @@ wheel: <
|
|||||||
name: "infra/python/wheels/click-py3"
|
name: "infra/python/wheels/click-py3"
|
||||||
version: "version:8.0.3"
|
version: "version:8.0.3"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
wheel: <
|
||||||
|
name: "infra/python/wheels/flake8-py2_py3"
|
||||||
|
version: "version:6.0.0"
|
||||||
|
>
|
||||||
|
|
||||||
|
# Required by flake8==6.0.0
|
||||||
|
wheel: <
|
||||||
|
name: "infra/python/wheels/mccabe-py2_py3"
|
||||||
|
version: "version:0.7.0"
|
||||||
|
>
|
||||||
|
|
||||||
|
# Required by flake8==6.0.0
|
||||||
|
wheel: <
|
||||||
|
name: "infra/python/wheels/pyflakes-py2_py3"
|
||||||
|
version: "version:3.0.1"
|
||||||
|
>
|
||||||
|
|
||||||
|
# Required by flake8==6.0.0
|
||||||
|
wheel: <
|
||||||
|
name: "infra/python/wheels/pycodestyle-py2_py3"
|
||||||
|
version: "version:2.10.0"
|
||||||
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user