#!/usr/bin/env bash set -euo pipefail # This must be run from the cccl repo root, but the script may be relocated by git_bisect.sh. # Check that the current directory looks like the repo root: if [[ ! -f "./cccl-version.json" ]]; then echo "This script must be run from the cccl repo root." exit 1 fi usage() { cat <&2; usage; exit 2 ;; esac done if [[ -z "${PRESET}" && -z "${CONFIGURE_OVERRIDE}" ]]; then echo "::error:: --preset or --configure-override is required" >&2 usage exit 2 fi if [[ -n "${CONFIGURE_OVERRIDE}" ]]; then if [[ -n "${PRESET}" ]]; then echo "::warning:: --preset ignored due to --configure-override" >&2 fi if [[ "${#CMAKE_OPTIONS[@]}" -gt 0 ]]; then echo "::warning:: --cmake-options ignored due to --configure-override" >&2 fi fi echo "::group::โš™๏ธ Testing $(git log --oneline | head -n1)" # Configure and parse the build directory from CMake output BUILD_DIR="" cmlog_file="$(mktemp /tmp/cmake-config-XXXXXX.log)" if [[ -n "${CONFIGURE_OVERRIDE}" ]]; then if ! (set -x; eval "${CONFIGURE_OVERRIDE}") 2>&1 | tee "${cmlog_file}"; then echo "::endgroup::" echo -e "๐Ÿ”ด๐Ÿ“ Configuration override failed ($(elapsed_time)):\n\t${CONFIGURE_OVERRIDE}" exit 1 fi else if ! (set -x; cmake --preset "${PRESET}" "${CMAKE_OPTIONS[@]}") 2>&1 | tee "${cmlog_file}"; then echo "::endgroup::" echo "๐Ÿ”ด๐Ÿ“ CMake configure failed for preset ${PRESET} ($(elapsed_time))" exit 1 fi fi BUILD_DIR=$(awk -F': ' '/-- Build files have been written to:/ {print $2}' "${cmlog_file}" | tail -n1) if [[ -z "${BUILD_DIR}" ]]; then echo "::endgroup::" echo "๐Ÿ”ดโ€ผ๏ธ Unable to determine build directory ($(elapsed_time))" exit 1 fi if [[ "${#BUILD_TARGETS[@]}" -gt 0 ]]; then if ! (set -x; ninja -C "${BUILD_DIR}" "${BUILD_TARGETS[@]}"); then echo "::endgroup::" echo "๐Ÿ”ด๐Ÿ› ๏ธ Ninja build failed for targets ($(elapsed_time)): ${BUILD_TARGETS[*]@Q}" exit 1 fi fi if [[ "${#CTEST_TARGETS[@]}" -gt 0 ]]; then for t in "${CTEST_TARGETS[@]}"; do if ! (set -x; ctest --test-dir "${BUILD_DIR}" -R "$t" -V --output-on-failure); then echo "::endgroup::" echo "๐Ÿ”ด๐Ÿ”Ž CTest failed for target $t ($(elapsed_time))" exit 1 fi done fi if [[ "${#LIT_PRECOMPILE_TESTS[@]}" -gt 0 || "${#LIT_TESTS[@]}" -gt 0 ]]; then lit_site_cfg="${BUILD_DIR}/libcudacxx/test/libcudacxx/lit.site.cfg" if [[ ! -f "${lit_site_cfg}" ]]; then echo "::endgroup::" echo "๐Ÿ”ด๐Ÿงช LIT site config not found ($(elapsed_time)): ${lit_site_cfg}" exit 1 fi fi if [[ "${#LIT_PRECOMPILE_TESTS[@]}" -gt 0 ]]; then for t in "${LIT_PRECOMPILE_TESTS[@]}"; do t_path="libcudacxx/test/libcudacxx/${t}" if ! (set -x; LIBCUDACXX_SITE_CONFIG="${lit_site_cfg}" lit -v "-Dexecutor=NoopExecutor()" "${t_path}"); then echo "::endgroup::" echo "๐Ÿ”ด๐Ÿงช LIT precompile failed ($(elapsed_time)): ${t}" exit 1 fi done fi if [[ "${#LIT_TESTS[@]}" -gt 0 ]]; then for t in "${LIT_TESTS[@]}"; do t_path="libcudacxx/test/libcudacxx/${t}" if ! (set -x; LIBCUDACXX_SITE_CONFIG="${lit_site_cfg}" lit -v "${t_path}"); then echo "::endgroup::" echo "๐Ÿ”ด๐Ÿงช LIT test failed ($(elapsed_time)): ${t}" exit 1 fi done fi if [[ -n "${CUSTOM_TEST_CMD}" ]]; then if ! (set -x; eval "${CUSTOM_TEST_CMD}"); then echo "::endgroup::" echo "๐Ÿ”ด๐Ÿงช Custom test command failed ($(elapsed_time)): ${CUSTOM_TEST_CMD}" exit 1 fi fi echo "::endgroup::" echo "๐ŸŸขโœ… Passed ($(elapsed_time))" exit 0