<commit_before>function usage {
  cat <<-EOF
USAGE

  $0  [-dghv] [-f focus-string]

OPTIONS

  -h  print this message

  -d  run tests in a debugger (either lldb or gdb)

  -g  run tests with valgrind

  -v  run tests with verbose output

  -f  focus tests to those containing the substring

EOF
}

function run_tests {
  local debug
  local args
  local valgrind
  local target=$1
  local cmd="out/Default/${target}"
  shift

  while getopts "hdgvf:" option; do
    case ${option} in
      h)
        usage
        exit
        ;;
      d)
        debug=true
        ;;
      f)
        args="$args --only='${OPTARG}'"
        ;;
      v)
        args="$args --reporter=spec"
        ;;
      g)
        valgrind=true
        ;;
    esac
  done

  make $target

  if [[ -n $valgrind ]]; then
    eval valgrind \
      --suppressions=./etc/valgrind.supp \
      --dsymutil=yes \
      $cmd \
      $args 2>&1 | \
      grep --color -E '\w+_specs?.cc:\d+|$'

  elif [[ -n $debug ]]; then
    if which -s gdb; then
      eval gdb $cmd -- $args
    elif which -s lldb; then
      eval lldb $cmd -- $args
    else
      echo "No debugger found"
      exit 1
    fi

  else
    eval time $cmd $args
  fi
}<commit_msg>Don't use eval in test scripts<commit_after>function usage {
  cat <<-EOF
USAGE

  $0  [-dghv] [-f focus-string]

OPTIONS

  -h  print this message

  -d  run tests in a debugger (either lldb or gdb)

  -g  run tests with valgrind

  -v  run tests with verbose output

  -f  run only tests whose description contain the given string

EOF
}

function run_tests {
  local mode=normal
  local args=()
  local target=$1
  local cmd="out/Default/${target}"
  shift

  while getopts "df:ghv" option; do
    case ${option} in
      h)
        usage
        exit
        ;;
      d)
        mode=debug
        ;;
      g)
        mode=valgrind
        ;;
      f)
        args+=("--only=${OPTARG}")
        ;;
      v)
        args+=("--reporter=spec")
        ;;
    esac
  done

  make $target
  args=${args:-""}

  case ${mode} in
    valgrind)
      valgrind \
        --suppressions=./etc/valgrind.supp \
        --dsymutil=yes \
        $cmd "${args[@]}" 2>&1 | \
        grep --color -E '\w+_specs?.cc:\d+|$'
      ;;

    debug)
      if which -s gdb; then
        gdb $cmd -- "${args[@]}"
      elif which -s lldb; then
        lldb $cmd -- "${args[@]}"
      else
        echo "No debugger found"
        exit 1
      fi
      ;;

    normal)
      time $cmd "${args[@]}"
      ;;
  esac
}
{'fraction_non_alphanumeric': 0.13019169329073482, 'fraction_numerical': 0.003993610223642172, 'mean_word_length': 1.609375, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4592286', 'n_tokens_mistral': 918, 'n_tokens_neox': 871, 'n_words': 263}