Buildkite Test Engine: fix JSON comma separate bug #56588
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request fixes a missing-comma-separator bug in the Bootleg JSON writer 🏴☠️ which is responsible for producing JSON test results for Buildkite Test Engine.
There was a bug when serializing to JSON array (from
AbstractVector) where elements that were===/ “egal” to the final element would not have a comma separator placed after them, producing invalid JSON. I stumbled upon this because I work at Buildkite; I've previously contributed a fix for a different issue in `test/buildkitetestjson.jl.Specifically, this bug occurred when the last item of
expandedorbacktracewithinfailure_expandedwas an empty string, becauseelt === last(val)was"" === ""wastrue, so e.g.["hello", "", "world", ""]would serialize to:Note this was not happening when the last element was a non-empty string; the strings come from
split(string, '\n')which returns a singleton empty string for zero-width splits, but separate strings for non-empty splits:This patch changes the “is final item” check to be index-based, rather than identity-based.
I've tested it by adding a synthetic failure to an existing test:
And then observed the
test/results_1.jsonbefore and after this patch:"expanded": [ "testing Buildkite JSON", - "" + "", "comma after blank lines", - "" + "", "when last line is blank", "" ]Related:
failure_expanded#53706