@@ -75,6 +75,12 @@ def __init__(self, parser=None):
7575 default = - 1 ,
7676 help = "Maximum isolated robot processes (default: max CPUs - 1)" ,
7777 )
78+ parser .add_argument (
79+ "--init-timeout" ,
80+ type = float ,
81+ default = None ,
82+ help = "Seconds to wait for robot to start (can be set in `tool.robotpy.pyfrc.init_timeout` also)" ,
83+ )
7884
7985 def run (
8086 self ,
@@ -87,6 +93,7 @@ def run(
8793 verbose : bool ,
8894 pytest_args : typing .List [str ],
8995 jobs : int ,
96+ init_timeout : typing .Optional [float ],
9097 ):
9198 if isolated is None :
9299 pyproject_path = project_path / "pyproject.toml"
@@ -106,6 +113,26 @@ def run(
106113
107114 isolated = v
108115
116+ try :
117+ v = d ["tool" ]["robotpy" ]["pyfrc" ]["init_timeout" ]
118+ except KeyError :
119+ pass
120+ else :
121+ if not isinstance (v , (int , float )):
122+ raise ValueError (
123+ f"tool.robotpy.pyfrc.init_timeout must be a number (got { v } )"
124+ )
125+ elif not (v > 0 ):
126+ raise ValueError (
127+ f"tool.robotpy.pyfrc.init_timeout must be a positive number (got { v } )"
128+ )
129+
130+ if init_timeout is None :
131+ init_timeout = float (v )
132+
133+ if init_timeout is None :
134+ init_timeout = 2.0
135+
109136 if isolated is None :
110137 isolated = True
111138
@@ -120,6 +147,7 @@ def run(
120147 verbose ,
121148 pytest_args ,
122149 jobs ,
150+ init_timeout ,
123151 )
124152 except _TryAgain :
125153 return self ._run_test (
@@ -132,6 +160,7 @@ def run(
132160 verbose ,
133161 pytest_args ,
134162 jobs ,
163+ init_timeout ,
135164 )
136165
137166 def _run_test (
@@ -145,6 +174,7 @@ def _run_test(
145174 verbose : bool ,
146175 pytest_args : typing .List [str ],
147176 jobs : int ,
177+ init_timeout : float ,
148178 ):
149179 # find test directory, change current directory so pytest can find the tests
150180 # -> assume that tests reside in tests or ../tests
@@ -180,14 +210,18 @@ def _run_test(
180210 pytest_args ,
181211 plugins = [
182212 pytest_isolated_tests_plugin .IsolatedTestsPlugin (
183- robot_class , main_file , builtin , verbose , jobs
213+ robot_class , main_file , builtin , verbose , jobs , init_timeout
184214 )
185215 ],
186216 )
187217 else :
188218 retv = pytest .main (
189219 pytest_args ,
190- plugins = [pytest_plugin .PyFrcPlugin (robot_class , main_file , False )],
220+ plugins = [
221+ pytest_plugin .PyFrcPlugin (
222+ robot_class , main_file , False , init_timeout
223+ )
224+ ],
191225 )
192226 finally :
193227 os .chdir (curdir )
0 commit comments