Skip to content

Commit 143c612

Browse files
committed
test(e2e): 钉住「改 action 的命令」也会生效
与「改 action 的输入」是两条不同的路径,必须都成立,否则改了生成器的调用方式会被 静默忽略: - 改**输入** → ninja 直接看到,重跑那条边 - 改 **build.mcpp** → ninja 跟踪的东西一样没变;是 build.mcpp 自己重跑(源码在它 的缓存键里)、重新声明出一条命令不同的 action,ninja 再因为 rule 的 command 变了而重跑 只测前者会让后者的回归完全隐形。
1 parent 8ed92f6 commit 143c612

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/e2e/188_build_actions.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ touch src/main.cpp
123123
grep -q "GENERATE" b3.log && {
124124
cat b3.log; echo "FAIL: the action re-ran although its inputs were unchanged"; exit 1; }
125125

126+
# ── 2b. changing the action's COMMAND also takes effect ────────────────────
127+
# Distinct from 2: there the action's declared INPUT changed and ninja noticed.
128+
# Here nothing ninja tracks changed — only build.mcpp, which re-runs (its own
129+
# source is part of its cache key), re-declares the action with a different
130+
# command, and ninja re-runs the edge because the rule's command changed. Both
131+
# halves have to work or an edited generator invocation is silently ignored.
132+
sed -i 's|"/data/value.txt"|"/data/other.txt"|g' build.mcpp
133+
echo "31" > data/other.txt
134+
"$MCPP" build > b2b.log 2>&1 || { cat b2b.log; echo "FAIL: rebuild after editing build.mcpp failed"; exit 1; }
135+
out="$("$MCPP" run 2>&1 | grep '^VALUE=' | tail -1)"
136+
[[ "$out" == "VALUE=31" ]] || {
137+
cat b2b.log; echo "FAIL: an edited action command did not take effect: $out"; exit 1; }
138+
126139
# ── 3. a failing check fails the build ─────────────────────────────────────
127140
touch FAIL_THE_CHECK
128141
rm -f "$OUTDIR/lint.stamp"

0 commit comments

Comments
 (0)