Make it easy to build with address sanitizer in test script

This commit is contained in:
Max Brunsfeld 2020-05-18 10:48:47 -07:00
parent 37ee7acc9e
commit 7b39420de3

View file

@ -37,12 +37,26 @@ export RUST_BACKTRACE=full
mode=normal
while getopts "dDghl:e:s:t:" option; do
# Specify a `--target` explicitly. For some reason, this is required for
# address sanitizer support.
toolchain=$(rustup show active-toolchain)
toolchain_regex='(stable|beta|nightly)-([_a-z0-9-]+).*'
if [[ $toolchain =~ $toolchain_regex ]]; then
release=${BASH_REMATCH[1]}
current_target=${BASH_REMATCH[2]}
else
echo "Failed to parse toolchain '${toolchain}'"
fi
while getopts "adDghl:e:s:t:" option; do
case ${option} in
h)
usage
exit
;;
a)
export RUSTFLAGS="-Z sanitizer=address"
;;
l)
export TREE_SITTER_TEST_LANGUAGE_FILTER=${OPTARG}
;;
@ -82,5 +96,5 @@ if [[ "${mode}" == "debug" ]]; then
)
lldb "${test_binary}" -- $top_level_filter
else
cargo test -p tree-sitter-cli --jobs 1 $top_level_filter -- --nocapture
cargo test --target=${current_target} -p tree-sitter-cli --jobs 1 $top_level_filter -- --nocapture
fi