File tree 1 file changed +15
-7
lines changed
1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 1
1
import glob
2
2
import runpy
3
- import signal
4
3
import subprocess
4
+ import time
5
5
from pathlib import Path
6
- from time import sleep
7
6
8
7
import pytest
9
8
12
11
13
12
@pytest .fixture (scope = "module" , autouse = True )
14
13
def sim_temperature_controller ():
15
- """Subprocess that runs ``tickit all <config_path>``."""
16
14
config_path : str = f"{ HERE } /../src/fastcs/demo/simulation/temp_controller.yaml"
17
- proc = subprocess .Popen (
15
+ process = subprocess .Popen (
18
16
["tickit" , "all" , config_path ],
19
17
stdout = subprocess .PIPE ,
20
18
stderr = subprocess .STDOUT ,
21
19
text = True ,
22
20
)
23
21
24
- sleep (1 )
22
+ TIMEOUT = 10
23
+ start_time = time .monotonic ()
24
+ while process .stdout is not None :
25
+ line = process .stdout .readline ()
26
+ if "Temperature controller running" in line :
27
+ break
28
+
29
+ if time .monotonic () - start_time > TIMEOUT :
30
+ raise TimeoutError ("Simulator did not start in time" )
31
+
32
+ time .sleep (0.1 )
25
33
26
34
yield
27
35
28
- proc . send_signal ( signal . SIGINT )
29
- print (proc .communicate ()[0 ])
36
+ process . kill ( )
37
+ print (process .communicate ()[0 ])
30
38
31
39
32
40
@pytest .mark .parametrize ("filename" , glob .glob ("docs/snippets/*.py" , recursive = True ))
You can’t perform that action at this time.
0 commit comments