This patch improves the user experience when building out of tree, using
run_python_bt2, but forgetting to set BT_TESTS_BUILDDIR.
Currently, the script doesn't complain when you do this, but sets
variables (e.g. PYTHONPATH) to point to files/directories that don't
exist:
$ /home/simark/src/babeltrace/tests/utils/run_python_bt2 python3
>>> import bt2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'bt2'
With this patch, the user gets notified that they did something wrong:
/home/simark/src/babeltrace/tests/utils/run_python_bt2: BT_TESTS_BUILDDIR does
not point to a valid directory
(/home/simark/src/babeltrace/tests/utils/../utils/../Makefile does not exist).
If building out-of-tree, set BT_TESTS_BUILDDIR to point to the tests directory
in the build tree.
Change-Id: Ibbc6e11b6cbfce560ad97081d709ed4794c406b1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1583
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
if [ "x$*" = "x" ]; then
usage
if [ "x$*" = "x" ]; then
usage
-else
- run_python_bt2 "${@}"
+
+# Sanity check that the BT_TESTS_BUILDDIR value makes sense.
+if [ ! -f "$BT_TESTS_BUILDDIR/Makefile" ]; then
+ fold -w 80 -s <<- END
+ $0: BT_TESTS_BUILDDIR does not point to a valid directory (\`$BT_TESTS_BUILDDIR/Makefile\` does not exist).
+
+ If building out-of-tree, set BT_TESTS_BUILDDIR to point to the \`tests\` directory in the build tree.
+ END
+ exit 1
+fi
+
+run_python_bt2 "${@}"