diff --git a/script/test b/script/test index 5fda7cb2..bcc88e24 100755 --- a/script/test +++ b/script/test @@ -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