为什么ctests通过此“失败”。即使在失败_regular_expression时测试不匹配?
我在.cmake
文件中使用以下几行添加了一个简单的测试:
add_test( NAME ktxsc-test-many-in-one-out
COMMAND ktxsc -o foo a.ktx2 b.ktx2 c.ktx2
)
set_tests_properties(
ktxsc-test-many-in-one-out
PROPERTIES
WILL_FAIL TRUE
FAIL_REGULAR_EXPRESSION "^Can't use -o when there are multiple infiles."
)
测试传递,testlog显示
----------------------------------------------------------
Test Pass Reason:
Error regular expression found in output. Regex=[^Can't use -o when there are multiple infiles.]
"ktxsc-test-many-in-one-out" end time: Jun 30 16:34 JST
"ktxsc-test-many-in-one-out" time elapsed: 00:00:00
----------------------------------------------------------
我是否将fail_regular_expression
转换为
FAIL_REGULAR_EXPRESSION "some rubbish"
测试,即使即使应用与以前打印相同的消息。这次,测试日志显示了
----------------------------------------------------------
Test Passed.
"ktxsc-test-many-in-one-out" end time: Jun 30 16:53 JST
"ktxsc-test-many-in-one-out" time elapsed: 00:00:00
----------------------------------------------------------
我通常在没有*_常规_expression
时通常看到的。
为什么会发生这种情况?当fail_regular_expression
与不匹配时,如何使CTEST失败测试?
I added a simple test to ctest with the following lines in a .cmake
file:
add_test( NAME ktxsc-test-many-in-one-out
COMMAND ktxsc -o foo a.ktx2 b.ktx2 c.ktx2
)
set_tests_properties(
ktxsc-test-many-in-one-out
PROPERTIES
WILL_FAIL TRUE
FAIL_REGULAR_EXPRESSION "^Can't use -o when there are multiple infiles."
)
The test passes and the TestLog shows
----------------------------------------------------------
Test Pass Reason:
Error regular expression found in output. Regex=[^Can't use -o when there are multiple infiles.]
"ktxsc-test-many-in-one-out" end time: Jun 30 16:34 JST
"ktxsc-test-many-in-one-out" time elapsed: 00:00:00
----------------------------------------------------------
If I change FAIL_REGULAR_EXPRESSION
to
FAIL_REGULAR_EXPRESSION "some rubbish"
the test still passes even though the app is printing the same message as before. This time the test log shows
----------------------------------------------------------
Test Passed.
"ktxsc-test-many-in-one-out" end time: Jun 30 16:53 JST
"ktxsc-test-many-in-one-out" time elapsed: 00:00:00
----------------------------------------------------------
which is what I normally see when no *_REGULAR_EXPRESSION
is set.
Why is this happening? How can I get ctest to fail the test when the FAIL_REGULAR_EXPRESSION
doesn't match?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢@tsyvarev的答案。
CTEST正在做
确定测试是否失败。如果比赛成功,则未检查退出代码。如果比赛失败,则将检查退出代码,并忽略了失败的匹配。
该文档尚不清楚。我已经阅读了很多次,直到@tsyvarev朝正确的方向转向正确的方向。我也发现这是一个糟糕的行为选择。我所有的工具在存在错误条件时都输出非零错误代码和消息。我需要两者都测试。我之前曾问过这个问题。它需要重复测试。
Thanks to @Tsyvarev for this answer.
ctest is doing
to determine if a test has failed. If the match succeeds the exit code is not checked. If the match fails the exit code is checked and the failed match is ignored.
The documentation is unclear. I've read it many times and still didn't figure out this behavior until steered in the right direction by @Tsyvarev. I also find this a poor behavioral choice. All my tools output both a non-zero error code and a message when there is an error condition. I need to test both. I previously asked this question about that. It requires duplicating tests.