[Lldb-commits] [PATCH] D126217: [lldb] Improve TestAppleSimulatorOSType.py error message

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon May 23 09:17:19 PDT 2022


JDevlieghere created this revision.
JDevlieghere added reviewers: augusto2112, jingham.
Herald added a project: All.
JDevlieghere requested review of this revision.

Show a more informative error message when we fail to parse the simctl output. It was inspired by https://reviews.llvm.org/D109336 which got reverted because we didn't want to silently fail.


https://reviews.llvm.org/D126217

Files:
  lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py


Index: lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
===================================================================
--- lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -17,9 +17,13 @@
 
     def check_simulator_ostype(self, sdk, platform_name, arch=platform.machine()):
         cmd = ['xcrun', 'simctl', 'list', '-j', 'devices']
-        self.trace(' '.join(cmd))
+        cmd_str = ' '.join(cmd)
+        self.trace(cmd_str)
         sim_devices_str = subprocess.check_output(cmd).decode("utf-8")
-        sim_devices = json.loads(sim_devices_str)['devices']
+        try:
+            sim_devices = json.loads(sim_devices_str)['devices']
+        except json.decoder.JSONDecodeError:
+            self.fail("Could not parse '{}' output. Authorization denied?".format(cmd_str))
         # Find an available simulator for the requested platform
         deviceUDID = None
         deviceRuntime = None


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126217.431399.patch
Type: text/x-patch
Size: 1001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220523/307df582/attachment-0001.bin>


More information about the lldb-commits mailing list