mirror of https://github.com/zulip/zulip.git
test-backend: Fix testing via shortcuts outside zerver/.
This commit is contained in:
parent
c56bd24715
commit
ac1f1e224b
|
@ -283,7 +283,7 @@ def main() -> None:
|
||||||
if options.processes is not None and options.processes < 1:
|
if options.processes is not None and options.processes < 1:
|
||||||
raise argparse.ArgumentTypeError("option processes: Only positive integers are allowed.")
|
raise argparse.ArgumentTypeError("option processes: Only positive integers are allowed.")
|
||||||
|
|
||||||
zerver_test_dir = "zerver/tests/"
|
test_dirs = ["zerver/tests/", "corporate/tests", "analytics/tests"]
|
||||||
|
|
||||||
# While running --rerun, we read var/last_test_failure.json to get
|
# While running --rerun, we read var/last_test_failure.json to get
|
||||||
# the list of tests that failed on the last run, and then pretend
|
# the list of tests that failed on the last run, and then pretend
|
||||||
|
@ -305,20 +305,21 @@ def main() -> None:
|
||||||
args[i] = suite.rstrip("/").replace("/", ".")
|
args[i] = suite.rstrip("/").replace("/", ".")
|
||||||
|
|
||||||
def rewrite_arguments(search_key: str) -> None:
|
def rewrite_arguments(search_key: str) -> None:
|
||||||
for root, dirs, files_names in os.walk(zerver_test_dir, topdown=False):
|
for test_dir in test_dirs:
|
||||||
for file_name in files_names:
|
for root, dirs, files_names in os.walk(test_dir, topdown=False):
|
||||||
# Check for files starting with alphanumeric characters and ending with '.py'
|
for file_name in files_names:
|
||||||
# Ignore backup files if any
|
# Check for files starting with alphanumeric characters and ending with '.py'
|
||||||
if not file_name[0].isalnum() or not file_name.endswith(".py"):
|
# Ignore backup files if any
|
||||||
continue
|
if not file_name[0].isalnum() or not file_name.endswith(".py"):
|
||||||
filepath = os.path.join(root, file_name)
|
continue
|
||||||
with open(filepath) as f:
|
filepath = os.path.join(root, file_name)
|
||||||
for line in f:
|
with open(filepath) as f:
|
||||||
if search_key not in line:
|
for line in f:
|
||||||
continue
|
if search_key not in line:
|
||||||
new_suite = filepath.replace(".py", ".") + suite
|
continue
|
||||||
args[i] = new_suite
|
new_suite = filepath.replace(".py", ".") + suite
|
||||||
return
|
args[i] = new_suite
|
||||||
|
return
|
||||||
|
|
||||||
for suite in args:
|
for suite in args:
|
||||||
if suite[0].isupper() and "test_" in suite:
|
if suite[0].isupper() and "test_" in suite:
|
||||||
|
@ -329,12 +330,13 @@ def main() -> None:
|
||||||
|
|
||||||
for i, suite in enumerate(args):
|
for i, suite in enumerate(args):
|
||||||
if suite.startswith("test"):
|
if suite.startswith("test"):
|
||||||
for root, dirs, files_names in os.walk(zerver_test_dir):
|
for test_dir in test_dirs:
|
||||||
for file_name in files_names:
|
for root, dirs, files_names in os.walk(test_dir):
|
||||||
if file_name in (suite, f"{suite}.py"):
|
for file_name in files_names:
|
||||||
new_suite = os.path.join(root, file_name)
|
if file_name in (suite, f"{suite}.py"):
|
||||||
args[i] = new_suite
|
new_suite = os.path.join(root, file_name)
|
||||||
break
|
args[i] = new_suite
|
||||||
|
break
|
||||||
|
|
||||||
for i, suite in enumerate(args):
|
for i, suite in enumerate(args):
|
||||||
args[i] = suite.replace(".py", "")
|
args[i] = suite.replace(".py", "")
|
||||||
|
|
Loading…
Reference in New Issue