#!/usr/bin/env bash set -e function usage { cat <&2 fi test_flags+=("--target=$current_target") ;; e) export TREE_SITTER_EXAMPLE=${OPTARG} ;; s) export TREE_SITTER_SEED=${OPTARG} ;; i) export TREE_SITTER_ITERATIONS=${OPTARG} ;; d) export TREE_SITTER_LOG=1 ;; D) export TREE_SITTER_LOG_GRAPHS=1 ;; g) mode=debug ;; *) usage exit 1 ;; esac done shift $((OPTIND - 1)) if [[ ${mode} == debug ]]; then test_binary=$( cargo test "${test_flags[@]}" --no-run --message-format=json 2> /dev/null | jq -rs 'map(select(.target.name == "tree-sitter-cli" and .executable))[0].executable' ) lldb "${test_binary}" -- "$1" else cargo test "${test_flags[@]}" "$1" -- --nocapture fi