Launchable: Aggregate test results based on file level

This commit is contained in:
Naoto Ono 2024-07-19 14:30:02 +09:00 committed by Koichi Sasada
parent 6428ce80f0
commit 09dd9a0457
Notes: git 2024-07-19 07:39:38 +00:00

View File

@ -359,36 +359,50 @@ def concurrent_exec_test
end end
end end
##
# Module for writing a test file for uploading test results into Launchable.
# In bootstraptest, we aggregate the test results based on file level.
module Launchable module Launchable
@@last_test_name = nil
@@stderr = ''
@@duration = 0
def show_progress(message = '') def show_progress(message = '')
faildesc, t = super faildesc, t = super
if writer = BT.launchable_test_reports if writer = BT.launchable_test_reports
if !faildesc if faildesc
status = 'TEST_PASSED' @@stderr += faildesc
else
status = 'TEST_FAILED'
end end
repo_path = File.expand_path("#{__dir__}/../") repo_path = File.expand_path("#{__dir__}/../")
relative_path = self.path.delete_prefix("#{repo_path}/") relative_path = File.join(__dir__, self.path).delete_prefix("#{repo_path}/")
# The test path is a URL-encoded representation. if @@last_test_name != nil && @@last_test_name != relative_path
# https://github.com/launchableinc/cli/blob/v1.81.0/launchable/testpath.py#L18 # The test path is a URL-encoded representation.
test_path = {file: relative_path, testcase: self.id}.map{|key, val| # https://github.com/launchableinc/cli/blob/v1.81.0/launchable/testpath.py#L18
"#{encode_test_path_component(key)}=#{encode_test_path_component(val)}" test_path = "#{encode_test_path_component("file")}=#{encode_test_path_component(@@last_test_name)}"
}.join('#') if @@stderr.size > 0
writer.write_object( status = 'TEST_FAILED'
{ else
testPath: test_path, status = 'TEST_PASSED'
status: status, end
duration: t, writer.write_object(
createdAt: Time.now.to_s, {
stderr: faildesc, testPath: test_path,
stdout: nil, status: status,
data: { duration: t,
lineNumber: self.lineno createdAt: Time.now.to_s,
stderr: @@stderr,
stdout: nil,
data: {
lineNumber: self.lineno
}
} }
} )
) @@duration = 0
@@stderr.clear
end
@@last_test_name = relative_path
@@duration += t
end end
end end