From dba1a371b5223e2bdce2148f7b814cfceb3f7595 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 3 Dec 2026 06:08:04 +0800 Subject: [PATCH] refactor(ci): consolidate Python test phase dispatch (#16120) --- scripts/run-python-tests.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/scripts/run-python-tests.py b/scripts/run-python-tests.py index 61e61a46a6..a1d9df4a88 100644 --- a/scripts/run-python-tests.py +++ b/scripts/run-python-tests.py @@ -107,23 +107,17 @@ if not list(root.joinpath("tests/support/analysis-efficiency").glob("test_*.py") modules = [ ".".join(path.relative_to(root).with_suffix("").parts) for path in bridge_tests ] -if sys.argv[1:] == ["--bridge"]: - run_bridge(modules) +phases = { + "--bridge": lambda: run_bridge(modules), + "--analysis-efficiency": run_analysis_efficiency, +} +args = sys.argv[1:] +if len(args) == 1 and args[0] in phases: + phases[args[0]]() raise SystemExit(0) -if sys.argv[1:] == ["--analysis-efficiency"]: - run_analysis_efficiency() - raise SystemExit(0) -if sys.argv[1:]: +if args: fail("invalid_python_test_arguments") -bridge_result = subprocess.run( - [sys.executable, __file__, "--bridge"], cwd=root, check=False -) -if bridge_result.returncode: - sys.exit(bridge_result.returncode) -result = subprocess.run( - [sys.executable, __file__, "--analysis-efficiency"], - cwd=root, - check=False, -) -if result.returncode: - sys.exit(result.returncode) +for phase in phases: + result = subprocess.run([sys.executable, __file__, phase], cwd=root, check=False) + if result.returncode: + sys.exit(result.returncode)