#!/bin/bash # This file is made to support the unit tests workflow. # It should only require the directories build/tests, scripts/, and tests/ to function, # and cmake (with ctest) installed. # (otherwise, update the workflow too, but try to avoid to keep things self-contained) # # Usage: run_unit_tests.sh [TEST_DIR] [BUILD_CONFIG] # TEST_DIR directory containing the built tests (default: build/tests) # BUILD_CONFIG configuration to run; required for multi-config generators, which all # build scripts use (build_linux.sh too: Ninja Multi-Config). Without it, # tests registered with plain add_test() lose their labels and report "Not Run". ROOT_DIR="$(dirname "$0")/.." cd "${ROOT_DIR}" || exit 1 TEST_DIR="${1:-build/tests}" BUILD_CONFIG="${2:-}" # Run the whole suite, excluding tests tagged [NotWorking] and tests labelled RequiresApp, # which run the built orca-slicer binary that this directory does not contain. # --no-tests=error fails the job if the filter matches nothing (instead of passing green). args=(--test-dir "${TEST_DIR}" -LE "NotWorking|RequiresApp" --no-tests=error --output-junit "$(pwd)/ctest_results.xml" --output-on-failure -j) [ -n "${BUILD_CONFIG}" ] && args+=(--build-config "${BUILD_CONFIG}") ctest "${args[@]}"