Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Add coveragepy and remove ignore: test #1668

Merged
merged 11 commits into from
Aug 14, 2024
2 changes: 0 additions & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ fixes:
comment:
layout: "diff, flags, files"
behavior: default
ignore:
- "**/test"
flags:
unittests:
paths:
Expand Down
1 change: 1 addition & 0 deletions controller_manager/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

<test_depend>ament_cmake_gmock</test_depend>
<test_depend>ament_cmake_pytest</test_depend>
<test_depend>python3-coverage</test_depend>
<test_depend>hardware_interface_testing</test_depend>
<test_depend>ros2_control_test_assets</test_depend>

Expand Down
16 changes: 11 additions & 5 deletions controller_manager/test/test_spawner_unspawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

using ::testing::_;
using ::testing::Return;
const char coveragepy_script[] = "python3 -m coverage run --append --branch";

using namespace std::chrono_literals;
class TestLoadController : public ControllerManagerFixture<controller_manager::ControllerManager>
Expand Down Expand Up @@ -68,14 +69,18 @@ class TestLoadController : public ControllerManagerFixture<controller_manager::C

int call_spawner(const std::string extra_args)
{
std::string spawner_script = "ros2 run controller_manager spawner ";
std::string spawner_script =
std::string(coveragepy_script) +
" $(ros2 pkg prefix controller_manager)/lib/controller_manager/spawner ";
return std::system((spawner_script + extra_args).c_str());
}

int call_unspawner(const std::string extra_args)
{
std::string spawner_script = "ros2 run controller_manager unspawner ";
return std::system((spawner_script + extra_args).c_str());
std::string unspawner_script =
std::string(coveragepy_script) +
" $(ros2 pkg prefix controller_manager)/lib/controller_manager/unspawner ";
return std::system((unspawner_script + extra_args).c_str());
}

TEST_F(TestLoadController, spawner_with_no_arguments_errors)
Expand Down Expand Up @@ -301,8 +306,9 @@ TEST_F(TestLoadController, unload_on_kill)
cm_->set_parameter(rclcpp::Parameter("ctrl_3.type", test_controller::TEST_CONTROLLER_CLASS_NAME));
std::stringstream ss;
ss << "timeout --signal=INT 5 "
<< "ros2 run controller_manager spawner ctrl_3 -c test_controller_manager"
<< " --unload-on-kill";
<< std::string(coveragepy_script) +
" $(ros2 pkg prefix controller_manager)/lib/controller_manager/spawner "
<< "ctrl_3 -c test_controller_manager --unload-on-kill";

EXPECT_NE(std::system(ss.str().c_str()), 0)
<< "timeout should have killed spawner and returned non 0 code";
Expand Down
Loading