blob: a032f5d062a354c51b85c78e409d437decfbfc2a [file] [log] [blame]
Louis Dionne0c7b6eb2023-04-18 13:25:16 +00001#!/usr/bin/env bash
2
3set -e
4
5PROGNAME="$(basename "${0}")"
6function usage() {
7cat <<EOF
8Usage:
Will Hawkinsfb9917d2023-09-07 12:05:07 -04009${PROGNAME} [-h|--help] [-b|--bootstrap] <build-directory> [lit options...] tests...
Louis Dionne0c7b6eb2023-04-18 13:25:16 +000010
11Shortcut to build the libc++ testing dependencies and run the libc++ tests with Lit.
12
Will Hawkinsfb9917d2023-09-07 12:05:07 -040013[-b|--bootstrap] Configure tests to run against a bootstrap build of libcxx.
Louis Dionne0c7b6eb2023-04-18 13:25:16 +000014<build-directory> The path to the build directory to use for building the library.
15[lit options...] Optional options to pass to 'llvm-lit'.
Louis Dionne8d99d792023-05-08 08:59:01 -040016tests... Paths of the tests to run. Those paths are relative to '<monorepo-root>'.
Louis Dionne0c7b6eb2023-04-18 13:25:16 +000017
18Example
19=======
20$ cmake -S runtimes -B build/ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"
21$ libcxx-lit build/ -sv libcxx/test/std/utilities/
22EOF
23}
24
Will Hawkinsfb9917d2023-09-07 12:05:07 -040025type="cxx"
26if [[ "${1}" == "-h" || "${1}" == "--help" ]]; then
27 usage
28 exit 0
29fi
30
31if [[ "${1}" == "-b" || "${1}" == "--bootstrap" ]]; then
32 type="runtimes"
Louis Dionneac40af12024-07-09 11:18:20 -040033 shift
Will Hawkinsfb9917d2023-09-07 12:05:07 -040034fi
Louis Dionne0c7b6eb2023-04-18 13:25:16 +000035
36if [[ $# -lt 1 ]]; then
37 usage
38 exit 1
39fi
40
41build_dir="${1}"
42shift
43
Will Hawkinsfb9917d2023-09-07 12:05:07 -040044if [[ "${type}" == "runtimes" ]]; then
45 echo "N.B.: In a bootstrap build, lit needs a prefix to work correctly;"
46 echo " See libcxx/docs/Testinglibcxx.rst for more information."
47fi
48cmake --build "${build_dir}" --target ${type}-test-depends
Louis Dionne0c7b6eb2023-04-18 13:25:16 +000049"${build_dir}/bin/llvm-lit" ${@}