http-client-python Emitter 构建与测试
test-unbranded-emitter
构建并测试 @typespec/http-client-python emitter。当用户想要测试其对 emitter 的本地变更、运行生成器测试套件、检查其 http-client-python 变更是否通过,或验证某项修复时使用。触发短语包括“test the emitter”(测试 emitter)、“run tests”(运行测试)、“check if my changes pass”(检查我的变更是否通过)、“run test:generator”(运行 test:generator)、“run CI”(运行 CI),或在 emitter 包中提及任何测试/验证变更的表述。
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 5.9k
- Forks
- 423
01 前言 Front Matter
- name
- test-unbranded-emitter
- description
- Build and test the @typespec/http-client-python emitter. Use this skill whenever the user wants to test their local changes to the emitter, run the generator test suite, check if their http-client-python changes are passing, or validate a fix. Triggers on phrases like "test the emitter", "run tests", "check if my changes pass", "run test:generator", "run CI", or any mention of testing/validating changes in the emitter package.
03 SKILL.md 正文
Test Emitter Skill
Builds and tests @typespec/http-client-python to validate local changes.
Automatically regenerates if the generated code is stale.
Paths
All paths are relative to the http-client-python package root:
~/Desktop/github/typespec/packages/http-client-python
| Item | Path |
|---|---|
| Package root | ~/Desktop/github/typespec/packages/http-client-python |
| Emitter source | emitter/src |
| Generated (unbranded) | generator/test/unbranded/generated |
| Generated (azure) | generator/test/azure/generated |
| Regenerate marker | .last-regenerate |
Workflow
Step 1: Build the emitter
cd ~/Desktop/github/typespec/packages/http-client-python
npm run build
Check for TypeScript compilation errors. If the build fails, report the errors to the user and stop — do not proceed to testing.
Step 2: Check if regeneration is needed
Regeneration is needed if ANY of these conditions are true:
-
Generated folder doesn't exist or is empty:
cd ~/Desktop/github/typespec/packages/http-client-python if [ ! -d "generator/test/unbranded/generated" ] \ || [ -z "$(ls -A generator/test/unbranded/generated 2> /dev/null)" ]; then echo "Unbranded generated folder is empty - regeneration needed" fi if [ ! -d "generator/test/azure/generated" ] \ || [ -z "$(ls -A generator/test/azure/generated 2> /dev/null)" ]; then echo "Azure generated folder is empty - regeneration needed" fi -
No regenerate marker file exists:
if [ ! -f ".last-regenerate" ]; then echo "No regenerate marker - regeneration needed" fi -
Emitter source files are newer than the marker:
if [ -n "$(find emitter/src -newer .last-regenerate -type f 2> /dev/null | head -1)" ]; then echo "Emitter source changed since last regenerate - regeneration needed" fi
Step 3: Regenerate if needed
If any condition from Step 2 is true:
cd ~/Desktop/github/typespec/packages/http-client-python
echo "Regenerating test clients..."
npm run regenerate
After successful regeneration, update the marker:
touch .last-regenerate
If regeneration fails, report the error and stop.
If regeneration is NOT needed, inform the user:
"Generated code is up to date (source unchanged since last regeneration). Skipping regenerate."
Step 4: Run the generator test suite
cd ~/Desktop/github/typespec/packages/http-client-python
npm run ci
This runs:
test:emitter- vitest unit tests for the emitterci:generator- pytest tests against generated code
The full CI can take several minutes. Keep the user informed that it's running.
Step 5: Report results
- If tests pass: Confirm success and summarize any notable output (warnings, skipped tests, etc.)
- If tests fail: Show the failing test names and error messages clearly. Offer to help debug or investigate specific failures.
Integration with diff-upstream
Both skills share the regeneration marker system:
diff-upstreamalways regenerates and updates.last-regeneratetest-unbranded-emitterchecks this marker and skips regeneration if fresh
Efficient workflow:
diff-upstream → test-unbranded-emitter
The second command will skip regeneration since diff-upstream just did it.
Standalone workflow:
test-unbranded-emitter
Will regenerate only if source changed since last run.
Notes
Regeneration takes time
npm run regenerate can take 2-3 minutes. The staleness check avoids this delay
when the user is iterating on test fixes (not emitter changes).
Test types
| Command | What it runs | Duration |
|---|---|---|
npm run test:emitter |
vitest unit tests only | ~5 seconds |
npm run test:generator |
pytest only (no vitest) | ~2 minutes |
npm run ci |
vitest + pytest (full CI) | ~2-3 minutes |
This skill runs npm run ci (full CI). If the user wants just unit tests or
just pytest, they can ask specifically.
Known flaky test
The test server teardown sometimes fails with ProcessLookupError - this is a
pre-existing infrastructure issue, not a test failure. All actual tests may pass
even if you see this error at the end.
Force regeneration
If the user suspects stale generated code despite the marker, they can force regeneration:
rm ~/Desktop/github/typespec/packages/http-client-python/.last-regenerate
Then run the skill again.
Gitignore
Ensure this entry is in the package's .gitignore:
.last-regenerate
04 同仓库更多 Skills
TypeSpec 生成 Python SDK 代码
generate-from-typespec
使用本地 emitter 从 TypeSpec 规范生成 Python SDK 代码。当用户想要从 TypeSpec 规范生成或重新生成 Python 客户端,提供了 TypeSpec 项目的 GitHub URL 或本地路径,或说出类似“generate from this spec”(从此规范生成)、“emit Python from this tsp”(从此 tsp 生成 Python)、“regenerate the SDK”(重新生成 SDK)、“compile this TypeSpec for Python”(将此 TypeSpec 编译为 Python)等表述时使用。
Emitter 生成代码与上游基线对比
diff-upstream
重新生成本地 emitter,并将生成的代码与已检入 autorest.python 的上游基线进行对比。当用户想查看其 emitter 变更对生成代码的影响(相较于当前生产环境的差异),或说出类似“diff upstream”(与上游对比)、“compare to baseline”(与基线比较)、“what changed vs production”(相较生产环境有哪些变化)、“show me the diff”(给我看差异)、“how does this affect generated code”(这如何影响生成代码)等表述,或希望验证其变更能产生预期的输出差异时使用。
Python SDK Spector 模拟 API 测试编写
writing-python-sdk-spector-mock-api-tests
根据 Spector 用例编写 TypeSpec http-client-python generator 的模拟 API 测试(azure/unbranded/shared)。当给定 Spector 用例链接,或修改 http-specs/azure-http-specs 下 Spector 用例的 PR 链接时使用。
pnpm 代码格式化
pnpm-format
使用 pnpm 格式化代码库,并从常见的格式化失败中恢复。
TypeSpec Bug 最小复现构建
minimal-repro
帮助创建 TypeSpec 编译器或 emitter bug 的最小复现。当用户提供 TypeSpec 源码(粘贴的代码或 GitHub URL)并描述问题时使用。在本地复现并缩减为单文件复现。
http-client-python 依赖升级与发布
http-client-python-bump-and-release
创建 PR 以升级 TypeSpec/Azure Tools 依赖、更新 peer 依赖,或发布 http-client-python 包的新版本。