You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

打包CMake时RunCMake测试因stderr不匹配失败,如何解决?

问题

使用dpkg-buildpackage -rfakeroot -uc -b打包CMake时,大量RunCMake测试失败,失败原因均为stderr does not match that expected。经排查发现,测试用例的预期stderr内容包含转义符号(如\.、\$),但实际输出的stderr无这些转义符号,导致匹配失败,这些带转义的预期内容存在于CMake源码的测试文件中。

具体输出对比如下:

Actual stdout:

actual-out> Not searching for unused variables given on the command line.
actual-out> -- The C compiler identification is GNU 9.3.0
actual-out> -- Detecting C compiler ABI info
actual-out> -- Detecting C compiler ABI info - done
actual-out> -- Check for working C compiler: /usr/bin/cc - skipped
actual-out> -- Detecting C compile features
actual-out> -- Detecting C compile features - done
actual-out> -- Configuring done

Expected stderr to match:

expect-err> ^CMake Error in CMakeLists\.txt:
expect-err>   Property INTERFACE_HEADER_SETS_TO_VERIFY of target "nonexistent" contained
expect-err>   the following header sets that are nonexistent or not INTERFACE:
expect-err> 
expect-err>     b
expect-err>     c
expect-err> 
expect-err> 
expect-err> CMake Generate step failed\.  Build files cannot be regenerated correctly\.$

Actual stderr:

actual-err> CMake Error in CMakeLists.txt:
actual-err>   Property INTERFACE_HEADER_SETS_TO_VERIFY of target "nonexistent" contained
actual-err>   the following header sets that are nonexistent or not INTERFACE:
actual-err> 
actual-err>     b
actual-err>     c
actual-err> 
actual-err> 
actual-err> CMake Generate step failed.  Build files cannot be regenerated correctly.

解决方法

  • 修改测试预期文件:找到CMake源码中对应测试的-stderr.txt文件,移除其中的转义符号,比如把CMakeLists\.txt改为CMakeLists.txt,failed\.改为failed.,correctly\.$改为correctly.,修改后重新运行测试即可匹配实际输出。
  • 跳过失败测试:若仅需完成打包,可在执行dpkg-buildpackage前,通过-DBUILD_TESTING=OFF参数关闭所有测试,或通过更精细的配置跳过特定RunCMake测试组。
  • 调整正则匹配逻辑:部分系统中测试使用的正则工具对转义字符处理存在差异,可修改CMake测试框架的正则匹配脚本,确保转义字符被正确解析(此方法复杂度较高,需熟悉测试框架代码)。

内容的提问来源于stack exchange,提问作者user3852441

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 22:13:11