Skip to content

Commit

Permalink
[CI] Add coveragepy and remove ignore: test (#1668)
Browse files Browse the repository at this point in the history
  • Loading branch information
christophfroehlich committed Aug 14, 2024
1 parent bb2fab2 commit 1063964
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 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 @@ -29,6 +29,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
14 changes: 10 additions & 4 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 @@ -67,14 +68,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 @@ -234,7 +239,8 @@ TEST_F(TestLoadController, unload_on_kill)
// timeout command will kill it after the specified time with signal SIGINT
std::stringstream ss;
ss << "timeout --signal=INT 5 "
<< "ros2 run controller_manager spawner "
<< std::string(coveragepy_script) +
" $(ros2 pkg prefix controller_manager)/lib/controller_manager/spawner "
<< "ctrl_3 -c test_controller_manager -t "
<< std::string(test_controller::TEST_CONTROLLER_CLASS_NAME) << " --unload-on-kill";

Expand Down

0 comments on commit 1063964

Please sign in to comment.