ros2
test_error
ai_generated
true
colcon test:在'build/my_package/test_results'中未找到测试输出文件
colcon test: No test output files found in 'build/my_package/test_results'
ID: ros2/colcon-test-missing-test-output
85%修复率
82%置信度
1证据数
2024-01-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| ROS2 Humble | active | — | — | — |
| ROS2 Iron | active | — | — | — |
| ROS2 Rolling | active | — | — | — |
根因分析
测试运行器(如pytest、gtest)未在预期目录中生成输出文件,因为测试未能运行、被跳过,或CMake/ament测试配置未正确设置输出生成。
English
The test runner (e.g., pytest, gtest) did not produce output files in the expected directory because tests failed to run, were skipped, or the CMake/ament test configuration did not set up output generation correctly.
官方文档
https://docs.ros.org/en/humble/Tutorials/Intermediate/Testing/Testing.html解决方案
-
检查测试可执行文件是否存在并可运行:'colcon test --packages-select my_package',并在控制台输出中查找错误消息。如果是C++ gtest,确保在CMakeLists.txt中使用了'add_rostest'或'ament_add_gtest'。
-
使用'--cmake-args -DBUILD_TESTING=ON'重新构建包,然后重新运行测试。这确保测试目标被构建。
-
对于Python包,确保'setup.py'或'setup.cfg'中有指向正确测试目录的'test'部分,并从工作区根目录运行'colcon test'。
无效尝试
常见但无效的做法:
-
Running 'colcon test' with '--event-handlers console_direct+' to see all output, but still no test results
80% 失败
This only increases verbosity; it does not fix the underlying issue of tests not producing output files.
-
Manually creating the test_results directory to satisfy colcon
95% 失败
The directory must contain actual test output files; an empty directory does not resolve the error.