#! /usr/bin/env bash set -o pipefail cmd=$1 shift function usage { cat < Stages build Configure and build the code test Run tests EOF exit 1 } function run_build { mkdir build ( cd build if command -v cmake3 >/dev/null 2>&1; then cmake3 .. else cmake .. fi make ) } function run_tests { make test local res=$? ( cd testing && [[ -d .tmp ]] && tar -czf tmp.tar.gz .tmp ) return $res } test -n "${cmd}" || usage if [ -e btest.venv ]; then # shellcheck disable=SC1091 . btest.venv/bin/activate fi case "${cmd}" in build) run_build $@ ;; test) run_tests $@ ;; *) usage ;; esac