Skip to content

Commit 7933dce

Browse files
authored
Fix failed test/buildbot/builders/unified_cmakeex.py test (issue #235). (#237)
The changes for UnifiedTreeBuilder.getCmakeExBuildFactory factory and its test: * updated the step formatting with 'hint' argument (avoid usage of substitutions). * allowed only 'str' or None for the 'hint' argument. * updated 'test/buildbot/builders/unified_cmakeex.py' test for the factory changes accordingly. See #235 for more details.
1 parent 65eb699 commit 7933dce

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

test/buildbot/builders/unified_cmakeex.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@
1111
from zorg.buildbot.builders import UnifiedTreeBuilder
1212
from zorg.buildbot.process.factory import LLVMBuildFactory
1313

14+
#Note:
15+
# - this function currently supports only %(kw:*)s formatting for the Interpolates.
16+
# - this function does not support the substitutions for arguments (such as '%(kw:arg:-)s' & etc).
17+
# - this function does not support the other types of the renderables except Interpolate
18+
# (such as WithProperties and os on).
1419
def partly_rendered(r):
1520
if isinstance(r, buildbot.process.properties.Interpolate):
1621
interpolations = {}
1722
for k, v in r.kwargs.items():
18-
interpolations[f"kw:{k}"] = v
23+
interpolations[f"kw:{k}"] = v if v else ""
1924
return r.fmtstring % interpolations
2025
elif type(r) == str:
2126
return r
@@ -90,7 +95,7 @@ def factory_has_step(f, name, hasarg=None, contains=None):
9095
assert factory_has_step(f, "set-props")
9196
assert factory_has_step(f, "clean-src-dir")
9297
assert factory_has_step(f, "clean-obj-dir")
93-
assert factory_has_step(f, "Checkout the source code")
98+
assert factory_has_step(f, "checkout")
9499

95100
assert factory_has_step(f, "cmake-configure")
96101
assert factory_has_step(f, "cmake-configure", hasarg = "generator", contains = "Ninja")
@@ -193,7 +198,7 @@ def factory_has_step(f, name, hasarg=None, contains=None):
193198
assert factory_has_step(f, "set-props")
194199
assert factory_has_step(f, "clean-src-dir")
195200
assert factory_has_step(f, "clean-obj-dir")
196-
assert factory_has_step(f, "Checkout the source code")
201+
assert factory_has_step(f, "checkout")
197202

198203
assert factory_has_step(f, "clean-install-dir")
199204
assert factory_has_step(f, "cmake-configure")
@@ -231,13 +236,13 @@ def factory_has_step(f, name, hasarg=None, contains=None):
231236
print(f"factory with VS environment autodetect: {f}\n")
232237

233238
assert factory_has_num_steps(f, 8)
234-
assert factory_has_step(f, "set-pros.vs_env")
239+
assert factory_has_step(f, "set-props.vs_env")
235240

236241
f = UnifiedTreeBuilder.getCmakeExBuildFactory(vs = "manual", vs_arch = "amd64")
237242
print(f"factory with VS environment manual: {f}\n")
238243

239244
assert factory_has_num_steps(f, 8)
240-
assert factory_has_step(f, "set-pros.vs_env")
245+
assert factory_has_step(f, "set-props.vs_env")
241246

242247
# Check custom CMake generator
243248
f = UnifiedTreeBuilder.getCmakeExBuildFactory(generator = "Unix Makefiles")
@@ -350,3 +355,13 @@ def factory_has_step(f, name, hasarg=None, contains=None):
350355
assert factory_has_step(f, "post_build_step2", hasarg = "command", contains = ["ls"])
351356
assert factory_has_step(f, "pre_install_step", hasarg = "property", contains = "SomeProperty")
352357
assert factory_has_step(f, "post_finalize_step", hasarg = "property", contains = "SomeProperty")
358+
359+
360+
# Hint
361+
f = UnifiedTreeBuilder.getCmakeExBuildFactory(
362+
hint = "stage-hint"
363+
)
364+
print(f"Hint option: {f}\n")
365+
366+
assert factory_has_step(f, "cmake-configure-stage-hint")
367+
assert factory_has_step(f, "build-default-stage-hint")

zorg/buildbot/builders/UnifiedTreeBuilder.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,8 @@ def getCmakeExBuildFactory(
800800
install => install-stageX
801801
& etc.
802802
803+
Note: cannot be a renderable object.
804+
803805
Returns
804806
-------
805807
@@ -842,6 +844,7 @@ def getCmakeExBuildFactory(
842844
"The 'pre_install_steps' argument must be a list() or BuildFactory()."
843845
assert not post_finalize_steps or isinstance(post_finalize_steps, (list, BuildFactory)), \
844846
"The 'post_finalize_steps' argument must be a list() or BuildFactory()."
847+
assert not hint or isinstance(hint, str), "The 'hint' argument must be a str object."
845848

846849
# This function extends the current workflow with provided custom steps.
847850
def extend_with_custom_steps(fc, s):
@@ -994,7 +997,7 @@ def norm_target_list_arg(lst):
994997
workdir = f.obj_dir
995998
))
996999

997-
hint_suffix = f"-{hint}" if hint else None
1000+
hint_suffix = f"-{hint}" if hint else ""
9981001
# Build Commands.
9991002
#NOTE: please note that the default target (.) cannot be specified by the IRenderable object.
10001003
for target in targets:
@@ -1008,7 +1011,7 @@ def norm_target_list_arg(lst):
10081011

10091012
f.addStep(
10101013
steps.CMake(
1011-
name = util.Interpolate("build-%(kw:title)s%(kw:hint:-)s",
1014+
name = util.Interpolate("build-%(kw:title)s%(kw:hint)s",
10121015
title = target_title, hint = hint_suffix),
10131016
options = cmake_build_options,
10141017
description = ["Build target", target_title],
@@ -1025,7 +1028,7 @@ def norm_target_list_arg(lst):
10251028
for target in checks:
10261029
f.addStep(
10271030
LitTestCommand(
1028-
name = util.Interpolate("test-%(kw:title)s%(kw:hint:-)s",
1031+
name = util.Interpolate("test-%(kw:title)s%(kw:hint)s",
10291032
title = target, hint = hint_suffix),
10301033
command = [steps.CMake.DEFAULT_CMAKE, "--build", ".", "--target", target],
10311034
description = ["Test just built components:", target],
@@ -1039,7 +1042,7 @@ def norm_target_list_arg(lst):
10391042
for target, cmd in checks_on_target:
10401043
f.addStep(
10411044
LitTestCommand(
1042-
name = util.Interpolate("test-%(kw:title)s%(kw:hint:-)s",
1045+
name = util.Interpolate("test-%(kw:title)s%(kw:hint)s",
10431046
title = target, hint = hint_suffix),
10441047
command = cmd,
10451048
description = ["Test just built components:", target],
@@ -1059,7 +1062,7 @@ def norm_target_list_arg(lst):
10591062
f.addStep(
10601063
steps.CMake(
10611064
name = util.Transform(lambda s: s if s.startswith("install") else f"install-{s}",
1062-
util.Interpolate("%(kw:title)s%(kw:hint:-)s", title = target, hint = hint_suffix)),
1065+
util.Interpolate("%(kw:title)s%(kw:hint)s", title = target, hint = hint_suffix)),
10631066
options = ["--build", ".", "--target", target],
10641067
description = ["Install just built components:", target],
10651068
haltOnFailure = False,

0 commit comments

Comments
 (0)