9
9
10
10
from buildbot .plugins import util
11
11
12
+ from . import (MAIN_BRANCH_VERSION , CUSTOM_BRANCH_NAME , MAIN_BRANCH_NAME ,
13
+ JUNIT_FILENAME )
12
14
from .steps import (
13
15
Test ,
14
16
Clean ,
18
20
UploadTestResults ,
19
21
)
20
22
21
- main_branch_version = "3.13"
22
- CUSTOM_BRANCH_NAME = "custom"
23
+ # Python branches with regrtest --fail-rerun option
24
+ # https://github.com/python/cpython/issues/108834
25
+ BRANCH_WITH_FAIL_RERUN = (
26
+ MAIN_BRANCH_NAME ,
27
+ #"3.12",
28
+ #"3.11",
29
+ )
23
30
24
31
# This (default) timeout is for each individual test file.
25
32
# It is a bit more than the default faulthandler timeout in regrtest.py
@@ -40,42 +47,21 @@ def __init__(self, source, *, extra_tags=[], **kwargs):
40
47
self .tags = self .factory_tags + extra_tags
41
48
42
49
43
- class FreezeBuild (TaggedBuildFactory ):
44
- buildersuffix = ".freeze" # to get unique directory names on master
45
- test_timeout = None
46
- factory_tags = ["freeze" ]
47
-
48
- def setup (self , ** kwargs ):
49
- self .addStep (Configure (command = ["./configure" , "--prefix" , "$(PWD)/target" ]))
50
- self .addStep (Compile (command = ["make" ]))
51
- self .addStep (
52
- ShellCommand (
53
- name = "install" , description = "installing" , command = ["make" , "install" ]
54
- )
55
- )
56
- self .addStep (
57
- Test (
58
- command = [
59
- "make" ,
60
- "-C" ,
61
- "Tools/freeze/test" ,
62
- "PYTHON=../../../target/bin/python3" ,
63
- "OUTDIR=../../../target/freezetest" ,
64
- ]
65
- )
66
- )
67
-
68
-
69
50
##############################################################################
70
51
############################### UNIX BUILDS ################################
71
52
##############################################################################
72
53
73
54
55
+ def has_option (option , test_options ):
56
+ # return True for option='-j' and test_options=['-uall', '-j2']
57
+ return option in ' ' .join (test_options )
58
+
59
+
74
60
class UnixBuild (TaggedBuildFactory ):
75
61
configureFlags = ["--with-pydebug" ]
76
62
compile_environ = {}
77
63
interpreterFlags = ""
78
- testFlags = "-j2"
64
+ testFlags = [ "-j2" ]
79
65
makeTarget = "all"
80
66
test_timeout = None
81
67
test_environ = {}
@@ -106,22 +92,24 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
106
92
Configure (command = configure_cmd , ** oot_kwargs )
107
93
)
108
94
compile = ["make" , self .makeTarget ]
109
- testopts = self .testFlags
110
- if "-R" not in self .testFlags :
111
- testopts += " --junit-xml test-results.xml"
95
+ testopts = list ( self .testFlags )
96
+ if not has_option ( "-R" , self .testFlags ) :
97
+ testopts . extend (( " --junit-xml" , JUNIT_FILENAME ))
112
98
# Timeout for the buildworker process
113
99
self .test_timeout = self .test_timeout or TEST_TIMEOUT
114
100
# Timeout for faulthandler
115
101
faulthandler_timeout = self .test_timeout - 5 * 60
116
102
if parallel :
117
103
compile = ["make" , parallel , self .makeTarget ]
118
- testopts = testopts + " " + parallel
119
- if "-j" not in testopts :
120
- testopts = "-j2 " + testopts
104
+ testopts .append (parallel )
105
+ if not has_option ("-j" , testopts ):
106
+ testopts .append ("-j2" )
107
+ if branch in BRANCH_WITH_FAIL_RERUN :
108
+ testopts .append ("--fail-rerun" )
121
109
test = [
122
110
"make" ,
123
111
"buildbottest" ,
124
- "TESTOPTS=" + testopts + " ${BUILDBOT_TESTOPTS}" ,
112
+ "TESTOPTS=" + " " . join ( testopts ) + " ${BUILDBOT_TESTOPTS}" ,
125
113
"TESTPYTHONOPTS=" + self .interpreterFlags ,
126
114
"TESTTIMEOUT=" + str (faulthandler_timeout ),
127
115
]
@@ -148,8 +136,8 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
148
136
** oot_kwargs
149
137
)
150
138
)
151
- if branch not in ("3" ,) and "-R" not in self .testFlags :
152
- filename = "test-results.xml"
139
+ if branch not in ("3" ,) and not has_option ( "-R" , self .testFlags ) :
140
+ filename = JUNIT_FILENAME
153
141
if self .build_out_of_tree :
154
142
filename = os .path .join (out_of_tree_dir , filename )
155
143
self .addStep (UploadTestResults (branch , filename = filename ))
@@ -174,7 +162,7 @@ class UnixVintageParserBuild(UnixBuild):
174
162
175
163
class UnixRefleakBuild (UnixBuild ):
176
164
buildersuffix = ".refleak"
177
- testFlags = "-R 3:3 -u-cpu"
165
+ testFlags = [ "-R" , " 3:3" , " -u-cpu"]
178
166
# -R 3:3 is supposed to only require timeout x 6, but in practice,
179
167
# it's much more slower. Use timeout x 10 to prevent timeout
180
168
# caused by --huntrleaks.
@@ -210,8 +198,8 @@ class UnixInstalledBuild(TaggedBuildFactory):
210
198
factory_tags = ["installed" ]
211
199
212
200
def setup (self , parallel , branch , test_with_PTY = False , ** kwargs ):
213
- if branch == "3.x" :
214
- branch = main_branch_version
201
+ if branch == MAIN_BRANCH_NAME :
202
+ branch = MAIN_BRANCH_VERSION
215
203
elif branch == "custom" :
216
204
branch = "3"
217
205
installed_python = "./target/bin/python%s" % branch
@@ -224,19 +212,23 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
224
212
225
213
compile = ["make" , self .makeTarget ]
226
214
install = ["make" , self .installTarget ]
227
- testopts = self .defaultTestOpts [:]
215
+ testopts = list ( self .defaultTestOpts )
228
216
# Timeout for the buildworker process
229
217
self .test_timeout = self .test_timeout or TEST_TIMEOUT
230
218
# Timeout for faulthandler
231
219
faulthandler_timeout = self .test_timeout - 5 * 60
232
- testopts += [ f"--timeout={ faulthandler_timeout } " ]
220
+ testopts . append ( f"--timeout={ faulthandler_timeout } " )
233
221
if parallel :
234
222
compile = ["make" , parallel , self .makeTarget ]
235
223
install = ["make" , parallel , self .installTarget ]
236
- testopts = testopts + [parallel ]
224
+ testopts .append (parallel )
225
+ if branch in BRANCH_WITH_FAIL_RERUN :
226
+ testopts .append ("--fail-rerun" )
237
227
238
- test = [installed_python ] + self .interpreterFlags
239
- test += ["-m" , "test.regrtest" ] + testopts
228
+ test = [installed_python ,
229
+ * self .interpreterFlags ,
230
+ "-m" , "test" ,
231
+ * testopts ]
240
232
241
233
self .addStep (Compile (command = compile ))
242
234
self .addStep (Install (command = install ))
@@ -362,10 +354,6 @@ class SlowNonDebugUnixBuild(NonDebugUnixBuild):
362
354
test_timeout = SLOW_TIMEOUT
363
355
364
356
365
- class SlowSharedUnixBuild (SharedUnixBuild ):
366
- test_timeout = SLOW_TIMEOUT
367
-
368
-
369
357
class SlowUnixInstalledBuild (UnixInstalledBuild ):
370
358
test_timeout = SLOW_TIMEOUT
371
359
@@ -516,7 +504,8 @@ class MacOSArmWithBrewBuild(UnixBuild):
516
504
"LDFLAGS=-L/opt/homebrew/lib" ,
517
505
]
518
506
# These tests are known to crash on M1 macs (see bpo-45289).
519
- testFlags = UnixBuild .testFlags + " -x test_dbm test_dbm_ndbm test_shelve"
507
+ testFlags = [* UnixBuild .testFlags ,
508
+ "-x" , "test_dbm" , "test_dbm_ndbm" , "test_shelve" ]
520
509
521
510
##############################################################################
522
511
############################ WINDOWS BUILDS ################################
@@ -536,12 +525,14 @@ class BaseWindowsBuild(TaggedBuildFactory):
536
525
537
526
def setup (self , parallel , branch , ** kwargs ):
538
527
build_command = self .build_command + self .buildFlags
539
- test_command = self .test_command + self .testFlags
540
- if "-R" not in self .testFlags :
541
- test_command += [ r"--junit-xml" , r"test-results.xml" ]
528
+ test_command = [ * self .test_command , * self .testFlags ]
529
+ if not has_option ( "-R" , self .testFlags ) :
530
+ test_command . extend (( r"--junit-xml" , JUNIT_FILENAME ))
542
531
clean_command = self .clean_command + self .cleanFlags
543
532
if parallel :
544
533
test_command .append (parallel )
534
+ if branch in BRANCH_WITH_FAIL_RERUN :
535
+ test_command .append ("--fail-rerun" )
545
536
self .addStep (Compile (command = build_command ))
546
537
self .addStep (
547
538
ShellCommand (
@@ -552,9 +543,9 @@ def setup(self, parallel, branch, **kwargs):
552
543
)
553
544
)
554
545
timeout = self .test_timeout if self .test_timeout else TEST_TIMEOUT
555
- test_command += [ "--timeout" , timeout - (5 * 60 )]
546
+ test_command . extend (( "--timeout" , timeout - (5 * 60 )))
556
547
self .addStep (Test (command = test_command , timeout = timeout ))
557
- if branch not in ("3" ,) and "-R" not in self .testFlags :
548
+ if branch not in ("3" ,) and not has_option ( "-R" , self .testFlags ) :
558
549
self .addStep (UploadTestResults (branch ))
559
550
self .addStep (Clean (command = clean_command ))
560
551
@@ -596,7 +587,7 @@ class Windows64BigmemBuild(BaseWindowsBuild):
596
587
597
588
class Windows64RefleakBuild (Windows64Build ):
598
589
buildersuffix = ".refleak"
599
- testFlags = ["-p" , "x64" ] + WindowsRefleakBuild .testFlags
590
+ testFlags = ["-p" , "x64" , * WindowsRefleakBuild .testFlags ]
600
591
# -R 3:3 is supposed to only require timeout x 6, but in practice,
601
592
# it's much more slower. Use timeout x 10 to prevent timeout
602
593
# caused by --huntrleaks.
@@ -607,7 +598,7 @@ class Windows64RefleakBuild(Windows64Build):
607
598
class Windows64ReleaseBuild (Windows64Build ):
608
599
buildersuffix = ".nondebug"
609
600
buildFlags = Windows64Build .buildFlags + ["-c" , "Release" ]
610
- testFlags = Windows64Build .testFlags + [ "+d" ]
601
+ testFlags = [ * Windows64Build .testFlags , "+d" ]
611
602
# keep default cleanFlags, both configurations get cleaned
612
603
factory_tags = ["win64" , "nondebug" ]
613
604
@@ -622,7 +613,7 @@ class WindowsARM64Build(BaseWindowsBuild):
622
613
class WindowsARM64ReleaseBuild (WindowsARM64Build ):
623
614
buildersuffix = ".nondebug"
624
615
buildFlags = WindowsARM64Build .buildFlags + ["-c" , "Release" ]
625
- testFlags = WindowsARM64Build .testFlags + [ "+d" ]
616
+ testFlags = [ * WindowsARM64Build .testFlags , "+d" ]
626
617
# keep default cleanFlags, both configurations get cleaned
627
618
factory_tags = ["win-arm64" , "nondebug" ]
628
619
@@ -714,13 +705,15 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
714
705
)
715
706
)
716
707
717
- testopts = self .testFlags
718
- if "-R" not in self .testFlags :
719
- testopts += " --junit-xml test-results.xml"
708
+ testopts = list ( self .testFlags )
709
+ if not has_option ( "-R" , self .testFlags ) :
710
+ testopts . extend (( " --junit-xml" , JUNIT_FILENAME ))
720
711
if parallel :
721
- testopts = testopts + " " + parallel
722
- if "-j" not in testopts :
723
- testopts = "-j2 " + testopts
712
+ testopts .append (parallel )
713
+ if not has_option ("-j" , self .testFlags ):
714
+ testopts .append ("-j2" )
715
+ if branch in BRANCH_WITH_FAIL_RERUN :
716
+ testopts .append ("--fail-rerun" )
724
717
725
718
# Timeout for the buildworker process
726
719
self .test_timeout = self .test_timeout or TEST_TIMEOUT
@@ -730,7 +723,7 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
730
723
test = [
731
724
"make" ,
732
725
"buildbottest" ,
733
- "TESTOPTS=" + testopts + " ${BUILDBOT_TESTOPTS}" ,
726
+ "TESTOPTS=" + " " . join ( testopts ) + " ${BUILDBOT_TESTOPTS}" ,
734
727
"TESTPYTHONOPTS=" + self .interpreterFlags ,
735
728
"TESTTIMEOUT=" + str (faulthandler_timeout ),
736
729
]
@@ -767,8 +760,8 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
767
760
workdir = oot_host_path ,
768
761
)
769
762
)
770
- if branch not in ("3" ,) and "-R" not in self .testFlags :
771
- filename = os .path .join (oot_host_path , "test-results.xml" )
763
+ if branch not in ("3" ,) and not has_option ( "-R" , self .testFlags ) :
764
+ filename = os .path .join (oot_host_path , JUNIT_FILENAME )
772
765
self .addStep (UploadTestResults (branch , filename = filename ))
773
766
self .addStep (
774
767
Clean (
0 commit comments