asdf
1#!/usr/bin/env bash
2
3set -euo pipefail4IFS=$'\n\t'5
6print.info() {7printf '[INFO] %s\n' "$1"8}
9
10print.error() {11printf '[ERROR] %s\n' "$1" >&212}
13
14{
15repo_dir=$(git rev-parse --show-toplevel)16current_dir=$(pwd -P)17if [ "$repo_dir" != "$current_dir" ]; then18print.error "This scripts requires execution from the repository root directory."19printf "\t%s\t%s\n" "Repo root dir:" "$repo_dir"20printf "\t%s\t%s\n\n" "Current dir:" "$current_dir"21exit 122fi23}
24
25test_directory="./test"26bats_options=(--timing --print-output-on-failure)27
28if command -v parallel >/dev/null; then29# Enable parallel jobs30bats_options+=(--jobs 2 --no-parallelize-within-files)31elif [[ -n "${CI-}" ]]; then32print.error "GNU parallel should be installed in the CI environment. Please install and rerun the test suite."33exit 134else
35print.info "For faster test execution, install GNU parallel."36fi
37
38print.info "Running Bats in directory '${test_directory}' with options:" "${bats_options[@]}"39bats "${bats_options[@]}" "${test_directory}"40