diff --git a/Dockerfile b/Dockerfile index f5bf435a..f6ac36f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,3 +40,17 @@ USER blinky WORKDIR /home/blinky/ +FROM base AS unittest + +# Build unit tests +RUN mkdir /tmp/arbitration_graphs/build && \ + cd /tmp/arbitration_graphs/build && \ + cmake -DBUILD_TESTS=true .. && \ + cmake --build . + +# Run unit tests +# Return with non-zero exit code if a test fails +# See https://unix.stackexchange.com/a/392973 for reference +CMD find /tmp/arbitration_graphs/build -type f -executable -name '*-gtest-*' -exec \ + sh -c 'for test; do echo "Running test: $test"; $test || exit 1; done' _ {} + +