From eda4263dba8c7de3a59e83ad422e4904d45402c0 Mon Sep 17 00:00:00 2001 From: argszero Date: Thu, 13 Aug 2026 10:56:17 +0800 Subject: [PATCH] emrg: fix .iss LoadStringFromFile 2-param signature (v0.2.30 Build Release windows gate) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v0.2.30 Build Release 31661378619 failed at the windows 'Make installer' step: iscc rejected the emrg.iss [Code] section with 'Invalid number of parameters' on LoadStringFromFile(LogFile). Root cause: Inno Setup's Pascal Script API declares function LoadStringFromFile(const FileName: String; var S: AnsiString): Boolean; (2-param out-argument form, identical in 6.7.1 through 7.x — verified against issrc Shared.ScriptFunc.pas). #727's R125 log-surfacing code called the non-existent 1-param string-returning form; the Test workflow never compiles the .iss, so the error only surfaced at tag-push Build Release (v0.2.7 lesson recurring). Fix: - make-installer.sh: call LoadStringFromFile(LogFile, LogText) (out-param), keep FileExists guard + 2000-char truncation - tests/test_installer_stop.py: assert the 2-param form (positive) and forbid the 1-param form (negative) - test.yml test-windows: new 'Inno Setup script compile smoke test' step — renders the emrg.iss heredoc (stub payload) and runs the runner's preinstalled iscc, so .iss syntax/signature errors fail PR CI instead of at release time --- .github/workflows/test.yml | 22 ++++++++++++++++++++++ packaging/make-installer.sh | 8 +++++++- tests/test_installer_stop.py | 8 +++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8cc14dbc..c87ee71c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -56,3 +56,25 @@ jobs: - run: uv sync - name: Python tests (Windows) run: uv run pytest tests/ -v + # v0.2.30 教训(Build Release 31661378619):Test 全绿 ≠ .iss 能编译。 + # make-installer.sh 的 emrg.iss 只在 tag 触发 Build Release 时经 iscc 编译, + # #727 误用 LoadStringFromFile 单参数形式(Inno 真实签名是 2 参数 out-param) + # → iscc "Invalid number of parameters" 发版才暴露。此处用 runner 预装的 + # iscc 编译渲染出的 emrg.iss(stub payload),PR CI 即拦截 .iss 语法/签名错误。 + - name: Inno Setup script compile smoke test + shell: bash + run: | + set -euo pipefail + STAGE="$(mktemp -d)" + mkdir -p "$STAGE/payload/bin" "$STAGE/dist/artifacts" + touch "$STAGE/payload/bin/stop-emrg.cmd" + # 渲染 make-installer.sh 的 emrg.iss heredoc(变量展开与真实构建一致) + sed -n '/cat > "\$STAGE\/emrg.iss" < "$STAGE/gen.sh" + VERSION="0.0.0-smoke" \ + DIST_WIN="$(cygpath -m "$STAGE/dist")" \ + STAGE_WIN="$(cygpath -m "$STAGE")" \ + ROOT_WIN="$(cygpath -m "$PWD")" \ + STAGE="$STAGE" \ + bash "$STAGE/gen.sh" + command -v iscc >/dev/null 2>&1 || { echo "::error::iscc not on PATH (runner image regression)"; exit 1; } + iscc "$STAGE/emrg.iss" diff --git a/packaging/make-installer.sh b/packaging/make-installer.sh index f2e73280..340f6519 100755 --- a/packaging/make-installer.sh +++ b/packaging/make-installer.sh @@ -400,8 +400,14 @@ begin if ResultCode <> 0 then begin LogText := ''; + // LoadStringFromFile 的 Inno Pascal Script 签名是 + // `function LoadStringFromFile(const FileName: String; var S: AnsiString): Boolean;` + // (6.7.1 → 7.x 全版本一致,见 issrc Shared.ScriptFunc.pas)——不存在单参数 + // 字符串返回形式!v0.2.30 Build Release 31661378619 因此编译失败 + // (iscc "Invalid number of parameters",Test CI 不编译 .iss 未拦住)。 + // 正确用法:out-param 写入 LogText,返回 Boolean 表示成功。 if FileExists(LogFile) then - LogText := LoadStringFromFile(LogFile); + LoadStringFromFile(LogFile, LogText); if Length(LogText) > 2000 then LogText := Copy(LogText, 1, 2000); if LogText <> '' then diff --git a/tests/test_installer_stop.py b/tests/test_installer_stop.py index cc431ed3..ca8ba040 100644 --- a/tests/test_installer_stop.py +++ b/tests/test_installer_stop.py @@ -146,7 +146,13 @@ def test_make_installer_iss_has_prepare_to_install(): # R125: rant 2026-08-13T09:24:37 — 输出重定向到 {tmp}\stop-emrg.log(2>&1), # 失败时 LoadStringFromFile 读日志展示杀不掉的进程,不再让宿主手动跑诊断 assert '/c ""\' + StopScript + \'" > "\' + LogFile + \'" 2>&1"' in content - assert "LoadStringFromFile(LogFile)" in content + # ⚡ LoadStringFromFile 的 Inno Pascal Script 签名是 2 参数 out-param 形式 + # `(const FileName: String; var S: AnsiString): Boolean`(6.7.1 → 7.x 一致, + # issrc Shared.ScriptFunc.pas)——单参数字符串返回形式不存在,iscc 编译报 + # "Invalid number of parameters"(v0.2.30 Build Release 31661378619 实际失败, + # Test CI 不编译 .iss 未拦住)。正反两态钉死正确调用形态。 + assert "LoadStringFromFile(LogFile, LogText)" in content # 正:out-param 形式 + assert ":= LoadStringFromFile(LogFile)" not in content # 反:1 参数形式不存在 assert "Length(LogText) > 2000" in content assert "Details from stop-emrg.cmd:" in content assert "SW_HIDE" in content # 批处理执行不弹控制台窗口(#592 纪律)