Handle long crystalball spec key name entries in yaml dump

flag=none

Test-plan:
- build map in jenkins
- push map to s3 manually
- reference map in test PS

Change-Id: I78c0c57f970256f84120fe3c336e882d6f3d41e2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/284590
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: James Butters <jbutters@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: James Butters <jbutters@instructure.com>
This commit is contained in:
Brian Watson 2022-02-07 13:45:37 -07:00
parent d780f09c68
commit aa2e095ee8
1 changed files with 16 additions and 0 deletions

View File

@ -198,6 +198,22 @@ module Crystalball
prediction_list.include?(ENV["CRYSTALBALL_TEST_SUITE_ROOT"])
end
end
class MapStorage
# YAML persistence adapter for execution map storage
class YAMLStorage
def dump(data)
path.dirname.mkpath
# Any keys longer than 128 chars will have a yaml output starting with "? <value>\n:" instead of "<value>:\n", which crystalball doesn't like
data_dump = if %i[type commit timestamp version].all? { |header| data.key? header }
YAML.dump(data)
else
YAML.dump(data).gsub("? ", "").gsub("\n:", ":\n").gsub("\n -", "\n-").gsub("\n -", "\n-")
end
path.open("a") { |f| f.write data_dump }
end
end
end
end
require "crystalball/rspec/runner/configuration"