Skip to content

Commit

Permalink
[CI] Add coveragepy and remove ignore: test (ros-controls#1668)
Browse files Browse the repository at this point in the history
  • Loading branch information
christophfroehlich authored Aug 14, 2024
1 parent 07fb4f3 commit 3cf167d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
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

0 comments on commit 3cf167d

Please sign in to comment.