Add a helper run_lit.sh for interactive debugging.

pull/1/head
Stella Laurenzo 2020-04-26 18:41:44 -07:00
parent 953ef89a30
commit f514bd533d
1 changed files with 35 additions and 0 deletions

35
tools/run_lit.sh 100755
View File

@ -0,0 +1,35 @@
#!/bin/bash
# Runs lit-based tests by properly translating paths to the build directory.
# Example:
# ./tools/run_lit.sh test/Dialect -v
set -e
td="$(realpath $(dirname $0)/..)"
build_dir="$td/build"
install_mlir="$td/install-mlir"
build_mlir="$td/build-mlir"
lit_exe="$build_mlir/bin/llvm-lit"
if ! [ -f "$lit_exe" ]; then
echo "Could not find lit: $lit_exe"
exit 1
fi
declare -a lit_args
for i in "$@"; do
if [[ ${i:0:1} = "-" ]] || [[ ${i:0:1} = "/" ]]; then
lit_args+=("$i")
else
if ! [ -e "$i" ]; then
echo "Specified lit input does not exist: $i"
exit 1
fi
test_local_path="$(realpath $i)"
# Replace the src prefix with the build dir.
test_build_path="$build_dir/${test_local_path##$td/}"
lit_args+=("$test_build_path")
fi
done
set -x
cd $build_dir/test && python3 "$lit_exe" ${lit_args[@]}