#!/bin/bash set -u GREEN="\e[0;32m" YELLOW="\e[0;33m" RED="\e[0;31m" END="\e[0m" usage () { cat <|--arg ] [] Run various commands to test bst. Commands: test Run the test suite. If no arguments are given, the full suite is run, otherwise the given arguments will be run run Run the test suite. (Does not clean) clean Clean temporary test files Options: --help Display this help message and exit --arg Specify an argument for bst, such as --colors --cov Specify a coverage rcfile --sources Specify a location for the source cache EOF } BST_COVERAGE= BST_FLAGS= BST_SOURCE_CACHE= export BST_COVERAGE export BST_FLAGS export BST_SOURCE_CACHE main () { while : ; do case "${1:-}" in "test") shift configure clean "$@" run "$@" break ;; "run") shift configure run "$@" break ;; "clean") shift clean "$@" break ;; --sources) export BST_SOURCE_CACHE=$(realpath -m "${2}") shift 2 ;; -c|--cov) export BST_COVERAGE=$(realpath -m "${2}") shift 2 ;; -a|--arg) export BST_FLAGS="${BST_FLAGS:-} $2" shift 2 ;; -h|--help) usage break ;; *) echo "Error: Unrecognized argument '${1:-}'" 1>&2 usage break ;; esac done } # configure # # Creates the buildstream.conf configuration configure () { # Treat source cache specially, we want to reuse it when # running automated CI if [ -z "${BST_SOURCE_CACHE}" ]; then BST_SOURCE_CACHE="$(pwd)/tmp/sources" fi # Create buildstream.conf cat > "$(pwd)/buildstream.conf" <&1 return 1 fi } main "$@"