Files
agentmc/run_tests.sh
JianFeeeee 34ed70ab53 修复视距不生效 + 接入统一测试
视距(用户报「无法调整视距?」)——根因是三处不同步:
  1. options.renderDistance        本地设置(原先只设了这个)
  2. options.setServerRenderDistance 服务端下发上限(getEffectiveRenderDistance = min(两者))
  3. ClientChunkCache.updateViewRadius storage 半径
第三处最关键:官方只在收到服务端半径包时才调它(ClientPacketListener:2316),
我们不连服 ⇒ Storage.inRange 用旧半径判定,超出区块被**静默丢弃**。

另一个前置:加载半径必须跟随视距。视距 12 只喂 3 圈数据,
画面看起来就像没生效(最容易误判的坑)。

实测(同相机同存档):
  视距 4  → 注入 81   渲染 55   色彩 15226
  视距 12 → 注入 595  渲染 447  色彩 18477
画面差异显著:RD=12 能看到延伸到地平线的森林与完整海岸线。
(sample-render-distance-{4,12}.png)

测试:新增 tests/test_anvil.py(13 项,存档/NBT/编码)
      tests/test_render_bridge.py(3 项,桥协议+合成渲染+真实存档渲染)
      run_tests.sh 改为默认跑单元测试、--with-render 跑联测
      合计 61 项全绿(原 48 + 13)
2026-09-25 17:47:58 +08:00

40 lines
1.2 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# 统一测试入口。
#
# ./run_tests.sh 纯 Python 单元测试(秒级)
# ./run_tests.sh --with-render 额外跑渲染桥联测(需 Java + Xvfb,约 4 分钟)
#
# 渲染联测需要:
# MCFOLD_RENDER_CLASSPATH 含 client-named.jar 与 McfoldRenderServer.class
# MCFOLD_NATIVES_DIR lwjgl natives(.so)
# DISPLAY 指向可用的 X(Xvfb 即可)
# 缺任一项会**跳过而非失败**(不误报)。
cd "$(dirname "$0")"
WITH_RENDER=0
[ "${1:-}" = "--with-render" ] && WITH_RENDER=1
total=0; fail=0
for t in tests/test_*.py; do
name=$(basename "$t")
if [ "$name" = "test_render_bridge.py" ] && [ $WITH_RENDER -eq 0 ]; then
printf ' %-24s ⊘ 跳过(用 --with-render 启用)\n' "$name"
continue
fi
out=$(python3 "$t" 2>&1)
if echo "$out" | grep -qE "全部通过|通过$"; then
n=$(echo "$out" | grep -c "^ ✓")
total=$((total+n))
printf ' %-24s ✓ %2d 项\n' "$name" "$n"
else
fail=$((fail+1))
printf ' %-24s ✗ 失败\n' "$name"
echo "$out" | tail -6 | sed 's/^/ /'
fi
done
echo
if [ $fail -eq 0 ]; then
echo "全部通过:$total 项,0 失败"
else
echo "失败 $fail 个套件(共 $total 项通过)"; exit 1
fi