test-bot: add safety margin to output truncation size
This commit is contained in:
parent
bbb1fcd17c
commit
1f8b6cb576
@ -37,6 +37,8 @@ require "tap"
|
|||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
BYTES_IN_1_MEGABYTE = 1024*1024
|
BYTES_IN_1_MEGABYTE = 1024*1024
|
||||||
|
MAX_STEP_OUTPUT_SIZE = BYTES_IN_1_MEGABYTE - (200*1024) # margin of safety
|
||||||
|
|
||||||
HOMEBREW_TAP_REGEX = %r{^([\w-]+)/homebrew-([\w-]+)$}
|
HOMEBREW_TAP_REGEX = %r{^([\w-]+)/homebrew-([\w-]+)$}
|
||||||
|
|
||||||
def ruby_has_encoding?
|
def ruby_has_encoding?
|
||||||
@ -997,14 +999,14 @@ module Homebrew
|
|||||||
output = output.delete("\000\a\b\e\f\x2\x1f")
|
output = output.delete("\000\a\b\e\f\x2\x1f")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Truncate to 1MB
|
# Truncate to 1MB to avoid hitting CI limits
|
||||||
if output.bytesize > BYTES_IN_1_MEGABYTE
|
if output.bytesize > MAX_STEP_OUTPUT_SIZE
|
||||||
if ruby_has_encoding?
|
if ruby_has_encoding?
|
||||||
binary_output = output.force_encoding("BINARY")
|
binary_output = output.force_encoding("BINARY")
|
||||||
output = binary_output.slice(-BYTES_IN_1_MEGABYTE, BYTES_IN_1_MEGABYTE)
|
output = binary_output.slice(-MAX_STEP_OUTPUT_SIZE, MAX_STEP_OUTPUT_SIZE)
|
||||||
fix_encoding!(output)
|
fix_encoding!(output)
|
||||||
else
|
else
|
||||||
output = output.slice(-BYTES_IN_1_MEGABYTE, BYTES_IN_1_MEGABYTE)
|
output = output.slice(-MAX_STEP_OUTPUT_SIZE, MAX_STEP_OUTPUT_SIZE)
|
||||||
end
|
end
|
||||||
output = "truncated output to 1MB:\n" + output
|
output = "truncated output to 1MB:\n" + output
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user