2020-04-27 09:41:44 +08:00
|
|
|
#!/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"
|
2020-09-18 06:35:47 +08:00
|
|
|
build_mlir="$td/external/llvm-project/build"
|
2020-04-27 09:41:44 +08:00
|
|
|
|
|
|
|
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
|
2020-04-29 11:32:49 +08:00
|
|
|
cd $build_dir
|
2020-09-18 06:35:47 +08:00
|
|
|
ninja npcomp-opt npcomp-run-mlir NPCOMPCompilerRuntimeShlib NPCOMPNativePyExt
|
2020-04-29 11:32:49 +08:00
|
|
|
cd test && python3 "$lit_exe" ${lit_args[@]}
|