Skip to content

Commit

Permalink
Merge pull request buildbot#8258 from ynezz/ynezz/fix-build-failure-s…
Browse files Browse the repository at this point in the history
…tatus-reporting

reporters: words: fix build status reporting
  • Loading branch information
p12tic authored Dec 9, 2024
2 parents 6eb0b6a + a70e72c commit 91ed91b
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
2 changes: 1 addition & 1 deletion master/buildbot/reporters/words.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def buildFinished(self, build, watched=False):
f"Build [#{buildNumber}]({url}) of `{builderName}` "
f"{self.bot.format_build_status(build)}"
)
s = build.get('status_string')
s = build.get('status_string') or build.get('state_string')
if build['results'] != SUCCESS and s is not None:
r += ": " + s
else:
Expand Down
68 changes: 68 additions & 0 deletions master/buildbot/test/unit/reporters/test_words.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,3 +813,71 @@ def test_bot_loadState(self):
])
yield self.bot.loadState()
self.assertEqual(self.bot.channels['#channel1'].notify_events, {'warnings'})

@defer.inlineCallbacks
def test_buildFinished_status_string_only(self):
"""Test that buildFinished works when only status_string is set"""
yield self.setupSomeBuilds()
self.patch_send()

build = yield self.master.data.get(('builds', 13))
build['results'] = FAILURE
build['status_string'] = 'failing tests in worker'
build['state_string'] = None

self.bot.tags = None
self.contact.channel.notify_for = lambda _: True
self.contact.useRevisions = False

yield self.contact.channel.buildFinished(build, watched=True)

self.assertEqual(
self.sent[0],
"Build [#3](http://localhost:8080/#/builders/23/builds/3) of "
"`builder1` failed: failing tests in worker",
)

@defer.inlineCallbacks
def test_buildFinished_status_string_fallback(self):
"""Test that buildFinished uses state_string when status_string is None"""
yield self.setupSomeBuilds()
self.patch_send()

build = yield self.master.data.get(('builds', 13))
build['results'] = FAILURE
build['status_string'] = None
build['state_string'] = 'failed due to test errors'

self.bot.tags = None
self.contact.channel.notify_for = lambda _: True
self.contact.useRevisions = False

yield self.contact.channel.buildFinished(build, watched=True)

self.assertEqual(
self.sent[0],
"Build [#3](http://localhost:8080/#/builders/23/builds/3) of "
"`builder1` failed: failed due to test errors",
)

@defer.inlineCallbacks
def test_buildFinished_no_status_strings(self):
"""Test that buildFinished works when both status_string and state_string are None"""
yield self.setupSomeBuilds()
self.patch_send()

build = yield self.master.data.get(('builds', 13))
build['results'] = FAILURE
build['status_string'] = None
build['state_string'] = None

self.bot.tags = None
self.contact.channel.notify_for = lambda _: True
self.contact.useRevisions = False

yield self.contact.channel.buildFinished(build, watched=True)

self.assertEqual(
self.sent[0],
"Build [#3](http://localhost:8080/#/builders/23/builds/3) of `builder1` failed.",
)
1 change: 1 addition & 0 deletions newsfragments/words-status.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix build status reporting to use state_string as fallback when status_string is None. This makes IRC build failure messages more informative by showing the failure reason instead of just "failed".

0 comments on commit 91ed91b

Please sign in to comment.