test: add category selection flags#1701
Conversation
|
| case 'tts': | ||
| includes.add('agents/src/tts/**/*.test.ts'); | ||
| includes.add('agents/src/inference/tts.test.ts'); | ||
| includes.add(`plugins/${provider}/src/**/tts*.test.ts`); |
There was a problem hiding this comment.
🟡 TTS glob pattern tts*.test.ts misses gemini_tts.test.ts
The glob pattern plugins/${provider}/src/**/tts*.test.ts at vitest.config.ts:32 requires filenames to start with tts, but plugins/google/src/beta/gemini_tts.test.ts starts with gemini_. Running pnpm test -- --tts or pnpm test -- --tts google silently skips Google's Gemini TTS test. The same issue exists in scripts/vitest.js:73 where categoriesFor checks normalized.includes('/tts') — this matches paths containing /tts as a path segment (like /tts.test.ts) but misses _tts in filenames like gemini_tts.test.ts, so --list-categories also won't show this file under the tts category.
Prompt for agents
The glob pattern `tts*.test.ts` in vitest.config.ts:32 (and similarly `stt*.test.ts` in line 27 which could face the same issue in the future) uses a prefix match, but some TTS test files like `plugins/google/src/beta/gemini_tts.test.ts` use a different naming convention with a prefix before `tts`. Two places need fixing:
1. In vitest.config.ts, the `tts` case (line 32): change `tts*.test.ts` to `*tts*.test.ts` (or `*tts{,_*}.test.ts` to be more targeted). Similarly consider changing `stt*.test.ts` to `*stt*.test.ts` in line 27 for forward compatibility.
2. In scripts/vitest.js, the `categoriesFor` function (line 73): the check `normalized.includes('/tts')` misses files like `gemini_tts.test.ts` because the `/tts` substring isn't in the path (it appears as `_tts`). Consider changing to check for `tts` in the filename itself, e.g. using a regex that matches the basename containing `tts`.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
This seems like python-specific one |
TL;DR: Add explicit source of truth for tests categorization and unified selection
Select and run tests as
Categorize new test modules via
Motivation
Currently there is no clear indication of which tests to run where and how.
./makefilehas a manually maintained list of unit-tests modules to run: all new modules must be added in order to be tested in CI, but nothing keeps this in check. This leads to stale/ignored testsPlain
pytest ./testsdoesn't work on most environment, even with-kselection, as the collection will fail due to missing dependencies.This PR fixes both problems by defining single source of truth and mechanism for tests isolation.
Changes
pytestmark = pytest.mark.<category>to existing modulespytest --<category>flags that runs tests of that category (with dependencies isolation)pytest --list-categoriesarg that lists all modules and their categories--allow-uncategorized)test_audio_recognition_aclose.pyandtest_speaker_id_grouping.pytest_cli_log_level.pyCategories and dependencies:
--unit--plugin [name]--stt/--tts--realtime--evals--docsdocsdependency groupNotes
Stale tests ignored in CI before this PR
test_audio_emitter.pytest_audio_recognition_aclose.pytest_cli_log_level.pytest_drain_timeout.pytest_interruption/test_interruption_failover.pytest_nested_agent_task.pytest_speaker_id_grouping.pytest_speech_start_time_persistence.pytest_stt_base.pytest_user_turn_exceeded.pypytest --list-categoriesoutputNew
### Testingsection in AGENTS.md (authored by Claude)Testing
Test categories
Every test module declares exactly one category via a module-level marker, and
each category has a matching
--<category>selection flag. Selection happensbefore import, so a category run never imports (or fails on) modules outside
it.
pytest.mark.unit--unitpytest.mark.plugin("name")--plugin [name]pytest.mark.stt--stttests/test_stt.py)pytest.mark.tts--ttstests/test_tts.py)pytest.mark.realtime("name")--realtime [name]pytest.mark.evals--evalspytest.mark.docs--docs.github/Adding a test: give the new module a category marker (
pytestmark = pytest.mark.unit, etc.) — collection fails with a hint if it lacks one. Runpytest with the
--allow-uncategorizedoption to temporarily disable this rule(CI keeps it on by default).
2 STT failures seem to be unrelated to the changes.