Repository navigation
test(motd): pin dynamic inputs for the NO_COLOR comparison - #105
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
main 在 9d9917c 合并后,Ubuntu 24.04 / motd(job 141724086513)失败,断言为:
FAIL: NO_COLOR text differs from colored text。根因是
tests/test-motd.sh旧第 357–359 行:把两次实时取样的完整面板输出整体比较。面板含/proc/uptime(运行时长)、/proc/loadavg(负载)、/proc/meminfo(内存)、df /(根盘),这些字段每次运行都可能变化;第一次 NO_COLOR 运行与第二次带色运行之间只要秒数进位、负载或可用内存变动,文字就必然不等。PR #104 当时 16 项检查全绿只是取样恰好一致,不是行为正确性证据。Scope
只改测试,不改产品代码:
bin-stable/motd-fixture:在 source payload 之前定义awk()与df(),只对最后参数为/proc/uptime、/proc/loadavg、/proc/meminfo的 awk 调用改喂固定标准输入,df固定 75% 占用,其余命令一律走command awk "$@"或真实二进制,payload 逻辑与代码路径不变。0.13 / 0.27 / 0.41(单一动态字段,证明夹具确实生效,而非又一次实时取样)。Validation
bash -n tests/test-motd.sh(exit 0)与git diff --check(干净),未跑全量测试。Risks
awk/df;payload 未来若新增其它路径的 awk 调用会走command awk,不受影响。Rollback
单文件测试改动,
git revert本提交即可恢复原断言。