Skip to content

Commit 12dd3dd

Browse files
authored
Merge pull request #98 from vstinner/cleantest
Add CleanupTest step
2 parents ed943fc + 84508a8 commit 12dd3dd

3 files changed

Lines changed: 30 additions & 3 deletions

File tree

master/custom/factories.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
from buildbot.process import factory
22
from buildbot.steps.shell import Configure, Compile, ShellCommand
33

4-
from .steps import Test, Clean, Install, LockInstall, Uninstall
4+
from .steps import Test, Clean, CleanupTest, Install, LockInstall, Uninstall
55

66
master_branch_version = "3.9"
7+
CUSTOM_BRANCH_NAME = "custom"
78

89
# This (default) timeout is for each individual test file.
910
# It is a bit more than the default faulthandler timeout in regrtest.py
1011
# (the latter isn't easily changed under Windows).
1112
TEST_TIMEOUT = 20 * 60
1213

1314

15+
def regrtest_has_cleanup(branch):
16+
# "python -m test --cleanup" is available in Python 3.7 and newer,
17+
# and in Python 2.7.
18+
return (branch not in ("3.4", "3.5", "3.6", CUSTOM_BRANCH_NAME))
19+
20+
1421
class TaggedBuildFactory(factory.BuildFactory):
1522
factory_tags = []
1623

@@ -58,7 +65,7 @@ class UnixBuild(TaggedBuildFactory):
5865
makeTarget = "all"
5966
test_timeout = None
6067

61-
def setup(self, parallel, test_with_PTY=False, **kwargs):
68+
def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
6269
self.addStep(
6370
Configure(
6471
command=["./configure", "--prefix", "$(PWD)/target"]
@@ -76,6 +83,13 @@ def setup(self, parallel, test_with_PTY=False, **kwargs):
7683
testopts = testopts + " " + parallel
7784
if "-j" not in testopts:
7885
testopts = "-j2 " + testopts
86+
cleantest = [
87+
"make",
88+
"cleantest",
89+
"TESTOPTS=" + testopts + " ${BUILDBOT_TESTOPTS}",
90+
"TESTPYTHONOPTS=" + self.interpreterFlags,
91+
"TESTTIMEOUT=" + str(faulthandler_timeout),
92+
]
7993
test = [
8094
"make",
8195
"buildbottest",
@@ -93,6 +107,8 @@ def setup(self, parallel, test_with_PTY=False, **kwargs):
93107
warnOnFailure=True,
94108
)
95109
)
110+
if regrtest_has_cleanup(branch):
111+
self.addStep(CleanupTest(command=cleantest))
96112
self.addStep(
97113
Test(command=test, timeout=self.test_timeout, usePTY=test_with_PTY)
98114
)
@@ -316,6 +332,9 @@ def setup(self, parallel, branch, **kwargs):
316332
timeout = TEST_TIMEOUT
317333
if branch != "2.7":
318334
test_command += ["--timeout", timeout - (5 * 60)]
335+
if regrtest_has_cleanup(branch):
336+
cleantest = test_command + ["--cleanup"]
337+
self.addStep(CleanupTest(command=cleantest))
319338
self.addStep(Test(command=test_command, timeout=timeout))
320339
self.addStep(Clean(command=clean_command))
321340

master/custom/steps.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ class Clean(ShellCommand):
7070
alwaysRun = True
7171

7272

73+
class CleanupTest(ShellCommand):
74+
name = "cleantest"
75+
description = ["cleaning previous tests"]
76+
descriptionDone = ["clean previous tests"]
77+
flunkOnFailure = False
78+
warnOnFailure = True
79+
80+
7381
class Install(ShellCommand):
7482
name = "install"
7583
description = ["installing"]

master/master.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ for k in list(sys.modules):
2828
if k.split(".")[0] in ["local", "custom"]:
2929
sys.modules.pop(k)
3030
from custom.factories import (
31+
CUSTOM_BRANCH_NAME,
3132
UnixBuild,
3233
UnixRefleakBuild,
3334
UnixInstalledBuild,
@@ -135,7 +136,6 @@ c['configurators'] = [util.JanitorConfigurator(
135136
c['workers'] = WORKERS
136137

137138
# repo url, buildbot category name, git branch name
138-
CUSTOM_BRANCH_NAME = "custom"
139139
git_branches = [
140140
(GIT_URL, "3.x", "master"),
141141
(GIT_URL, "3.8", "3.8"),

0 commit comments

Comments
 (0)