Adding the `bt_` prefix like other functions in `utils.sh` and renaming
the rest to indicate that it runs something in a specific environment,
not necessarily Python itself.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I011c837857eb6d2b08f0c0064d399fd3acc2b89d
# start server
diag "$BT_TESTS_PYTHON_BIN $server_script ${server_args[*]}"
# start server
diag "$BT_TESTS_PYTHON_BIN $server_script ${server_args[*]}"
- run_python "$BT_TESTS_PYTHON_BIN" "$server_script" "${server_args[@]}" 1>&2 &
+ bt_run_in_py_utils_env "$BT_TESTS_PYTHON_BIN" "$server_script" "${server_args[@]}" 1>&2 &
# write PID to file
echo $! > "$pid_file"
# write PID to file
echo $! > "$pid_file"
# Major and minor version of the `python3` command to use when testing.
#
# This doesn't need to be exported, but it needs to remain set for
# Major and minor version of the `python3` command to use when testing.
#
# This doesn't need to be exported, but it needs to remain set for
-# run_python() to use it.
+# bt_run_in_py_utils_env() to use it.
_bt_tests_py3_version=$("$BT_TESTS_PYTHON_BIN" -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))')
# Name of the `python3-config` command to use when testing, if not set
_bt_tests_py3_version=$("$BT_TESTS_PYTHON_BIN" -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))')
# Name of the `python3-config` command to use when testing, if not set
# Executes a command within an environment which can import the testing
# Python modules (in `tests/utils/python`).
# Executes a command within an environment which can import the testing
# Python modules (in `tests/utils/python`).
+bt_run_in_py_utils_env() {
local our_pythonpath=$BT_TESTS_SRCDIR/utils/python
if [[ $_bt_tests_py3_version =~ 3.[45] ]]; then
local our_pythonpath=$BT_TESTS_SRCDIR/utils/python
if [[ $_bt_tests_py3_version =~ 3.[45] ]]; then
local -x ASAN_OPTIONS=${ASAN_OPTIONS:-}${ASAN_OPTIONS:+,}detect_leaks=0
fi
local -x ASAN_OPTIONS=${ASAN_OPTIONS:-}${ASAN_OPTIONS:+,}detect_leaks=0
fi
+ bt_run_in_py_utils_env "$@"
}
# Runs the Python tests matching the pattern `$2` (optional, `*` if
}
# Runs the Python tests matching the pattern `$2` (optional, `*` if
)
echo "Running: \`${cmd[*]}\`" >&2
)
echo "Running: \`${cmd[*]}\`" >&2
+ bt_run_in_py_utils_env "${cmd[@]}"