test: add unit testing for point.h to CI workflow

This commit is contained in:
2025-11-08 21:57:23 +01:00
parent 60a210ab0f
commit aee965c84d
5 changed files with 97 additions and 2 deletions
+30 -2
View File
@@ -1,4 +1,5 @@
FROM ubuntu:24.04
# Base builder
FROM ubuntu:24.04 AS base
ENV DEBIAN_FRONTEND=noninteractive
@@ -32,6 +33,33 @@ RUN make install
WORKDIR /app
COPY src/occt/ ./src
COPY unit-test/occt/ ./unit-test
COPY test/occt/ ./test
RUN cmake -S src -B build -DCMAKE_PREFIX_PATH=/usr/local && cmake --build build
COPY test/occt/ ./test
# Unit test runner
FROM ubuntu:24.04 AS unit-testing
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
catch2 \
xvfb \
&& rm -rf /var/lib/apt/lists/*
COPY --from=base /usr/local /usr/local
COPY --from=base /app/build /app/build
COPY --from=base /app/src /app/src
COPY --from=base /app/test /app/test
WORKDIR /app
RUN cmake -S test -B build/tests -DCMAKE_PREFIX_PATH=/usr/local
RUN cmake --build build/tests
CMD ["ctest", "--test-dir", "build/tests", "-V"]
+14
View File
@@ -6,6 +6,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_PATH="$(cd "$SCRIPT_DIR/../../" && pwd)"
DOCKERFILE_PATH="$SCRIPT_DIR/../occt.Dockerfile"
# Check for --unit-testing argument
RUN_UNIT_TESTS=false
if [[ "${1-}" == "--unit-testing" ]]; then
RUN_UNIT_TESTS=true
fi
echo "Building image..."
if ! docker build -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" "$PROJECT_PATH"; then
echo "Image build failed." >&2
@@ -17,3 +23,11 @@ if ! docker run --rm "$IMAGE_NAME" ls /usr/local/bin; then
echo "Listing /usr/local/bin failed." >&2
exit 1
fi
if [ "$RUN_UNIT_TESTS" = true ]; then
echo "Running unit tests..."
if ! docker run --rm "$IMAGE_NAME" ctest --test-dir /app/build/unit-tests -V; then
echo "Unit tests failed." >&2
exit 1
fi
fi