mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-04-20 14:09:30 +00:00
run_tests: fix running when cwd is not the root
If you try running this from a subdir, then most of the tests fail because they assume they're running from the top of the source tree. Change all the tests to actually run there. For example: cd docs && ../run_tests Change-Id: I92e17476393a108e56b58e049193b9fd72c5b7ba Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/464841 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
85ee1738e6
commit
3667de1d0f
18
run_tests
18
run_tests
@ -21,8 +21,6 @@ import subprocess
|
||||
import sys
|
||||
from typing import List
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
@ -38,7 +36,11 @@ def run_pytest(argv: List[str]) -> int:
|
||||
if is_ci():
|
||||
argv = ["-m", "not skip_cq"] + argv
|
||||
|
||||
return pytest.main(argv)
|
||||
return subprocess.run(
|
||||
[sys.executable, "-m", "pytest"] + argv,
|
||||
check=False,
|
||||
cwd=ROOT_DIR,
|
||||
).returncode
|
||||
|
||||
|
||||
def run_pytest_py38(argv: List[str]) -> int:
|
||||
@ -57,6 +59,7 @@ def run_pytest_py38(argv: List[str]) -> int:
|
||||
]
|
||||
+ argv,
|
||||
check=False,
|
||||
cwd=ROOT_DIR,
|
||||
).returncode
|
||||
except FileNotFoundError:
|
||||
# Skip if the user doesn't have vpython from depot_tools.
|
||||
@ -76,20 +79,25 @@ def run_black():
|
||||
return subprocess.run(
|
||||
[sys.executable, "-m", "black", "--check", ROOT_DIR] + extra_programs,
|
||||
check=False,
|
||||
cwd=ROOT_DIR,
|
||||
).returncode
|
||||
|
||||
|
||||
def run_flake8():
|
||||
"""Returns the exit code from flake8."""
|
||||
return subprocess.run(
|
||||
[sys.executable, "-m", "flake8", ROOT_DIR], check=False
|
||||
[sys.executable, "-m", "flake8", ROOT_DIR],
|
||||
check=False,
|
||||
cwd=ROOT_DIR,
|
||||
).returncode
|
||||
|
||||
|
||||
def run_isort():
|
||||
"""Returns the exit code from isort."""
|
||||
return subprocess.run(
|
||||
[sys.executable, "-m", "isort", "--check", ROOT_DIR], check=False
|
||||
[sys.executable, "-m", "isort", "--check", ROOT_DIR],
|
||||
check=False,
|
||||
cwd=ROOT_DIR,
|
||||
).returncode
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user