[CI] Enable failfast (-f) by default in run_suite.py (#21330)

This commit is contained in:
Liangsheng Yin
2026-03-24 17:04:42 -07:00
committed by GitHub
parent 3937a07b17
commit 37420dce0b
4 changed files with 9 additions and 44 deletions
+4 -4
View File
@@ -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
+3 -1
View File
@@ -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
+1 -20
View File
@@ -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()
+1 -19
View File
@@ -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()