Skip to content

Commit b699648

Browse files
author
Murilo Marinho
committed
test: make [4/4] ambiguity regression hermetic (rclcpp stub)
The [4/4] smoke-test step used '#include <rclcpp/rclcpp.hpp>' but the raw g++ was not given the ROS include path, so it failed in CI with 'fatal error: rclcpp/rclcpp.hpp: No such file or directory'. The bug under test is purely a name-lookup issue, so a minimal rclcpp stub (class Clock; class Node) is name-lookup-identical to the real rclcpp::Clock and rclcpp::Node and lets the test run hermetically without ROS include plumbing. Verified: the consumer compiles with the fixed shim and fails ('reference to Clock is ambiguous') with the pre-fix shim.
1 parent 9985ed4 commit b699648

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

‎docker/smoke_test.sh‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
# libmarinholab_sas_core (legacy include path + namespace sas)
99
# [4/4] C++ namespace-ambiguity regression test (downstream-style consumer
1010
# with `using namespace rclcpp;` + bare `Clock` in `namespace sas`)
11+
#
12+
# Note on CI gating: the `run` step uses `docker compose up`, which does not
13+
# propagate the container's exit code. The checks here are therefore
14+
# informational in CI today; run this script manually (or via
15+
# `docker compose run --rm sas_core`) to get a real pass/fail signal.
1116
set -e
1217

1318
cd /root/sas_core_devel/src/
@@ -52,8 +57,23 @@ echo '=== [4/4] C++ namespace-ambiguity regression test (downstream-style) ==='
5257
# shim, `Clock` was ambiguous between rclcpp::Clock and
5358
# marinholab::sas::core::Clock. The `using Clock = ...` declaration in the
5459
# shim makes it a real member of `namespace sas`, shadowing rclcpp::Clock.
55-
# Compile-only: linking the full rclcpp runtime here is not required for
56-
# the name-lookup check.
60+
#
61+
# A minimal `rclcpp` stub (Clock + Node) is used instead of the full rclcpp
62+
# runtime: the bug is purely about *name lookup*, and a stub rclcpp::Clock /
63+
# rclcpp::Node is name-lookup-identical to the real ones. This keeps the test
64+
# hermetic and independent of the ROS include layout.
65+
STUB=/tmp/sas_ambig_stub/rclcpp
66+
mkdir -p "${STUB}"
67+
cat > "${STUB}/rclcpp.hpp" <<'CPP'
68+
#pragma once
69+
#include <memory>
70+
namespace rclcpp
71+
{
72+
class Clock {};
73+
class Node { public: std::shared_ptr<Clock> get_clock() { return nullptr; } };
74+
}
75+
CPP
76+
5777
cat > /tmp/sas_core_ambig_test.cpp <<'CPP'
5878
#include <memory>
5979
#include <rclcpp/rclcpp.hpp>
@@ -84,7 +104,7 @@ int main()
84104
CPP
85105

86106
g++ /tmp/sas_core_ambig_test.cpp -c -o /tmp/sas_core_ambig_test.o \
87-
-I"${SAS_INC}"
107+
-I"${STUB%/*}" -I"${SAS_INC}"
88108
echo 'Ambiguity regression test compiled (no ambiguous Clock).'
89109

90110
echo '=== ALL CHECKS PASSED ==='

0 commit comments

Comments
 (0)