servediff 0.4.2__tar.gz → 0.4.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {servediff-0.4.2 → servediff-0.4.4}/CHANGELOG.md +19 -0
  2. {servediff-0.4.2 → servediff-0.4.4}/PKG-INFO +22 -2
  3. {servediff-0.4.2 → servediff-0.4.4}/README.md +21 -1
  4. {servediff-0.4.2 → servediff-0.4.4}/README.zh-CN.md +19 -1
  5. {servediff-0.4.2 → servediff-0.4.4}/pyproject.toml +1 -1
  6. {servediff-0.4.2 → servediff-0.4.4}/src/servediff/cli.py +40 -8
  7. {servediff-0.4.2 → servediff-0.4.4}/src/servediff.egg-info/PKG-INFO +22 -2
  8. {servediff-0.4.2 → servediff-0.4.4}/tests/test_cli.py +46 -0
  9. {servediff-0.4.2 → servediff-0.4.4}/CONTRIBUTING.md +0 -0
  10. {servediff-0.4.2 → servediff-0.4.4}/LICENSE +0 -0
  11. {servediff-0.4.2 → servediff-0.4.4}/MANIFEST.in +0 -0
  12. {servediff-0.4.2 → servediff-0.4.4}/examples/issue-excerpts/vllm-47047-v0.23-default.log +0 -0
  13. {servediff-0.4.2 → servediff-0.4.4}/examples/issue-excerpts/vllm-47047-v0.23-marlin.log +0 -0
  14. {servediff-0.4.2 → servediff-0.4.4}/examples/issue-excerpts/vllm-53472-v0.23.log +0 -0
  15. {servediff-0.4.2 → servediff-0.4.4}/examples/issue-excerpts/vllm-53472-v0.26-flag.log +0 -0
  16. {servediff-0.4.2 → servediff-0.4.4}/examples/issue-excerpts/vllm-53472-v0.26.log +0 -0
  17. {servediff-0.4.2 → servediff-0.4.4}/setup.cfg +0 -0
  18. {servediff-0.4.2 → servediff-0.4.4}/src/servediff/__init__.py +0 -0
  19. {servediff-0.4.2 → servediff-0.4.4}/src/servediff/__main__.py +0 -0
  20. {servediff-0.4.2 → servediff-0.4.4}/src/servediff/env.py +0 -0
  21. {servediff-0.4.2 → servediff-0.4.4}/src/servediff.egg-info/SOURCES.txt +0 -0
  22. {servediff-0.4.2 → servediff-0.4.4}/src/servediff.egg-info/dependency_links.txt +0 -0
  23. {servediff-0.4.2 → servediff-0.4.4}/src/servediff.egg-info/entry_points.txt +0 -0
  24. {servediff-0.4.2 → servediff-0.4.4}/src/servediff.egg-info/requires.txt +0 -0
  25. {servediff-0.4.2 → servediff-0.4.4}/src/servediff.egg-info/top_level.txt +0 -0
  26. {servediff-0.4.2 → servediff-0.4.4}/tests/fixtures/README.md +0 -0
  27. {servediff-0.4.2 → servediff-0.4.4}/tests/fixtures/sglang-0.4.4-tp4.log +0 -0
  28. {servediff-0.4.2 → servediff-0.4.4}/tests/fixtures/vllm-0.23.1-tp8-allreduce.log +0 -0
  29. {servediff-0.4.2 → servediff-0.4.4}/tests/fixtures/vllm-0.29-tp4-ep-h200-allreduce.log +0 -0
  30. {servediff-0.4.2 → servediff-0.4.4}/tests/fixtures/vllm-47047-v0.23-default.log +0 -0
  31. {servediff-0.4.2 → servediff-0.4.4}/tests/fixtures/vllm-47047-v0.23-marlin.log +0 -0
  32. {servediff-0.4.2 → servediff-0.4.4}/tests/fixtures/vllm-53472-v0.23.log +0 -0
  33. {servediff-0.4.2 → servediff-0.4.4}/tests/fixtures/vllm-53472-v0.26-flag.log +0 -0
  34. {servediff-0.4.2 → servediff-0.4.4}/tests/fixtures/vllm-53472-v0.26.log +0 -0
  35. {servediff-0.4.2 → servediff-0.4.4}/tests/test_env.py +0 -0
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.4 — 2026-11-07
4
+
5
+ - `capture` survives Ctrl-C. That is how a server run actually ends: interrupt it once the
6
+ startup lines are printed. It used to leave a traceback and exit 1, which this tool
7
+ reserves for "the inputs differ"; it now stops the child, keeps the log, says where it
8
+ is, and exits 130. The server's own exit code is still passed through on a normal exit.
9
+ - README documents `capture` as the way to produce both logs, since most people arrive
10
+ with one log and a question rather than two ready files.
11
+
12
+ ## 0.4.3 — 2026-11-07
13
+
14
+ - `capture` now snapshots the interpreter the command itself names. `capture -- python -m
15
+ vllm...` used to snapshot the interpreter servediff runs on, which is a different venv
16
+ often enough that a later snapshot diff compared two copies of servediff and reported
17
+ no difference — the failure mode this tool exists to name. When the command does not
18
+ name a python launcher, the snapshot line now says which interpreter it describes and
19
+ points at `--python`.
20
+ - The snapshot line prints the interpreter path it used, so the JSON and the log agree.
21
+
3
22
  ## 0.4.2 — 2026-11-07
4
23
 
5
24
  - An unreadable path (`servediff show typo.log`, `diff` with a missing side) no longer
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: servediff
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Diff what your vLLM / SGLang server actually ran with: auto-selected backends, CUDA graphs, startup failures, dependency versions.
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Homepage, https://github.com/apex-mochen/servediff
@@ -66,6 +66,26 @@ The two `note:` lines are part of the answer, not noise: the excerpt posted in t
66
66
  issue carries no rank line, so this run cannot say whether it was multi-GPU at all,
67
67
  and the tool says so instead of leaving you to read silence as "unchanged".
68
68
 
69
+ ## Recording your own two logs
70
+
71
+ Most people meet this with one log and a question, not two ready files. `capture` runs the
72
+ server, tees its output, and snapshots the environment *before* launch, so the next run is
73
+ directly comparable:
74
+
75
+ ```bash
76
+ # before the upgrade, with the flags you actually use
77
+ servediff capture -o before.log -- python -m vllm.entrypoints.openai.api_server --model <model> ...
78
+ # Ctrl-C once the server is up: the startup lines are already in before.log
79
+ servediff capture -o after.log -- <the same command>
80
+ servediff diff before.log after.log # what the server did differently
81
+ servediff diff before.log.env.json after.log.env.json # package, GPU and engine env drift
82
+ ```
83
+
84
+ Ctrl-C stops the server, keeps the log, and exits `130`. A run that ends on its own passes the
85
+ server's exit code through, so `capture` is safe inside a script that checks it. If the command
86
+ names a python launcher, that interpreter is the one snapshotted; for entry points like
87
+ `vllm serve`, pass `--python <the server's python>`.
88
+
69
89
  ## Commands and exit codes
70
90
 
71
91
  | Command | What it reads | Exit codes |
@@ -74,7 +94,7 @@ and the tool says so instead of leaving you to read silence as "unchanged".
74
94
  | `servediff diff <a> <b>` | two startup logs, or two `servediff env` snapshots; `--json`, `--markdown`, `--all`, `--raw-args` | `0` identical; `1` at least one difference; `2` usage error, unreadable path, or one log mixed with one snapshot |
75
95
  | `servediff series <a> <b> <c> ...` | three or more startup logs, in the column order you give → one fact per row; `--json`, `--markdown`, `--all`, `--raw-args` | `0` same across every log; `1` at least one fact differs; `2` fewer than three inputs |
76
96
  | `servediff env [--python P] [-o snap.json]` | that interpreter's packages, GPU info, and env vars whose names start with `VLLM_` / `SGLANG_` / `SGL_` / `CUDA_` / `NCCL_` / `TORCH_` / `PYTORCH_` / `FLASHINFER_` / `TRITON_` or are `HF_HUB_OFFLINE` / `TRANSFORMERS_OFFLINE`; secret-looking names become `<redacted>` | `0` written; `2` snapshot failed |
77
- | `servediff capture [-o run.log] -- <server command>` | runs the server, tees its log, and writes `<out>.env.json` **before** launch | the server's own exit code |
97
+ | `servediff capture [-o run.log] -- <server command>` | runs the server, tees its log to stdout and to the file, and writes `<out>.env.json` **before** launch. If the command names a python launcher (`capture -- python -m vllm...`), that interpreter is the one snapshotted; otherwise pass `--python` to point at the server's venv | the server's own exit code |
78
98
 
79
99
  `1` always means *the inputs differ* — never *something went wrong* — so
80
100
  `servediff diff old.log new.log` works directly as a CI gate. At most one input may be
@@ -45,6 +45,26 @@ The two `note:` lines are part of the answer, not noise: the excerpt posted in t
45
45
  issue carries no rank line, so this run cannot say whether it was multi-GPU at all,
46
46
  and the tool says so instead of leaving you to read silence as "unchanged".
47
47
 
48
+ ## Recording your own two logs
49
+
50
+ Most people meet this with one log and a question, not two ready files. `capture` runs the
51
+ server, tees its output, and snapshots the environment *before* launch, so the next run is
52
+ directly comparable:
53
+
54
+ ```bash
55
+ # before the upgrade, with the flags you actually use
56
+ servediff capture -o before.log -- python -m vllm.entrypoints.openai.api_server --model <model> ...
57
+ # Ctrl-C once the server is up: the startup lines are already in before.log
58
+ servediff capture -o after.log -- <the same command>
59
+ servediff diff before.log after.log # what the server did differently
60
+ servediff diff before.log.env.json after.log.env.json # package, GPU and engine env drift
61
+ ```
62
+
63
+ Ctrl-C stops the server, keeps the log, and exits `130`. A run that ends on its own passes the
64
+ server's exit code through, so `capture` is safe inside a script that checks it. If the command
65
+ names a python launcher, that interpreter is the one snapshotted; for entry points like
66
+ `vllm serve`, pass `--python <the server's python>`.
67
+
48
68
  ## Commands and exit codes
49
69
 
50
70
  | Command | What it reads | Exit codes |
@@ -53,7 +73,7 @@ and the tool says so instead of leaving you to read silence as "unchanged".
53
73
  | `servediff diff <a> <b>` | two startup logs, or two `servediff env` snapshots; `--json`, `--markdown`, `--all`, `--raw-args` | `0` identical; `1` at least one difference; `2` usage error, unreadable path, or one log mixed with one snapshot |
54
74
  | `servediff series <a> <b> <c> ...` | three or more startup logs, in the column order you give → one fact per row; `--json`, `--markdown`, `--all`, `--raw-args` | `0` same across every log; `1` at least one fact differs; `2` fewer than three inputs |
55
75
  | `servediff env [--python P] [-o snap.json]` | that interpreter's packages, GPU info, and env vars whose names start with `VLLM_` / `SGLANG_` / `SGL_` / `CUDA_` / `NCCL_` / `TORCH_` / `PYTORCH_` / `FLASHINFER_` / `TRITON_` or are `HF_HUB_OFFLINE` / `TRANSFORMERS_OFFLINE`; secret-looking names become `<redacted>` | `0` written; `2` snapshot failed |
56
- | `servediff capture [-o run.log] -- <server command>` | runs the server, tees its log, and writes `<out>.env.json` **before** launch | the server's own exit code |
76
+ | `servediff capture [-o run.log] -- <server command>` | runs the server, tees its log to stdout and to the file, and writes `<out>.env.json` **before** launch. If the command names a python launcher (`capture -- python -m vllm...`), that interpreter is the one snapshotted; otherwise pass `--python` to point at the server's venv | the server's own exit code |
57
77
 
58
78
  `1` always means *the inputs differ* — never *something went wrong* — so
59
79
  `servediff diff old.log new.log` works directly as a CI gate. At most one input may be
@@ -22,6 +22,24 @@ servediff diff examples/issue-excerpts/vllm-47047-v0.23-default.log examples/iss
22
22
 
23
23
  从 PyPI 安装(`pip install servediff`)。另有一个同名但无关的工具放在第三方 Homebrew tap 里,`pip` 装到的这个才是本项目。
24
24
 
25
+ ## 采自己的两份日志
26
+
27
+ 多数人手里只有一份日志和一个疑问,而不是现成的两个文件。`capture` 会跑起 server、把输出同时
28
+ 转存,并在启动**之前**拍下环境快照,于是下一次运行天然可对比:
29
+
30
+ ```bash
31
+ # 升级前,用你实际在用的参数
32
+ servediff capture -o before.log -- python -m vllm.entrypoints.openai.api_server --model <model> ...
33
+ # server 起来之后按 Ctrl-C:启动阶段的日志已经写进 before.log 了
34
+ servediff capture -o after.log -- <同一条命令>
35
+ servediff diff before.log after.log # server 到底哪里不一样
36
+ servediff diff before.log.env.json after.log.env.json # 包、GPU 与环境变量漂移
37
+ ```
38
+
39
+ Ctrl-C 会停掉 server、保留日志、退出码 `130`;server 自己结束时则透传它的退出码,所以放在
40
+ 检查退出码的脚本里是安全的。命令里带 python 启动器时,快照的就是那个解释器;像 `vllm serve`
41
+ 这种入口脚本,用 `--python <server 的 python>` 指明。
42
+
25
43
  ## 子命令与退出码
26
44
 
27
45
  | 子命令 | 读什么 | 退出码 |
@@ -30,7 +48,7 @@ servediff diff examples/issue-excerpts/vllm-47047-v0.23-default.log examples/iss
30
48
  | `servediff diff <a> <b>` | 两份启动日志,或两份 `servediff env` 快照;`--json` / `--markdown` / `--all` / `--raw-args` | `0` 一致;`1` 至少有一处不同;`2` 用法错误、路径读不了,或一份日志配一份快照 |
31
49
  | `servediff series <a> <b> <c> ...` | 三份及以上日志,按你给的顺序排列成列,每条 fact 一行;`--json` / `--markdown` / `--all` / `--raw-args` | `0` 各份全同;`1` 有 fact 不同;`2` 少于三份 |
32
50
  | `servediff env [--python P] [-o snap.json]` | 该解释器的包、GPU 信息,以及名字以 `VLLM_` / `SGLANG_` / `SGL_` / `CUDA_` / `NCCL_` / `TORCH_` / `PYTORCH_` / `FLASHINFER_` / `TRITON_` 开头的环境变量和 `HF_HUB_OFFLINE` / `TRANSFORMERS_OFFLINE`;看起来像密钥的名字一律写成 `<redacted>` | `0` 已写出;`2` 快照失败 |
33
- | `servediff capture [-o run.log] -- <启动命令>` | 跑起 server、把日志同时写文件,并在启动**之前**写出 `<out>.env.json` | server 自己的退出码 |
51
+ | `servediff capture [-o run.log] -- <启动命令>` | 跑起 server、把日志同时输出到终端和文件,并在启动**之前**写出 `<out>.env.json`。命令里自带 python 启动器时(`capture -- python -m vllm...`),快照的就是那个解释器;否则用 `--python` 指到 server 所在的环境 | server 自己的退出码 |
34
52
 
35
53
  `1` 只表示「输入不同」,不表示「出错」,所以 `servediff diff old.log new.log` 可以直接当 CI 门禁。`-` 至多出现一次:stdin 只能读一遍。
36
54
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "servediff"
7
- version = "0.4.2"
7
+ version = "0.4.4"
8
8
  description = "Diff what your vLLM / SGLang server actually ran with: auto-selected backends, CUDA graphs, startup failures, dependency versions."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -532,15 +532,28 @@ def main(argv=None) -> int:
532
532
  file=sys.stderr)
533
533
  return 2
534
534
  # Snapshot the environment before the server starts, so we capture what it launched with.
535
+ # When the command itself names a Python launcher (`capture -- python -m vllm...`), that
536
+ # launcher *is* the server's environment; snapshotting our own would describe the wrong
537
+ # venv and make a later snapshot diff compare two copies of servediff.
538
+ snapshot_python = args.python
539
+ if snapshot_python is None and cmd:
540
+ launcher = Path(cmd[0]).name.lower()
541
+ if re.fullmatch(r"python(\d+(\.\d+)*)?((\.exe)?)", launcher):
542
+ snapshot_python = cmd[0]
535
543
  try:
536
- snap = envsnap.snapshot(args.python)
544
+ snap = envsnap.snapshot(snapshot_python)
537
545
  except (RuntimeError, OSError) as exc:
538
546
  print(f"servediff capture: env snapshot failed: {exc}", file=sys.stderr)
539
547
  return 2
540
548
  snap_path = args.output.with_suffix(args.output.suffix + ".env.json")
541
549
  snap_path.write_text(json.dumps(snap, indent=2, ensure_ascii=False, sort_keys=True) + "\n",
542
550
  encoding="utf-8")
543
- print(f"env snapshot -> {snap_path}", file=sys.stderr)
551
+ print(f"env snapshot -> {snap_path} (interpreter: {snap.get('executable') or snapshot_python})",
552
+ file=sys.stderr)
553
+ if snapshot_python is None:
554
+ print(" note: the command does not name a python launcher, so this snapshot describes"
555
+ " the interpreter servediff runs on; pass --python <the server's python> if the"
556
+ " server lives in another venv", file=sys.stderr)
544
557
  print(f"log -> {args.output} (running: {' '.join(shlex.quote(p) for p in cmd)})", file=sys.stderr)
545
558
  try:
546
559
  proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,
@@ -549,12 +562,31 @@ def main(argv=None) -> int:
549
562
  print(f"capture: cannot start {cmd[0]}: {exc}", file=sys.stderr)
550
563
  return 2
551
564
  with open(args.output, "w", encoding="utf-8", errors="replace") as logf:
552
- for line in proc.stdout:
553
- logf.write(line)
554
- logf.flush()
555
- sys.stdout.write(line)
556
- sys.stdout.flush()
557
- proc.wait()
565
+ interrupted = False
566
+ try:
567
+ for line in proc.stdout:
568
+ logf.write(line)
569
+ logf.flush()
570
+ sys.stdout.write(line)
571
+ sys.stdout.flush()
572
+ except KeyboardInterrupt:
573
+ # Ctrl-C is how a server run ends in practice. Without this it bubbled
574
+ # out as a traceback with exit 1, which reads as "the inputs differ".
575
+ interrupted = True
576
+ finally:
577
+ if proc.poll() is None:
578
+ proc.terminate()
579
+ try:
580
+ proc.wait(timeout=5)
581
+ except subprocess.TimeoutExpired:
582
+ proc.kill()
583
+ proc.wait()
584
+ if not interrupted:
585
+ proc.wait()
586
+ else:
587
+ print(f"\ninterrupted; server stopped, log kept: {args.output}"
588
+ f" (startup lines printed before the interruption are still in it)", file=sys.stderr)
589
+ return 130
558
590
  print(f"\nserver exited with code {proc.returncode}; log: {args.output}", file=sys.stderr)
559
591
  return proc.returncode
560
592
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: servediff
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Diff what your vLLM / SGLang server actually ran with: auto-selected backends, CUDA graphs, startup failures, dependency versions.
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Homepage, https://github.com/apex-mochen/servediff
@@ -66,6 +66,26 @@ The two `note:` lines are part of the answer, not noise: the excerpt posted in t
66
66
  issue carries no rank line, so this run cannot say whether it was multi-GPU at all,
67
67
  and the tool says so instead of leaving you to read silence as "unchanged".
68
68
 
69
+ ## Recording your own two logs
70
+
71
+ Most people meet this with one log and a question, not two ready files. `capture` runs the
72
+ server, tees its output, and snapshots the environment *before* launch, so the next run is
73
+ directly comparable:
74
+
75
+ ```bash
76
+ # before the upgrade, with the flags you actually use
77
+ servediff capture -o before.log -- python -m vllm.entrypoints.openai.api_server --model <model> ...
78
+ # Ctrl-C once the server is up: the startup lines are already in before.log
79
+ servediff capture -o after.log -- <the same command>
80
+ servediff diff before.log after.log # what the server did differently
81
+ servediff diff before.log.env.json after.log.env.json # package, GPU and engine env drift
82
+ ```
83
+
84
+ Ctrl-C stops the server, keeps the log, and exits `130`. A run that ends on its own passes the
85
+ server's exit code through, so `capture` is safe inside a script that checks it. If the command
86
+ names a python launcher, that interpreter is the one snapshotted; for entry points like
87
+ `vllm serve`, pass `--python <the server's python>`.
88
+
69
89
  ## Commands and exit codes
70
90
 
71
91
  | Command | What it reads | Exit codes |
@@ -74,7 +94,7 @@ and the tool says so instead of leaving you to read silence as "unchanged".
74
94
  | `servediff diff <a> <b>` | two startup logs, or two `servediff env` snapshots; `--json`, `--markdown`, `--all`, `--raw-args` | `0` identical; `1` at least one difference; `2` usage error, unreadable path, or one log mixed with one snapshot |
75
95
  | `servediff series <a> <b> <c> ...` | three or more startup logs, in the column order you give → one fact per row; `--json`, `--markdown`, `--all`, `--raw-args` | `0` same across every log; `1` at least one fact differs; `2` fewer than three inputs |
76
96
  | `servediff env [--python P] [-o snap.json]` | that interpreter's packages, GPU info, and env vars whose names start with `VLLM_` / `SGLANG_` / `SGL_` / `CUDA_` / `NCCL_` / `TORCH_` / `PYTORCH_` / `FLASHINFER_` / `TRITON_` or are `HF_HUB_OFFLINE` / `TRANSFORMERS_OFFLINE`; secret-looking names become `<redacted>` | `0` written; `2` snapshot failed |
77
- | `servediff capture [-o run.log] -- <server command>` | runs the server, tees its log, and writes `<out>.env.json` **before** launch | the server's own exit code |
97
+ | `servediff capture [-o run.log] -- <server command>` | runs the server, tees its log to stdout and to the file, and writes `<out>.env.json` **before** launch. If the command names a python launcher (`capture -- python -m vllm...`), that interpreter is the one snapshotted; otherwise pass `--python` to point at the server's venv | the server's own exit code |
78
98
 
79
99
  `1` always means *the inputs differ* — never *something went wrong* — so
80
100
  `servediff diff old.log new.log` works directly as a CI gate. At most one input may be
@@ -205,6 +205,52 @@ def test_capture_tees_output_and_writes_env_snapshot(tmp_path):
205
205
  assert "pytest" in data["packages"]
206
206
 
207
207
 
208
+ def test_capture_snapshots_the_python_the_command_names(tmp_path, capsys):
209
+ """`capture -- python -m vllm...` must snapshot that interpreter, not servediff's own."""
210
+ log = tmp_path / "run.log"
211
+ rc = servediff.main(["capture", "-o", str(log), "--", sys.executable, "-c", "print('hi')"])
212
+ assert rc == 0
213
+ data = json.loads(log.with_suffix(log.suffix + ".env.json").read_text(encoding="utf-8"))
214
+ assert data["executable"] == sys.executable
215
+ assert "does not name a python launcher" not in capsys.readouterr().err
216
+
217
+
218
+ def test_capture_survives_ctrl_c_and_keeps_the_log(tmp_path, capsys, monkeypatch):
219
+ """Ctrl-C is how a server run ends; exit 1 there would read as "the inputs differ"."""
220
+ log = tmp_path / "run.log"
221
+ terminated = []
222
+
223
+ class FakeProc:
224
+ returncode = None
225
+
226
+ def __init__(self):
227
+ self.stdout = self._lines()
228
+
229
+ def _lines(self):
230
+ yield "INFO: started serving\n"
231
+ raise KeyboardInterrupt
232
+
233
+ def poll(self):
234
+ return None if not terminated else 0
235
+
236
+ def terminate(self):
237
+ terminated.append("terminate")
238
+
239
+ def wait(self, timeout=None):
240
+ self.returncode = -15
241
+
242
+ # Stub the snapshot so the only Popen in play is the fake server's.
243
+ monkeypatch.setattr(servediff.envsnap, "snapshot",
244
+ lambda *a, **k: {"schema": "servediff-env/1", "packages": {}, "env": {},
245
+ "executable": "stub-python"})
246
+ monkeypatch.setattr(servediff.subprocess, "Popen", lambda *a, **k: FakeProc())
247
+ rc = servediff.main(["capture", "-o", str(log), "--", "fake-server"])
248
+ assert rc == 130
249
+ assert terminated == ["terminate"]
250
+ assert "INFO: started serving" in log.read_text(encoding="utf-8")
251
+ assert "interrupted; server stopped, log kept" in capsys.readouterr().err
252
+
253
+
208
254
  def test_capture_reports_missing_command(tmp_path, capsys):
209
255
  log = tmp_path / "x.log"
210
256
  assert servediff.main(["capture", "-o", str(log), "--", "no-such-binary-xyz"]) == 2
File without changes
File without changes
File without changes
File without changes
File without changes