Skip to content

Commit ef0a6e3

Browse files
authored
Merge pull request #2255 from apple/🍒/bastille/2501e911a5a174fc1a07a2a1ac687a2bf0f05ef3
[lldb] Don't depend on psutil in TestCompletion.py
2 parents 74570a7 + 25f6bc3 commit ef0a6e3

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import os
88
from multiprocessing import Process
9-
import psutil
109
import lldb
1110
from lldbsuite.test.decorators import *
1211
from lldbsuite.test.lldbtest import *
@@ -119,6 +118,18 @@ def test_process_plugin_completion(self):
119118
self.complete_from_to('process ' + subcommand + ' mac',
120119
'process ' + subcommand + ' mach-o-core')
121120

121+
def completions_contain_str(self, input, needle):
122+
interp = self.dbg.GetCommandInterpreter()
123+
match_strings = lldb.SBStringList()
124+
num_matches = interp.HandleCompletion(input, len(input), 0, -1, match_strings)
125+
found_needle = False
126+
for match in match_strings:
127+
if needle in match:
128+
found_needle = True
129+
break
130+
self.assertTrue(found_needle, "Returned completions: " + "\n".join(match_strings))
131+
132+
122133
@skipIfRemote
123134
def test_common_completion_process_pid_and_name(self):
124135
# 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):
136147
self.complete_from_to('platform process attach -p ', [str(pid)])
137148
self.complete_from_to('platform process info ', [str(pid)])
138149

139-
pname = psutil.Process(pid).name() # FIXME: psutil doesn't work for remote
140-
self.complete_from_to('process attach -n ', [str(pname)])
141-
self.complete_from_to('platform process attach -n ', [str(pname)])
150+
self.completions_contain_str('process attach -n ', "a.out")
151+
self.completions_contain_str('platform process attach -n ', "a.out")
142152

143153
def test_process_signal(self):
144154
# The tab completion for "process signal" won't work without a running process.

0 commit comments

Comments
 (0)