Skip to content

Commit b99f29a

Browse files
committed
Extract spawn helper
1 parent bbcb58a commit b99f29a

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212

1313

1414
class TestDAP_attach(lldbdap_testcase.DAPTestCaseBase):
15-
def spawn_and_wait(self, program, delay):
16-
time.sleep(delay)
15+
def spawn(self, args):
1716
self.process = subprocess.Popen(
18-
[program],
17+
args,
1918
stdin=subprocess.PIPE,
2019
stdout=subprocess.PIPE,
2120
stderr=subprocess.PIPE,
2221
universal_newlines=True,
2322
)
23+
24+
def spawn_and_wait(self, program, delay):
25+
time.sleep(delay)
26+
self.spawn([program])
2427
self.process.wait()
2528

2629
def continue_and_verify_pid(self):
@@ -33,13 +36,7 @@ def test_by_pid(self):
3336
Tests attaching to a process by process ID.
3437
"""
3538
program = self.build_and_create_debug_adapter_for_attach()
36-
self.process = subprocess.Popen(
37-
[program],
38-
stdin=subprocess.PIPE,
39-
stdout=subprocess.PIPE,
40-
stderr=subprocess.PIPE,
41-
universal_newlines=True,
42-
)
39+
self.spawn([program])
4340
self.attach(pid=self.process.pid)
4441
self.continue_and_verify_pid()
4542

@@ -53,13 +50,7 @@ def test_by_name(self):
5350
pid_file_path = lldbutil.append_to_process_working_directory(
5451
self, "pid_file_%d" % (int(time.time()))
5552
)
56-
self.process = subprocess.Popen(
57-
[program, pid_file_path],
58-
stdin=subprocess.PIPE,
59-
stdout=subprocess.PIPE,
60-
stderr=subprocess.PIPE,
61-
universal_newlines=True,
62-
)
53+
self.spawn([program, pid_file_path])
6354
lldbutil.wait_for_file_on_target(self, pid_file_path)
6455

6556
self.attach(program=program)

0 commit comments

Comments
 (0)