[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 21 04:15:24 PDT 2021


DavidSpickett added a reviewer: DavidSpickett.
DavidSpickett added inline comments.


================
Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1284
         compiler = self.getCompilerBinary()
-        version_output = system([[compiler, "--version"]])
-        for line in version_output.split(os.linesep):
-            m = re.search('version ([0-9.]+)', line)
-            if m:
-                return m.group(1)
+        version_output = check_output([compiler, "--version"])
+        m = re.search(b'version ([0-9.]+)', version_output)
----------------
You could use `universal_newlines` here to get the decoded string. It's a bit cryptic but saves the decode below.

There is an alias `text` name in 3.7 but requiring that seems ambitious.


================
Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1425
+            try:
+                proc = run(cmd, stdin=DEVNULL, stdout=PIPE, stderr=STDOUT,
+                        check=True)
----------------
labath wrote:
> PSA: this function is available from python-3.5 onwards.
Any reason to use `run(...check=True)` rather than `check_call`?

https://docs.python.org/3/library/subprocess.html#subprocess.check_call

(`universal_newlines` applies here too if you want)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112212/new/

https://reviews.llvm.org/D112212



More information about the lldb-commits mailing list