34
34
TEST_TIMEOUT = 20 * 60
35
35
36
36
37
+ def step_timeout (timeout ):
38
+ # timeout is the regrtest timeout in seconds. If a test runs longer than
39
+ # the timeout, it should be killed by faulthandler. Give 10 minutes to
40
+ # faulthandler to kill the process. Tests should always be shorter than the
41
+ # buildbot step timeout, unless faulthandler fails to kill the process.
42
+ return timeout + 10 * 60
43
+
44
+
37
45
def regrtest_has_cleanup (branch ):
38
46
return branch not in {CUSTOM_BRANCH_NAME }
39
47
40
48
41
- class TaggedBuildFactory (factory .BuildFactory ):
49
+ class BaseBuild (factory .BuildFactory ):
42
50
factory_tags = []
51
+ test_timeout = TEST_TIMEOUT
43
52
44
53
def __init__ (self , source , * , extra_tags = [], ** kwargs ):
45
54
super ().__init__ ([source ])
@@ -57,13 +66,12 @@ def has_option(option, test_options):
57
66
return option in ' ' .join (test_options )
58
67
59
68
60
- class UnixBuild (TaggedBuildFactory ):
69
+ class UnixBuild (BaseBuild ):
61
70
configureFlags = ["--with-pydebug" ]
62
71
compile_environ = {}
63
72
interpreterFlags = ""
64
73
testFlags = ["-j2" ]
65
74
makeTarget = "all"
66
- test_timeout = None
67
75
test_environ = {}
68
76
build_out_of_tree = False
69
77
@@ -95,10 +103,6 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
95
103
testopts = list (self .testFlags )
96
104
if not has_option ("-R" , self .testFlags ):
97
105
testopts .extend (("--junit-xml" , JUNIT_FILENAME ))
98
- # Timeout for the buildworker process
99
- self .test_timeout = self .test_timeout or TEST_TIMEOUT
100
- # Timeout for faulthandler
101
- faulthandler_timeout = self .test_timeout - 5 * 60
102
106
if parallel :
103
107
compile = ["make" , parallel , self .makeTarget ]
104
108
testopts .append (parallel )
@@ -110,8 +114,8 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
110
114
"make" ,
111
115
"buildbottest" ,
112
116
"TESTOPTS=" + " " .join (testopts ) + " ${BUILDBOT_TESTOPTS}" ,
113
- "TESTPYTHONOPTS=" + self .interpreterFlags ,
114
- "TESTTIMEOUT=" + str ( faulthandler_timeout ) ,
117
+ f "TESTPYTHONOPTS={ self .interpreterFlags } " ,
118
+ f "TESTTIMEOUT={ self . test_timeout } " ,
115
119
]
116
120
117
121
self .addStep (Compile (command = compile ,
@@ -127,15 +131,13 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
127
131
** oot_kwargs
128
132
)
129
133
)
130
- self .addStep (
131
- Test (
132
- command = test ,
133
- timeout = self .test_timeout ,
134
- usePTY = test_with_PTY ,
135
- env = self .test_environ ,
136
- ** oot_kwargs
137
- )
138
- )
134
+ self .addStep (Test (
135
+ command = test ,
136
+ timeout = step_timeout (self .test_timeout ),
137
+ usePTY = test_with_PTY ,
138
+ env = self .test_environ ,
139
+ ** oot_kwargs
140
+ ))
139
141
if branch not in ("3" ,) and not has_option ("-R" , self .testFlags ):
140
142
filename = JUNIT_FILENAME
141
143
if self .build_out_of_tree :
@@ -187,22 +189,21 @@ class UnixNoGilRefleakBuild(UnixBuild):
187
189
factory_tags = ["nogil" , "refleak" ]
188
190
189
191
190
- class UnixInstalledBuild (TaggedBuildFactory ):
192
+ class UnixInstalledBuild (BaseBuild ):
191
193
buildersuffix = ".installed"
192
194
configureFlags = []
193
195
interpreterFlags = ["-Wdefault" , "-bb" , "-E" ]
194
196
defaultTestOpts = ["-rwW" , "-uall" , "-j2" ]
195
197
makeTarget = "all"
196
198
installTarget = "install"
197
- test_timeout = None
198
199
factory_tags = ["installed" ]
199
200
200
201
def setup (self , parallel , branch , test_with_PTY = False , ** kwargs ):
201
202
if branch == MAIN_BRANCH_NAME :
202
203
branch = MAIN_BRANCH_VERSION
203
204
elif branch == "custom" :
204
205
branch = "3"
205
- installed_python = "./target/bin/python%s" % branch
206
+ installed_python = f "./target/bin/python{ branch } "
206
207
self .addStep (
207
208
Configure (
208
209
command = ["./configure" , "--prefix" , "$(PWD)/target" ]
@@ -213,11 +214,7 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
213
214
compile = ["make" , self .makeTarget ]
214
215
install = ["make" , self .installTarget ]
215
216
testopts = list (self .defaultTestOpts )
216
- # Timeout for the buildworker process
217
- self .test_timeout = self .test_timeout or TEST_TIMEOUT
218
- # Timeout for faulthandler
219
- faulthandler_timeout = self .test_timeout - 5 * 60
220
- testopts .append (f"--timeout={ faulthandler_timeout } " )
217
+ testopts .append (f"--timeout={ self .test_timeout } " )
221
218
if parallel :
222
219
compile = ["make" , parallel , self .makeTarget ]
223
220
install = ["make" , parallel , self .installTarget ]
@@ -241,9 +238,11 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
241
238
warnOnFailure = True ,
242
239
)
243
240
)
244
- self .addStep (
245
- Test (command = test , timeout = self .test_timeout , usePTY = test_with_PTY )
246
- )
241
+ self .addStep (Test (
242
+ command = test ,
243
+ timeout = step_timeout (self .test_timeout ),
244
+ usePTY = test_with_PTY ,
245
+ ))
247
246
self .addStep (Uninstall ())
248
247
self .addStep (Clean ())
249
248
@@ -256,8 +255,6 @@ class UnixAsanBuild(UnixBuild):
256
255
# SIGSEGV is ignored on purpose.
257
256
compile_environ = {'ASAN_OPTIONS' : 'detect_leaks=0:allocator_may_return_null=1:handle_segv=0' }
258
257
test_environ = {'ASAN_OPTIONS' : 'detect_leaks=0:allocator_may_return_null=1:handle_segv=0' }
259
- # Sometimes test_multiprocessing_fork times out after 15 minutes
260
- test_timeout = TEST_TIMEOUT * 2
261
258
262
259
263
260
class UnixAsanDebugBuild (UnixAsanBuild ):
@@ -512,15 +509,14 @@ class MacOSArmWithBrewBuild(UnixBuild):
512
509
##############################################################################
513
510
514
511
515
- class BaseWindowsBuild (TaggedBuildFactory ):
512
+ class BaseWindowsBuild (BaseBuild ):
516
513
build_command = [r"Tools\buildbot\build.bat" ]
517
514
test_command = [r"Tools\buildbot\test.bat" ]
518
515
clean_command = [r"Tools\buildbot\clean.bat" ]
519
516
python_command = [r"python.bat" ]
520
517
buildFlags = ["-p" , "Win32" ]
521
518
testFlags = ["-p" , "Win32" , "-j2" ]
522
519
cleanFlags = []
523
- test_timeout = None
524
520
factory_tags = ["win32" ]
525
521
526
522
def setup (self , parallel , branch , ** kwargs ):
@@ -542,9 +538,11 @@ def setup(self, parallel, branch, **kwargs):
542
538
warnOnFailure = True ,
543
539
)
544
540
)
545
- timeout = self .test_timeout if self .test_timeout else TEST_TIMEOUT
546
- test_command .extend (("--timeout" , timeout - (5 * 60 )))
547
- self .addStep (Test (command = test_command , timeout = timeout ))
541
+ test_command .extend (("--timeout" , str (self .test_timeout )))
542
+ self .addStep (Test (
543
+ command = test_command ,
544
+ timeout = step_timeout (self .test_timeout ),
545
+ ))
548
546
if branch not in ("3" ,) and not has_option ("-R" , self .testFlags ):
549
547
self .addStep (UploadTestResults (branch ))
550
548
self .addStep (Clean (command = clean_command ))
@@ -721,17 +719,12 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
721
719
if branch in BRANCH_WITH_FAIL_RERUN :
722
720
testopts .append ("--fail-rerun" )
723
721
724
- # Timeout for the buildworker process
725
- self .test_timeout = self .test_timeout or TEST_TIMEOUT
726
- # Timeout for faulthandler
727
- faulthandler_timeout = self .test_timeout - 5 * 60
728
-
729
722
test = [
730
723
"make" ,
731
724
"buildbottest" ,
732
725
"TESTOPTS=" + " " .join (testopts ) + " ${BUILDBOT_TESTOPTS}" ,
733
- "TESTPYTHONOPTS=" + self .interpreterFlags ,
734
- "TESTTIMEOUT=" + str ( faulthandler_timeout ) ,
726
+ f "TESTPYTHONOPTS={ self .interpreterFlags } " ,
727
+ f "TESTTIMEOUT={ self . test_timeout } " ,
735
728
]
736
729
737
730
if parallel :
@@ -757,15 +750,13 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
757
750
workdir = oot_host_path ,
758
751
)
759
752
)
760
- self .addStep (
761
- Test (
762
- command = test ,
763
- timeout = self .test_timeout ,
764
- usePTY = test_with_PTY ,
765
- env = self .test_environ ,
766
- workdir = oot_host_path ,
767
- )
768
- )
753
+ self .addStep (Test (
754
+ command = test ,
755
+ timeout = step_timeout (self .test_timeout ),
756
+ usePTY = test_with_PTY ,
757
+ env = self .test_environ ,
758
+ workdir = oot_host_path ,
759
+ ))
769
760
if branch not in ("3" ,) and not has_option ("-R" , self .testFlags ):
770
761
filename = os .path .join (oot_host_path , JUNIT_FILENAME )
771
762
self .addStep (UploadTestResults (branch , filename = filename ))
0 commit comments