chore: import upstream snapshot with attribution
Integration Tests / melodic (push) Has been cancelled
Integration Tests / noetic (push) Has been cancelled
Integration Tests / humble (push) Has been cancelled
Integration Tests / jazzy (push) Has been cancelled
Ruff Lint & Format / ruff (push) Has been cancelled
Sync main to develop / Check if sync is needed (push) Has been cancelled
Sync main to develop / Sync main to develop (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 12:36:23 +08:00
commit db1d565b64
209 changed files with 22046 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
# Run cross-tests: verify each distro is detected as the correct ROS version.
# Usage: ./tests/integration/scripts/run-all-cross-tests.sh
set -e
cd "$(git rev-parse --show-toplevel)"
PASSED=()
FAILED=()
run_check() {
local distro="$1"
local expected="$2"
echo ""
echo "========================================"
echo " $distro → expecting $expected"
echo "========================================"
if ./tests/integration/scripts/run-cross-test.sh "$distro" "$expected"; then
PASSED+=("$distro=$expected")
else
FAILED+=("$distro=$expected")
fi
}
# Correct expectations — all should PASS
run_check melodic ROS1
run_check noetic ROS1
run_check humble ROS2
run_check jazzy ROS2
echo ""
echo "========================================"
echo " RESULTS"
echo "========================================"
echo "Passed: ${PASSED[*]:-none}"
echo "Failed: ${FAILED[*]:-none}"
if [ ${#FAILED[@]} -gt 0 ]; then
exit 1
fi
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
# Run version detection tests against ALL supported distros.
# Usage: ./tests/integration/scripts/run-all-distros.sh
set -e
cd "$(git rev-parse --show-toplevel)"
DISTROS=(melodic noetic humble jazzy)
PASSED=()
FAILED=()
for distro in "${DISTROS[@]}"; do
echo ""
echo "========================================"
echo " Testing: $distro"
echo "========================================"
echo ""
if ./tests/integration/scripts/run-detect-test.sh "$distro"; then
PASSED+=("$distro")
else
FAILED+=("$distro")
fi
done
echo ""
echo "========================================"
echo " RESULTS"
echo "========================================"
echo "Passed: ${PASSED[*]:-none}"
echo "Failed: ${FAILED[*]:-none}"
echo ""
if [ ${#FAILED[@]} -gt 0 ]; then
exit 1
fi
+89
View File
@@ -0,0 +1,89 @@
#!/bin/bash
# Cross-test: start one distro's container, tell pytest it's a DIFFERENT distro.
# The test should FAIL because the detector sees the real distro.
#
# Usage: ./tests/integration/scripts/run-cross-test.sh <real_distro> <fake_distro>
# Example: ./tests/integration/scripts/run-cross-test.sh noetic humble
# → Starts Noetic, runs pytest with --ros-distro humble → should FAIL
set -e
cd "$(git rev-parse --show-toplevel)"
REAL_DISTRO="${1:?Usage: $0 <real_distro> <fake_distro>}"
FAKE_DISTRO="${2:?Usage: $0 <real_distro> <fake_distro>}"
COMPOSE="tests/integration/docker-compose.yml"
if [ "$REAL_DISTRO" = "$FAKE_DISTRO" ]; then
EXPECT_PASS=true
else
EXPECT_PASS=false
fi
declare -A DOCKERFILES=(
[melodic]="Dockerfile.ros1-melodic"
[noetic]="Dockerfile.ros1-noetic"
[humble]="Dockerfile.ros2-humble"
[jazzy]="Dockerfile.ros2-jazzy"
)
declare -A CONTAINERS=(
[melodic]="integration-ros-melodic"
[noetic]="integration-ros-noetic"
[humble]="integration-ros2-humble"
[jazzy]="integration-ros2-jazzy"
)
DOCKERFILE="${DOCKERFILES[$REAL_DISTRO]}"
CONTAINER="${CONTAINERS[$REAL_DISTRO]}"
if [ -z "$DOCKERFILE" ]; then
echo "Unknown distro: $REAL_DISTRO (valid: melodic, noetic, humble, jazzy)"
exit 1
fi
echo "=== Cross-test: running $REAL_DISTRO, claiming $FAKE_DISTRO ==="
if $EXPECT_PASS; then
echo "Expected: pytest PASSES (same distro)"
else
echo "Expected: pytest FAILS on distro/version mismatch"
fi
echo ""
# Start the REAL container
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" down --volumes 2>/dev/null || true
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" up --build -d --wait
echo ""
echo "--- Running pytest --ros-distro $FAKE_DISTRO --skip-compose ---"
echo ""
# Run pytest with the FAKE distro but skip compose (use the already-running REAL container)
if uv run pytest tests/integration/test_detect_version.py -v \
--ros-distro "$FAKE_DISTRO" --skip-compose; then
PYTEST_PASSED=true
else
PYTEST_PASSED=false
fi
echo ""
if $EXPECT_PASS && $PYTEST_PASSED; then
echo "PASS — pytest passed as expected (same distro)"
EXIT=0
elif $EXPECT_PASS && ! $PYTEST_PASSED; then
echo "!!! UNEXPECTED FAIL — pytest should have passed for matching distro !!!"
EXIT=1
elif ! $EXPECT_PASS && ! $PYTEST_PASSED; then
echo "PASS — pytest failed as expected (detector saw $REAL_DISTRO, not $FAKE_DISTRO)"
EXIT=0
else
echo "!!! UNEXPECTED PASS — detector did not catch the mismatch !!!"
EXIT=1
fi
# Tear down
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" down --volumes 2>/dev/null || true
exit $EXIT
+89
View File
@@ -0,0 +1,89 @@
#!/bin/bash
# Cross-test: start one distro's container, tell pytest it's a DIFFERENT distro.
# The test should FAIL because the detector sees the real distro.
#
# Usage: ./tests/integration/scripts/run-detect-cross-test.sh <real_distro> <fake_distro>
# Example: ./tests/integration/scripts/run-detect-cross-test.sh noetic humble
# → Starts Noetic, runs pytest with --ros-distro humble → should FAIL
set -e
cd "$(git rev-parse --show-toplevel)"
REAL_DISTRO="${1:?Usage: $0 <real_distro> <fake_distro>}"
FAKE_DISTRO="${2:?Usage: $0 <real_distro> <fake_distro>}"
COMPOSE="tests/integration/docker-compose.yml"
if [ "$REAL_DISTRO" = "$FAKE_DISTRO" ]; then
EXPECT_PASS=true
else
EXPECT_PASS=false
fi
declare -A DOCKERFILES=(
[melodic]="Dockerfile.ros1-melodic"
[noetic]="Dockerfile.ros1-noetic"
[humble]="Dockerfile.ros2-humble"
[jazzy]="Dockerfile.ros2-jazzy"
)
declare -A CONTAINERS=(
[melodic]="integration-ros-melodic"
[noetic]="integration-ros-noetic"
[humble]="integration-ros2-humble"
[jazzy]="integration-ros2-jazzy"
)
DOCKERFILE="${DOCKERFILES[$REAL_DISTRO]}"
CONTAINER="${CONTAINERS[$REAL_DISTRO]}"
if [ -z "$DOCKERFILE" ]; then
echo "Unknown distro: $REAL_DISTRO (valid: melodic, noetic, humble, jazzy)"
exit 1
fi
echo "=== Cross-test: running $REAL_DISTRO, claiming $FAKE_DISTRO ==="
if $EXPECT_PASS; then
echo "Expected: pytest PASSES (same distro)"
else
echo "Expected: pytest FAILS on distro/version mismatch"
fi
echo ""
# Start the REAL container
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" down --volumes 2>/dev/null || true
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" up --build -d --wait
echo ""
echo "--- Running pytest --ros-distro $FAKE_DISTRO --skip-compose ---"
echo ""
# Run pytest with the FAKE distro but skip compose (use the already-running REAL container)
if uv run pytest tests/integration/test_detect_version.py -v \
--ros-distro "$FAKE_DISTRO" --skip-compose; then
PYTEST_PASSED=true
else
PYTEST_PASSED=false
fi
echo ""
if $EXPECT_PASS && $PYTEST_PASSED; then
echo "PASS — pytest passed as expected (same distro)"
EXIT=0
elif $EXPECT_PASS && ! $PYTEST_PASSED; then
echo "!!! UNEXPECTED FAIL — pytest should have passed for matching distro !!!"
EXIT=1
elif ! $EXPECT_PASS && ! $PYTEST_PASSED; then
echo "PASS — pytest failed as expected (detector saw $REAL_DISTRO, not $FAKE_DISTRO)"
EXIT=0
else
echo "!!! UNEXPECTED PASS — detector did not catch the mismatch !!!"
EXIT=1
fi
# Tear down
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" down --volumes 2>/dev/null || true
exit $EXIT
+63
View File
@@ -0,0 +1,63 @@
#!/bin/bash
# Run the version detection test against a specific ROS distro.
# Usage: ./tests/integration/scripts/run-detect-test.sh <distro>
# Example: ./tests/integration/scripts/run-detect-test.sh noetic
set -e
cd "$(git rev-parse --show-toplevel)"
DISTRO="${1:?Usage: $0 <melodic|noetic|humble|jazzy>}"
COMPOSE="tests/integration/docker-compose.yml"
declare -A DOCKERFILES=(
[melodic]="Dockerfile.ros1-melodic"
[noetic]="Dockerfile.ros1-noetic"
[humble]="Dockerfile.ros2-humble"
[jazzy]="Dockerfile.ros2-jazzy"
)
declare -A CONTAINERS=(
[melodic]="integration-ros-melodic"
[noetic]="integration-ros-noetic"
[humble]="integration-ros2-humble"
[jazzy]="integration-ros2-jazzy"
)
DOCKERFILE="${DOCKERFILES[$DISTRO]}"
CONTAINER="${CONTAINERS[$DISTRO]}"
if [ -z "$DOCKERFILE" ]; then
echo "Unknown distro: $DISTRO"
echo "Valid options: melodic, noetic, humble, jazzy"
exit 1
fi
echo "=== Testing $DISTRO ==="
echo "Dockerfile: $DOCKERFILE"
echo "Container: $CONTAINER"
echo ""
# Tear down any previous container
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" down --volumes 2>/dev/null || true
# Build and start
echo "--- Starting container ---"
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" up --build -d --wait
# Run quick detect
echo ""
echo "--- Quick detect ---"
uv run python tests/integration/test_quick_detect.py
# Run pytest
echo ""
echo "--- Pytest ---"
uv run pytest tests/integration/test_detect_version.py -v --ros-distro "$DISTRO"
# Tear down
echo ""
echo "--- Tearing down ---"
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" down --volumes
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
# Run integration tests against ALL supported distros.
# Usage: ./tests/integration/scripts/run-tests-all-distros.sh
set -e
cd "$(git rev-parse --show-toplevel)"
DISTROS=(melodic noetic humble jazzy)
PASSED=()
FAILED=()
for distro in "${DISTROS[@]}"; do
echo ""
echo "========================================"
echo " Testing: $distro"
echo "========================================"
echo ""
if ./tests/integration/scripts/run-tests.sh "$distro"; then
PASSED+=("$distro")
else
FAILED+=("$distro")
fi
done
echo ""
echo "========================================"
echo " RESULTS"
echo "========================================"
echo "Passed: ${PASSED[*]:-none}"
echo "Failed: ${FAILED[*]:-none}"
echo ""
if [ ${#FAILED[@]} -gt 0 ]; then
exit 1
fi
+86
View File
@@ -0,0 +1,86 @@
#!/bin/bash
# Run integration tests against a specific ROS distro.
# Usage: ./tests/integration/scripts/run-tests.sh <distro> [module]
# Example: ./tests/integration/scripts/run-tests.sh noetic
# Example: ./tests/integration/scripts/run-tests.sh humble topics
set -e
cd "$(git rev-parse --show-toplevel)"
if [ -z "${1:-}" ]; then
MODULES=$(ls tests/integration/test_*.py 2>/dev/null \
| sed 's|tests/integration/test_||;s|\.py||' \
| grep -v quick_detect \
| tr '\n' ', ' | sed 's/,$//')
echo "Usage: $0 <distro> [module]"
echo "Distros: melodic, noetic, humble, jazzy"
echo "Modules: $MODULES"
exit 1
fi
DISTRO="$1"
MODULE="${2:-}"
COMPOSE="tests/integration/docker-compose.yml"
declare -A DOCKERFILES=(
[melodic]="Dockerfile.ros1-melodic"
[noetic]="Dockerfile.ros1-noetic"
[humble]="Dockerfile.ros2-humble"
[jazzy]="Dockerfile.ros2-jazzy"
)
declare -A CONTAINERS=(
[melodic]="integration-ros-melodic"
[noetic]="integration-ros-noetic"
[humble]="integration-ros2-humble"
[jazzy]="integration-ros2-jazzy"
)
DOCKERFILE="${DOCKERFILES[$DISTRO]}"
CONTAINER="${CONTAINERS[$DISTRO]}"
if [ -z "$DOCKERFILE" ]; then
echo "Unknown distro: $DISTRO"
echo "Valid options: melodic, noetic, humble, jazzy"
exit 1
fi
echo "=== Testing $DISTRO ==="
echo "Dockerfile: $DOCKERFILE"
echo "Container: $CONTAINER"
echo ""
# Tear down any previous container
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" down --volumes 2>/dev/null || true
# Build and start
echo "--- Starting container ---"
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" up --build -d --wait
# Run quick detect
echo ""
echo "--- Quick detect ---"
uv run python tests/integration/test_quick_detect.py
# Run pytest
echo ""
echo "--- Pytest ---"
if [ -n "$MODULE" ]; then
TEST_PATH="tests/integration/test_${MODULE}.py"
if [ ! -f "$TEST_PATH" ]; then
echo "Unknown module: $MODULE"
echo "Available: $(ls tests/integration/test_*.py | sed 's|tests/integration/test_||;s|\.py||' | tr '\n' ' ')"
exit 1
fi
uv run pytest "$TEST_PATH" -v --ros-distro "$DISTRO" --skip-compose
else
uv run pytest tests/integration/ -v --ros-distro "$DISTRO" --skip-compose
fi
# Tear down
echo ""
echo "--- Tearing down ---"
ROS_DOCKERFILE="$DOCKERFILE" ROS_CONTAINER_NAME="$CONTAINER" \
docker compose -f "$COMPOSE" down --volumes