Louis Dionne | 0c7b6eb | 2023-04-18 13:25:16 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | PROGNAME="$(basename "${0}")" |
| 6 | function usage() { |
| 7 | cat <<EOF |
| 8 | Usage: |
Will Hawkins | fb9917d | 2023-09-07 12:05:07 -0400 | [diff] [blame] | 9 | ${PROGNAME} [-h|--help] [-b|--bootstrap] <build-directory> [lit options...] tests... |
Louis Dionne | 0c7b6eb | 2023-04-18 13:25:16 +0000 | [diff] [blame] | 10 | |
| 11 | Shortcut to build the libc++ testing dependencies and run the libc++ tests with Lit. |
| 12 | |
Will Hawkins | fb9917d | 2023-09-07 12:05:07 -0400 | [diff] [blame] | 13 | [-b|--bootstrap] Configure tests to run against a bootstrap build of libcxx. |
Louis Dionne | 0c7b6eb | 2023-04-18 13:25:16 +0000 | [diff] [blame] | 14 | <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 Dionne | 8d99d79 | 2023-05-08 08:59:01 -0400 | [diff] [blame] | 16 | tests... Paths of the tests to run. Those paths are relative to '<monorepo-root>'. |
Louis Dionne | 0c7b6eb | 2023-04-18 13:25:16 +0000 | [diff] [blame] | 17 | |
| 18 | Example |
| 19 | ======= |
| 20 | $ cmake -S runtimes -B build/ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" |
| 21 | $ libcxx-lit build/ -sv libcxx/test/std/utilities/ |
| 22 | EOF |
| 23 | } |
| 24 | |
Will Hawkins | fb9917d | 2023-09-07 12:05:07 -0400 | [diff] [blame] | 25 | type="cxx" |
| 26 | if [[ "${1}" == "-h" || "${1}" == "--help" ]]; then |
| 27 | usage |
| 28 | exit 0 |
| 29 | fi |
| 30 | |
| 31 | if [[ "${1}" == "-b" || "${1}" == "--bootstrap" ]]; then |
| 32 | type="runtimes" |
Louis Dionne | ac40af1 | 2024-07-09 11:18:20 -0400 | [diff] [blame] | 33 | shift |
Will Hawkins | fb9917d | 2023-09-07 12:05:07 -0400 | [diff] [blame] | 34 | fi |
Louis Dionne | 0c7b6eb | 2023-04-18 13:25:16 +0000 | [diff] [blame] | 35 | |
| 36 | if [[ $# -lt 1 ]]; then |
| 37 | usage |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
| 41 | build_dir="${1}" |
| 42 | shift |
| 43 | |
Will Hawkins | fb9917d | 2023-09-07 12:05:07 -0400 | [diff] [blame] | 44 | if [[ "${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." |
| 47 | fi |
| 48 | cmake --build "${build_dir}" --target ${type}-test-depends |
Louis Dionne | 0c7b6eb | 2023-04-18 13:25:16 +0000 | [diff] [blame] | 49 | "${build_dir}/bin/llvm-lit" ${@} |