git » libfiu » commit cf38594

tests: Add a verbose option for wrap-python

author Alberto Bertogli
2020-03-28 15:43:14 UTC
committer Alberto Bertogli
2020-03-28 15:43:14 UTC
parent d107e96be8f82c35c0cab9ce2b0acd3de173d56e

tests: Add a verbose option for wrap-python

When debugging python tests, it can be convenient to invoke the Python
interpreter directly, for example to run it under gdb or valgrind.

This patch adds a verbose option to wrap-python so it shows an equivalent
command line to execute manually.

tests/wrap-python +10 -1

diff --git a/tests/wrap-python b/tests/wrap-python
index d0c2153..f35e334 100755
--- a/tests/wrap-python
+++ b/tests/wrap-python
@@ -10,12 +10,16 @@ import os
 import glob
 
 
-if len(sys.argv) < 2 or sys.argv[1] not in ("2", "3"):
+if len(sys.argv) < 2 or sys.argv[1] not in ("2", "2v", "3", "3v"):
 	sys.stderr.write("Error: the first argument must be the " +
 				"version (2 or 3)\n")
 	sys.exit(1)
 
 py_ver = sys.argv[1]
+verbose = False
+if py_ver[-1] == "v":
+    verbose = True
+    py_ver = py_ver[:-1]
 
 
 # Find the path where the library was built and add it to the lookup paths, so
@@ -55,5 +59,10 @@ if py_ver == '2':
 else:
 	py_bin = "python3"
 
+if verbose:
+    print("LD_LIBRARY_PATH=%s" % os.environ["LD_LIBRARY_PATH"],
+        "PYTHONPATH=%s" % os.environ["PYTHONPATH"],
+        py_bin, " ".join(sys.argv[2:]))
+
 os.execvp(py_bin, [py_bin] + sys.argv[2:])