@@ -38,6 +38,26 @@ def run(test_name: str, arguments: List[str], timeout=timeout) -> (int, str, str
38
38
return result .returncode , result .stdout , result .stderr
39
39
40
40
41
+ def popen (arguments : List [str ], user_input : str ) -> (int , str , str ):
42
+ # Start the process
43
+ executable_path = getExecutablePath ()
44
+ process = subprocess .Popen (
45
+ [executable_path ] + arguments ,
46
+ stdin = subprocess .PIPE ,
47
+ stdout = subprocess .PIPE ,
48
+ stderr = subprocess .PIPE ,
49
+ text = True , # This ensures the input and output are treated as text
50
+ )
51
+
52
+ # Send input and get output
53
+ stdout , stderr = process .communicate (input = user_input )
54
+
55
+ # Get the return code
56
+ return_code = process .returncode
57
+
58
+ return stdout , stderr , return_code
59
+
60
+
41
61
# Start the API server
42
62
# Wait for `Server started` message or failed
43
63
def start_server () -> bool :
@@ -50,10 +70,10 @@ def start_server() -> bool:
50
70
def start_server_nix () -> bool :
51
71
executable = getExecutablePath ()
52
72
process = subprocess .Popen (
53
- [executable ] + [' start' , '-p' , ' 3928' ],
54
- stdout = subprocess .PIPE ,
55
- stderr = subprocess .PIPE ,
56
- text = True
73
+ [executable ] + [" start" , "-p" , " 3928" ],
74
+ stdout = subprocess .PIPE ,
75
+ stderr = subprocess .PIPE ,
76
+ text = True ,
57
77
)
58
78
59
79
start_time = time .time ()
@@ -80,7 +100,7 @@ def start_server_nix() -> bool:
80
100
def start_server_windows () -> bool :
81
101
executable = getExecutablePath ()
82
102
process = subprocess .Popen (
83
- [executable ] + [' start' , '-p' , ' 3928' ],
103
+ [executable ] + [" start" , "-p" , " 3928" ],
84
104
stdout = subprocess .PIPE ,
85
105
stderr = subprocess .PIPE ,
86
106
text = True ,
0 commit comments