summaryrefslogtreecommitdiff
path: root/bootstraptest/runner.rb
diff options
context:
space:
mode:
authorNaoto Ono <[email protected]>2024-07-19 14:30:02 +0900
committerKoichi Sasada <[email protected]>2024-07-19 16:39:21 +0900
commit09dd9a0457c0ce6fdde2bf0246efa5bebde1d05b (patch)
tree5157b616343b372e6be3b72713ba40acea3a4d7c /bootstraptest/runner.rb
parent6428ce80f0ef85324a4d0a72ffa4c6fa2db37cdd (diff)
Launchable: Aggregate test results based on file level
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11205
Diffstat (limited to 'bootstraptest/runner.rb')
-rwxr-xr-xbootstraptest/runner.rb58
1 files changed, 36 insertions, 22 deletions
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb
index 2e2a3611de..237a90241b 100755
--- a/bootstraptest/runner.rb
+++ b/bootstraptest/runner.rb
@@ -359,36 +359,50 @@ def concurrent_exec_test
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
+ @@last_test_name = nil
+ @@stderr = ''
+ @@duration = 0
+
def show_progress(message = '')
faildesc, t = super
if writer = BT.launchable_test_reports
- if !faildesc
- status = 'TEST_PASSED'
- else
- status = 'TEST_FAILED'
+ if faildesc
+ @@stderr += faildesc
end
repo_path = File.expand_path("#{__dir__}/../")
- relative_path = self.path.delete_prefix("#{repo_path}/")
- # The test path is a URL-encoded representation.
- # https://github.com/launchableinc/cli/blob/v1.81.0/launchable/testpath.py#L18
- test_path = {file: relative_path, testcase: self.id}.map{|key, val|
- "#{encode_test_path_component(key)}=#{encode_test_path_component(val)}"
- }.join('#')
- writer.write_object(
- {
- testPath: test_path,
- status: status,
- duration: t,
- createdAt: Time.now.to_s,
- stderr: faildesc,
- stdout: nil,
- data: {
- lineNumber: self.lineno
+ relative_path = File.join(__dir__, self.path).delete_prefix("#{repo_path}/")
+ if @@last_test_name != nil && @@last_test_name != relative_path
+ # The test path is a URL-encoded representation.
+ # https://github.com/launchableinc/cli/blob/v1.81.0/launchable/testpath.py#L18
+ test_path = "#{encode_test_path_component("file")}=#{encode_test_path_component(@@last_test_name)}"
+ if @@stderr.size > 0
+ status = 'TEST_FAILED'
+ else
+ status = 'TEST_PASSED'
+ end
+ writer.write_object(
+ {
+ testPath: test_path,
+ status: status,
+ duration: t,
+ 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