From f5d15a21d235e72cfbc521ffce63e39b37326e83 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Thu, 3 Jul 2025 21:10:57 +0900 Subject: [PATCH 1/7] Add sample test --- CMakeLists.txt | 7 +++++++ include/sample.h | 3 +++ src/sample.cpp | 13 +++++++++++++ test/src/test_sum.cpp | 15 +++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 include/sample.h create mode 100644 src/sample.cpp create mode 100644 test/src/test_sum.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8abda1d..a9be7c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,3 +3,10 @@ project(sample_ros_pkg) find_package(catkin REQUIRED) catkin_package() + +if(CATKIN_ENABLE_TESTING) + catkin_add_gtest(test_sum + test/src/test_sum.cpp + src/sum.cpp + ) +endif() diff --git a/include/sample.h b/include/sample.h new file mode 100644 index 0000000..df6e391 --- /dev/null +++ b/include/sample.h @@ -0,0 +1,3 @@ +#pragma once + +int sum(const int a, const int b); diff --git a/src/sample.cpp b/src/sample.cpp new file mode 100644 index 0000000..f3413c3 --- /dev/null +++ b/src/sample.cpp @@ -0,0 +1,13 @@ +int sum(const int a, const int b) +{ + // covered + const int c = a + b; + return c; +} + +int mul(const int a, const int b) +{ + // not covered + const int c = a * b; + return c; +} diff --git a/test/src/test_sum.cpp b/test/src/test_sum.cpp new file mode 100644 index 0000000..1cc588f --- /dev/null +++ b/test/src/test_sum.cpp @@ -0,0 +1,15 @@ +#include + +#include + +TEST(Sum, Sum) +{ + ASSERT_EQ(sum(1, 2), 3); +} + +int main(int argc, char** argv) +{ + testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} From 8d6ca73d920a29153d250d4ab8b04079b41c88a0 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Thu, 3 Jul 2025 21:11:40 +0900 Subject: [PATCH 2/7] Update header --- include/sample.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/sample.h b/include/sample.h index df6e391..06ae34c 100644 --- a/include/sample.h +++ b/include/sample.h @@ -1,3 +1,4 @@ #pragma once int sum(const int a, const int b); +int mul(const int a, const int b); From dd3645e323d2ce36f31d4ed162c7c79737f900bb Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Thu, 3 Jul 2025 21:15:27 +0900 Subject: [PATCH 3/7] Fix filename --- CMakeLists.txt | 6 +++--- test/src/{test_sum.cpp => test_sample.cpp} | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename test/src/{test_sum.cpp => test_sample.cpp} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9be7c8..dae008c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,8 @@ find_package(catkin REQUIRED) catkin_package() if(CATKIN_ENABLE_TESTING) - catkin_add_gtest(test_sum - test/src/test_sum.cpp - src/sum.cpp + catkin_add_gtest(test_sample + test/src/test_sample.cpp + src/sample.cpp ) endif() diff --git a/test/src/test_sum.cpp b/test/src/test_sample.cpp similarity index 100% rename from test/src/test_sum.cpp rename to test/src/test_sample.cpp From 3e4fa4b28728c42ce872faf0283a089bdd47ea2e Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Thu, 3 Jul 2025 21:15:52 +0900 Subject: [PATCH 4/7] Enable coverage upload --- .github/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6496a56..4daccd0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,5 +16,6 @@ jobs: uses: alpine-ros/alpine-ros-ci-workflows/.github/workflows/ros1.yaml@main with: enable-bot-comment: true + enable-codecov: true secrets: bot-comment-token: ${{ secrets.GITHUB_TOKEN }} From f2d1cc5184d54a7c6acb7646859bf54d2a08e907 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Thu, 3 Jul 2025 21:17:15 +0900 Subject: [PATCH 5/7] Fix include --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dae008c..6c39073 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ project(sample_ros_pkg) find_package(catkin REQUIRED) catkin_package() +include_directories(include) + if(CATKIN_ENABLE_TESTING) catkin_add_gtest(test_sample test/src/test_sample.cpp From 196881abf650a3198897a62b9c489f67c573cabe Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Thu, 3 Jul 2025 21:24:14 +0900 Subject: [PATCH 6/7] Add codecov.yml --- codecov.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..30b231e --- /dev/null +++ b/codecov.yml @@ -0,0 +1,9 @@ +coverage: + status: + project: + default: + threshold: 5% + patch: + default: + target: 25% + only_pulls: true From 996eba8298f5bab451cae6b93666a9c7ff769da2 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Thu, 3 Jul 2025 21:31:32 +0900 Subject: [PATCH 7/7] Make path matched with package name --- CHANGELOG.rst => sample_ros_pkg/CHANGELOG.rst | 0 CMakeLists.txt => sample_ros_pkg/CMakeLists.txt | 0 README.md => sample_ros_pkg/README.md | 0 codecov.yml => sample_ros_pkg/codecov.yml | 0 {include => sample_ros_pkg/include}/sample.h | 0 package.xml => sample_ros_pkg/package.xml | 0 {src => sample_ros_pkg/src}/sample.cpp | 0 {test => sample_ros_pkg/test}/src/test_sample.cpp | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename CHANGELOG.rst => sample_ros_pkg/CHANGELOG.rst (100%) rename CMakeLists.txt => sample_ros_pkg/CMakeLists.txt (100%) rename README.md => sample_ros_pkg/README.md (100%) rename codecov.yml => sample_ros_pkg/codecov.yml (100%) rename {include => sample_ros_pkg/include}/sample.h (100%) rename package.xml => sample_ros_pkg/package.xml (100%) rename {src => sample_ros_pkg/src}/sample.cpp (100%) rename {test => sample_ros_pkg/test}/src/test_sample.cpp (100%) diff --git a/CHANGELOG.rst b/sample_ros_pkg/CHANGELOG.rst similarity index 100% rename from CHANGELOG.rst rename to sample_ros_pkg/CHANGELOG.rst diff --git a/CMakeLists.txt b/sample_ros_pkg/CMakeLists.txt similarity index 100% rename from CMakeLists.txt rename to sample_ros_pkg/CMakeLists.txt diff --git a/README.md b/sample_ros_pkg/README.md similarity index 100% rename from README.md rename to sample_ros_pkg/README.md diff --git a/codecov.yml b/sample_ros_pkg/codecov.yml similarity index 100% rename from codecov.yml rename to sample_ros_pkg/codecov.yml diff --git a/include/sample.h b/sample_ros_pkg/include/sample.h similarity index 100% rename from include/sample.h rename to sample_ros_pkg/include/sample.h diff --git a/package.xml b/sample_ros_pkg/package.xml similarity index 100% rename from package.xml rename to sample_ros_pkg/package.xml diff --git a/src/sample.cpp b/sample_ros_pkg/src/sample.cpp similarity index 100% rename from src/sample.cpp rename to sample_ros_pkg/src/sample.cpp diff --git a/test/src/test_sample.cpp b/sample_ros_pkg/test/src/test_sample.cpp similarity index 100% rename from test/src/test_sample.cpp rename to sample_ros_pkg/test/src/test_sample.cpp