Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions features/test/ros2/assets/minimal_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.8)
project(devcontainers_minimal)

find_package(ament_cmake REQUIRED)

add_executable(devcontainers_minimal_node src/main.cpp)
install(TARGETS devcontainers_minimal_node DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
ament_add_gtest(devcontainers_minimal_test test/test_main.cpp)
endif()

ament_package()
15 changes: 15 additions & 0 deletions features/test/ros2/assets/minimal_package/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<package format="3">
<name>devcontainers_minimal</name>
<version>0.0.0</version>
<description>Minimal package used to validate the ROS 2 development environment.</description>
<maintainer email="maintainer@example.com">Devcontainers test</maintainer>
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<test_depend>ament_cmake_gtest</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
7 changes: 7 additions & 0 deletions features/test/ros2/assets/minimal_package/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <iostream>

int main()
{
std::cout << "ROS 2 development environment is ready" << std::endl;
return 0;
}
6 changes: 6 additions & 0 deletions features/test/ros2/assets/minimal_package/test/test_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <gtest/gtest.h>

TEST(DevcontainersMinimal, BuildsAndRuns)
{
EXPECT_EQ(2 + 2, 4);
}
18 changes: 18 additions & 0 deletions features/test/ros2/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,22 @@ check "absent overlay does not break shell startup" bash -lc 'command -v ros2 >/
check "effective user bashrc sources ROS profile once" bash -lc 'test "$(grep -Fc "[ -f /etc/profile.d/ros2.sh ] && . /etc/profile.d/ros2.sh" /home/vscode/.bashrc)" -eq 1'
check "colcon completion is enabled" bash -ic 'complete -p colcon >/dev/null'

test_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
workspace="/tmp/ros2_minimal_workspace"

mkdir -p "${workspace}/src"
cp -R "${test_dir}/assets/minimal_package" "${workspace}/src/"
cd "${workspace}"

check "rosdep metadata can be updated" rosdep update
check "workspace dependencies can be resolved" rosdep install --from-paths src --ignore-src --rosdistro "${ROS_DISTRO}" -y
check "minimal workspace builds" colcon build --event-handlers console_direct+

# shellcheck disable=SC1091
source install/setup.bash

check "minimal workspace tests run" colcon test --event-handlers console_direct+
check "minimal workspace tests pass" colcon test-result --verbose
check "installed workspace executable runs" "${workspace}/install/devcontainers_minimal/lib/devcontainers_minimal/devcontainers_minimal_node"

reportResults