Skip to content

Commit

Permalink
Fix failed test/buildbot/builders/unified_cmakeex.py test (issue llvm…
Browse files Browse the repository at this point in the history
…#235). (llvm#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 llvm#235 for more details.
  • Loading branch information
vvereschaka authored Jul 20, 2024
1 parent 65eb699 commit 7933dce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
25 changes: 20 additions & 5 deletions test/buildbot/builders/unified_cmakeex.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
from zorg.buildbot.builders import UnifiedTreeBuilder
from zorg.buildbot.process.factory import LLVMBuildFactory

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

assert factory_has_step(f, "cmake-configure")
assert factory_has_step(f, "cmake-configure", hasarg = "generator", contains = "Ninja")
Expand Down Expand Up @@ -193,7 +198,7 @@ def factory_has_step(f, name, hasarg=None, contains=None):
assert factory_has_step(f, "set-props")
assert factory_has_step(f, "clean-src-dir")
assert factory_has_step(f, "clean-obj-dir")
assert factory_has_step(f, "Checkout the source code")
assert factory_has_step(f, "checkout")

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

assert factory_has_num_steps(f, 8)
assert factory_has_step(f, "set-pros.vs_env")
assert factory_has_step(f, "set-props.vs_env")

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

assert factory_has_num_steps(f, 8)
assert factory_has_step(f, "set-pros.vs_env")
assert factory_has_step(f, "set-props.vs_env")

# Check custom CMake generator
f = UnifiedTreeBuilder.getCmakeExBuildFactory(generator = "Unix Makefiles")
Expand Down Expand Up @@ -350,3 +355,13 @@ def factory_has_step(f, name, hasarg=None, contains=None):
assert factory_has_step(f, "post_build_step2", hasarg = "command", contains = ["ls"])
assert factory_has_step(f, "pre_install_step", hasarg = "property", contains = "SomeProperty")
assert factory_has_step(f, "post_finalize_step", hasarg = "property", contains = "SomeProperty")


# Hint
f = UnifiedTreeBuilder.getCmakeExBuildFactory(
hint = "stage-hint"
)
print(f"Hint option: {f}\n")

assert factory_has_step(f, "cmake-configure-stage-hint")
assert factory_has_step(f, "build-default-stage-hint")
13 changes: 8 additions & 5 deletions zorg/buildbot/builders/UnifiedTreeBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,8 @@ def getCmakeExBuildFactory(
install => install-stageX
& etc.
Note: cannot be a renderable object.
Returns
-------
Expand Down Expand Up @@ -842,6 +844,7 @@ def getCmakeExBuildFactory(
"The 'pre_install_steps' argument must be a list() or BuildFactory()."
assert not post_finalize_steps or isinstance(post_finalize_steps, (list, BuildFactory)), \
"The 'post_finalize_steps' argument must be a list() or BuildFactory()."
assert not hint or isinstance(hint, str), "The 'hint' argument must be a str object."

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

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

f.addStep(
steps.CMake(
name = util.Interpolate("build-%(kw:title)s%(kw:hint:-)s",
name = util.Interpolate("build-%(kw:title)s%(kw:hint)s",
title = target_title, hint = hint_suffix),
options = cmake_build_options,
description = ["Build target", target_title],
Expand All @@ -1025,7 +1028,7 @@ def norm_target_list_arg(lst):
for target in checks:
f.addStep(
LitTestCommand(
name = util.Interpolate("test-%(kw:title)s%(kw:hint:-)s",
name = util.Interpolate("test-%(kw:title)s%(kw:hint)s",
title = target, hint = hint_suffix),
command = [steps.CMake.DEFAULT_CMAKE, "--build", ".", "--target", target],
description = ["Test just built components:", target],
Expand All @@ -1039,7 +1042,7 @@ def norm_target_list_arg(lst):
for target, cmd in checks_on_target:
f.addStep(
LitTestCommand(
name = util.Interpolate("test-%(kw:title)s%(kw:hint:-)s",
name = util.Interpolate("test-%(kw:title)s%(kw:hint)s",
title = target, hint = hint_suffix),
command = cmd,
description = ["Test just built components:", target],
Expand All @@ -1059,7 +1062,7 @@ def norm_target_list_arg(lst):
f.addStep(
steps.CMake(
name = util.Transform(lambda s: s if s.startswith("install") else f"install-{s}",
util.Interpolate("%(kw:title)s%(kw:hint:-)s", title = target, hint = hint_suffix)),
util.Interpolate("%(kw:title)s%(kw:hint)s", title = target, hint = hint_suffix)),
options = ["--build", ".", "--target", target],
description = ["Install just built components:", target],
haltOnFailure = False,
Expand Down

0 comments on commit 7933dce

Please sign in to comment.