[Lldb-commits] [lldb] 2501e91 - [lldb] Don't depend on psutil in TestCompletion.py

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 24 23:30:50 PDT 2020


Author: Raphael Isemann
Date: 2020-08-25T08:30:33+02:00
New Revision: 2501e911a5a174fc1a07a2a1ac687a2bf0f05ef3

URL: https://github.com/llvm/llvm-project/commit/2501e911a5a174fc1a07a2a1ac687a2bf0f05ef3
DIFF: https://github.com/llvm/llvm-project/commit/2501e911a5a174fc1a07a2a1ac687a2bf0f05ef3.diff

LOG: [lldb] Don't depend on psutil in TestCompletion.py

psutil isn't reall a dependency of the test suite so this shouldn't be
unconditionally be imported here. Instead just check for the process name
by looking for the "a.out" string to get the bots green again.

Added: 
    

Modified: 
    lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py
index e2b003219a00..b80594b7568b 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -6,7 +6,6 @@
 
 import os
 from multiprocessing import Process
-import psutil
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -119,6 +118,18 @@ def test_process_plugin_completion(self):
             self.complete_from_to('process ' + subcommand + ' mac',
                                   'process ' + subcommand + ' mach-o-core')
 
+    def completions_contain_str(self, input, needle):
+        interp = self.dbg.GetCommandInterpreter()
+        match_strings = lldb.SBStringList()
+        num_matches = interp.HandleCompletion(input, len(input), 0, -1, match_strings)
+        found_needle = False
+        for match in match_strings:
+          if needle in match:
+            found_needle = True
+            break
+        self.assertTrue(found_needle, "Returned completions: " + "\n".join(match_strings))
+
+
     @skipIfRemote
     def test_common_completion_process_pid_and_name(self):
         # The LLDB process itself and the process already attached to are both
@@ -136,9 +147,8 @@ def test_common_completion_process_pid_and_name(self):
         self.complete_from_to('platform process attach -p ', [str(pid)])
         self.complete_from_to('platform process info ', [str(pid)])
 
-        pname = psutil.Process(pid).name()  # FIXME: psutil doesn't work for remote
-        self.complete_from_to('process attach -n ', [str(pname)])
-        self.complete_from_to('platform process attach -n ', [str(pname)])
+        self.completions_contain_str('process attach -n ', "a.out")
+        self.completions_contain_str('platform process attach -n ', "a.out")
 
     def test_process_signal(self):
         # The tab completion for "process signal"  won't work without a running process.


        


More information about the lldb-commits mailing list