run-in-py-utils-bt2-env.sh: use `[[ ... ]]` instead of `[` or `test`
[babeltrace.git] / tests / utils / run-in-py-env.sh
CommitLineData
644e0364
MJ
1#!/bin/bash
2#
0235b0db
MJ
3# SPDX-License-Identifier: GPL-2.0-only
4#
b566b220 5# Copyright (C) 2017-2023 Philippe Proulx <pproulx@efficios.com>
644e0364 6# Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
644e0364 7
7f03322d 8if [[ -n "${BT_TESTS_SRCDIR:-}" ]]; then
644e0364
MJ
9 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
10else
11 UTILSSH="$(dirname "$0")/../utils/utils.sh"
12fi
13
14# shellcheck source=../utils/utils.sh
15source "$UTILSSH"
16
17usage() {
b566b220 18 echo "Usage: run-in-py-utils-bt2-env.sh COMMAND [ARGS]..."
644e0364 19 echo ""
b566b220
PP
20 echo "Runs the command \`COMMAND\` with the arguments \`ARGS\` within an environment"
21 echo "which can import the testing Python modules (in \`tests/utils/python\`) and the"
22 echo "built \`bt2\` Python package."
644e0364 23 echo ""
b566b220
PP
24 echo "NOTE: If you build out of tree, export and set the \`BT_TESTS_BUILDDIR\`"
25 echo "environment variable to the built \`tests\` directory."
644e0364
MJ
26}
27
7f03322d 28if [[ -z "$*" ]]; then
644e0364 29 usage
b841eced 30 exit 1
644e0364 31fi
b841eced
SM
32
33# Sanity check that the BT_TESTS_BUILDDIR value makes sense.
7f03322d 34if [[ ! -f "$BT_TESTS_BUILDDIR/Makefile" ]]; then
b841eced
SM
35 fold -w 80 -s <<- END
36 $0: BT_TESTS_BUILDDIR does not point to a valid directory (\`$BT_TESTS_BUILDDIR/Makefile\` does not exist).
37
38 If building out-of-tree, set BT_TESTS_BUILDDIR to point to the \`tests\` directory in the build tree.
39 END
40 exit 1
41fi
42
31d2049b 43bt_run_in_py_env "${@}"
This page took 0.056512 seconds and 4 git commands to generate.