From 37420dce0b704bd4975239d1d2465d21e9005c25 Mon Sep 17 00:00:00 2001 From: Liangsheng Yin Date: Tue, 24 Mar 2026 17:04:42 -0700 Subject: [PATCH] [CI] Enable failfast (`-f`) by default in `run_suite.py` (#21330) --- python/sglang/test/ci/ci_utils.py | 8 ++++---- test/README.md | 4 +++- test/registered/models/test_vlm_models.py | 21 +-------------------- test/registered/vlm/test_encoder_dp.py | 20 +------------------- 4 files changed, 9 insertions(+), 44 deletions(-) diff --git a/python/sglang/test/ci/ci_utils.py b/python/sglang/test/ci/ci_utils.py index a17498e06..ca6cf5162 100644 --- a/python/sglang/test/ci/ci_utils.py +++ b/python/sglang/test/ci/ci_utils.py @@ -160,10 +160,12 @@ def run_unittest_files( ) file_tic = time.perf_counter() + cmd = ["python3", full_path, "-f"] + if capture_output: # Capture output for retry decision process = subprocess.Popen( - ["python3", full_path], + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, @@ -175,9 +177,7 @@ def run_unittest_files( output_lines.append(line) process.wait() else: - process = subprocess.Popen( - ["python3", full_path], stdout=None, stderr=None - ) + process = subprocess.Popen(cmd, stdout=None, stderr=None) process.wait() elapsed = time.perf_counter() - file_tic diff --git a/test/README.md b/test/README.md index 017c39216..4b10a5eae 100644 --- a/test/README.md +++ b/test/README.md @@ -88,7 +88,9 @@ Here is an illustration Because the system uses a custom registry and the `run_suite.py` launcher, it supports both Python's built-in [unittest](https://docs.python.org/3/library/unittest.html) and the popular [pytest](https://docs.pytest.org/en/stable/) framework. The basic unit is a file, and you can use either framework in your file. -The launcher runs `python filename.py` to execute tests, so make sure your file includes the following lines. Otherwise, CI will not run it. +The launcher runs `python filename.py -f` to execute tests with **failfast enabled by default** — the first test method failure stops the file immediately. This avoids wasting CI time on remaining tests after a failure. + +Make sure your file ends with **exactly** one of the following blocks. Do not add custom `argparse` or modify `sys.argv` before calling `unittest.main()` / `pytest.main()` — the CI runner appends `-f` for failfast, and custom argument parsing will break it. ```python # for unittest diff --git a/test/registered/models/test_vlm_models.py b/test/registered/models/test_vlm_models.py index e03c56e8a..7789bed9d 100644 --- a/test/registered/models/test_vlm_models.py +++ b/test/registered/models/test_vlm_models.py @@ -1,6 +1,4 @@ -import argparse import random -import sys import tempfile import unittest from types import SimpleNamespace @@ -8,7 +6,6 @@ from types import SimpleNamespace from sglang.srt.utils import is_hip from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci from sglang.test.kits.mmmu_vlm_kit import ( - DEFAULT_MEM_FRACTION_STATIC, MMMUMultiModelTestBase, ) from sglang.test.test_utils import is_in_ci @@ -48,20 +45,4 @@ class TestVLMModels(MMMUMultiModelTestBase): if __name__ == "__main__": - # Define and parse arguments here, before unittest.main - parser = argparse.ArgumentParser(description="Test VLM models") - parser.add_argument( - "--mem-fraction-static", - type=float, - help="Static memory fraction for the model", - default=DEFAULT_MEM_FRACTION_STATIC, - ) - - # Parse args intended for unittest - args = parser.parse_args() - - # Store the parsed args object on the class - TestVLMModels.parsed_args = args - - # Pass args to unittest - unittest.main(argv=[sys.argv[0]]) + unittest.main() diff --git a/test/registered/vlm/test_encoder_dp.py b/test/registered/vlm/test_encoder_dp.py index 47adf11df..dd0f2669c 100644 --- a/test/registered/vlm/test_encoder_dp.py +++ b/test/registered/vlm/test_encoder_dp.py @@ -1,9 +1,7 @@ -import argparse import glob import json import os import random -import sys import unittest from types import SimpleNamespace @@ -255,20 +253,4 @@ class TestVLMEncoderDP(CustomTestCase): if __name__ == "__main__": - # Define and parse arguments here, before unittest.main - parser = argparse.ArgumentParser(description="Test VLM models") - parser.add_argument( - "--mem-fraction-static", - type=float, - help="Static memory fraction for the model", - default=DEFAULT_MEM_FRACTION_STATIC, - ) - - # Parse args intended for unittest - args = parser.parse_args() - - # Store the parsed args object on the class - TestVLMEncoderDP.parsed_args = args - - # Pass args to unittest - unittest.main(argv=[sys.argv[0]]) + unittest.main()