Skip to content

[misc] CI hygiene: enforce __main__ entry, drop silent-skipped tests, fix rerun-test protoc#23305

Merged
hnyls2002 merged 7 commits intomainfrom
lsyin/fix-streaming-unit-test-silent
Apr 21, 2026
Merged

[misc] CI hygiene: enforce __main__ entry, drop silent-skipped tests, fix rerun-test protoc#23305
hnyls2002 merged 7 commits intomainfrom
lsyin/fix-streaming-unit-test-silent

Conversation

@hnyls2002
Copy link
Copy Markdown
Collaborator

@hnyls2002 hnyls2002 commented Apr 21, 2026

Misc CI hygiene bundle. Three independent changes:

1. Sanity check + streaming test fix

Pytest-style tests under test/registered/ have been silently skipping in CI: the CI runner invokes each file via python3 file.py -f (not pytest), so files without an executable if __name__ == "__main__": block just import and exit zero. Every test function body has never run.

  • Sanity check in collect_tests: every registered file with at least one enabled registry must have an executable __main__ block (AST-verified). Files with all registries disabled=... (helpers, self-skipping multi-GPU benches) are exempt.
  • Streaming session unit test fix (the immediate trigger): _FakeReq.finished_len = None (missing from fixture; real Req defaults to None) + proper __main__ entry. Also dropped a stale test (defers_tail_free) whose intent was already superseded by streaming session: trim spec v2 overshoot in cache_finished_req #22897.

Root cause (for context)

  • run_unittest_files -> subprocess.Popen(["python3", <file>, "-f"]) — assumes unittest.main() picks up -f as --failfast.
  • Pytest-style files with no unittest.main() / no __main__ block just import + exit 0. Zero tests executed, CI shows green.
  • Easy to land silently during review, especially when migrating tests across directories.

Kept files (6): __main__ fix applied, tests now actually run

  • test/registered/unit/mem_cache/test_streaming_session_unit.py — PR's immediate target (4 tests)
  • test/registered/debug_utils/comparator/test_preset.py
  • test/registered/debug_utils/source_patcher/test_code_patcher.py
  • test/registered/debug_utils/source_patcher/test_dumper_integration.py
  • test/registered/debug_utils/source_patcher/test_source_editor.py
  • test/registered/debug_utils/test_dump_comparator.pyalso dropped TestMainBasic subset: those 3 integration tests call dump_comparator.main() which hard-codes x.cuda() in _load_tensor, so they always raise no NVIDIA driver on the CPU suite they were registered in. Kept the 6 pure-CPU unit tests in the file. cc @fzyzcjy (originally added in Tiny fix single-gpu dumper and add tests for dumper #16285)

Dropped files (9)

If any original author wants a file revived: reopen with a proper __main__ block (see the pattern in test_streaming_session_unit.py at the bottom) so the file actually executes in CI.

2. Fix rerun-test.yml CPU job missing protoc / rustup

rerun-test-cpu (.github/workflows/rerun-test.yml) was runs-on: ubuntu-latest but missing the Install protoc + Install Rust toolchain steps that pr-test.yml's stage-a-test-cpu has (at pr-test.yml:646-652). Installing sglang editable wheel compiles sglang-grpc Rust crate, whose build.rs needs protoc -> workflow fails in Install dependencies before pytest even starts.

Fix: mirror pr-test.yml's setup — add the same two steps. Keeps rerun-test environment aligned with pr-test rather than forking into a docker-container approach.

Test plan

  • collect_tests(sanity_check=True) passes over all 710 registered files
  • scripts/ci/check_registered_tests.py returns 0 (pre-commit hook stays green)
  • Each previously-silent file: syntax-check + pytest AST-parse OK
  • CI green on the 6 kept files (dispatched via /rerun-test)

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@hnyls2002
Copy link
Copy Markdown
Collaborator Author

hnyls2002 commented Apr 21, 2026

/rerun-test test_streaming_session_unit.py test_preset.py test_code_patcher.py test_dumper_integration.py test_source_editor.py test_dump_comparator.py
(5 tries)

@github-actions
Copy link
Copy Markdown
Contributor

ubuntu-latest (6 tests): View workflow run

cd test/ && python3 registered/unit/mem_cache/test_streaming_session_unit.py
cd test/ && python3 registered/debug_utils/comparator/test_preset.py
cd test/ && python3 registered/debug_utils/source_patcher/test_code_patcher.py
cd test/ && python3 registered/debug_utils/source_patcher/test_dumper_integration.py
cd test/ && python3 registered/debug_utils/source_patcher/test_source_editor.py
cd test/ && python3 registered/debug_utils/test_dump_comparator.py

1-gpu-h100 (1 test): View workflow run

cd test/ && python3 registered/vlm/test_patch_embed_perf.py

@github-actions
Copy link
Copy Markdown
Contributor

ubuntu-latest (6 tests): View workflow run

cd test/ && python3 registered/unit/mem_cache/test_streaming_session_unit.py
cd test/ && python3 registered/debug_utils/comparator/test_preset.py
cd test/ && python3 registered/debug_utils/source_patcher/test_code_patcher.py
cd test/ && python3 registered/debug_utils/source_patcher/test_dumper_integration.py
cd test/ && python3 registered/debug_utils/source_patcher/test_source_editor.py
cd test/ && python3 registered/debug_utils/test_dump_comparator.py

1-gpu-h100 (1 test): View workflow run

cd test/ && python3 registered/vlm/test_patch_embed_perf.py

@hnyls2002 hnyls2002 changed the title fix silently-skipped pytest tests; enforce __main__ entry in ci sanity check [misc] CI hygiene: enforce __main__ entry, drop silent-skipped tests, fix rerun-test protoc Apr 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

ubuntu-latest (6 tests): View workflow run

cd test/ && python3 registered/unit/mem_cache/test_streaming_session_unit.py
cd test/ && python3 registered/debug_utils/comparator/test_preset.py
cd test/ && python3 registered/debug_utils/source_patcher/test_code_patcher.py
cd test/ && python3 registered/debug_utils/source_patcher/test_dumper_integration.py
cd test/ && python3 registered/debug_utils/source_patcher/test_source_editor.py
cd test/ && python3 registered/debug_utils/test_dump_comparator.py

1-gpu-h100 (1 test): View workflow run

cd test/ && python3 registered/vlm/test_patch_embed_perf.py

@github-actions
Copy link
Copy Markdown
Contributor

ubuntu-latest (6 tests): View workflow run

cd test/ && python3 registered/unit/mem_cache/test_streaming_session_unit.py
cd test/ && python3 registered/debug_utils/comparator/test_preset.py
cd test/ && python3 registered/debug_utils/source_patcher/test_code_patcher.py
cd test/ && python3 registered/debug_utils/source_patcher/test_dumper_integration.py
cd test/ && python3 registered/debug_utils/source_patcher/test_source_editor.py
cd test/ && python3 registered/debug_utils/test_dump_comparator.py

1-gpu-h100 (1 test): View workflow run

cd test/ && python3 registered/vlm/test_patch_embed_perf.py

@github-actions
Copy link
Copy Markdown
Contributor

ubuntu-latest (6 tests): View workflow run

cd test/ && python3 registered/unit/mem_cache/test_streaming_session_unit.py
cd test/ && python3 registered/debug_utils/comparator/test_preset.py
cd test/ && python3 registered/debug_utils/source_patcher/test_code_patcher.py
cd test/ && python3 registered/debug_utils/source_patcher/test_dumper_integration.py
cd test/ && python3 registered/debug_utils/source_patcher/test_source_editor.py
cd test/ && python3 registered/debug_utils/test_dump_comparator.py

@hnyls2002
Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@hnyls2002 hnyls2002 merged commit 6cc2eee into main Apr 21, 2026
29 of 68 checks passed
@hnyls2002 hnyls2002 deleted the lsyin/fix-streaming-unit-test-silent branch April 21, 2026 04:16
@fxmarty-amd
Copy link
Copy Markdown
Contributor

Why are the tests removed? Does it not mean that some part of sglang codebase still exist, but are simply untested?

The intent was definitely not to have tests skipped by default when adding tests to tests/ folder.

bingxche added a commit that referenced this pull request Apr 22, 2026
Re-add the int4fp8_moe quantization accuracy test (Mixtral-8x7B, GSM8K)
that was removed in #23305. The original file (from #17116 / #7392) was
missing an `if __name__ == "__main__": unittest.main()` block, causing
it to silently skip in CI. This commit restores the test with a proper
`__main__` entry.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
@bingxche
Copy link
Copy Markdown
Collaborator

Why are the tests removed? Does it not mean that some part of sglang codebase still exist, but are simply untested?

The intent was definitely not to have tests skipped by default when adding tests to tests/ folder.

Hi @fxmarty-amd , in this PR #23305 your test file will be restored and properly registered.

zhangying098 pushed a commit to zhangying098/sglang that referenced this pull request Apr 23, 2026
kyx1999 pushed a commit to KMSorSMS/sglang that referenced this pull request Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants