Launchable: Add lineNumber field

This commit is contained in:
Naoto Ono 2024-03-25 13:42:28 +09:00 committed by Nobuyoshi Nakada
parent b664590c4d
commit 56ecd8038a
2 changed files with 22 additions and 6 deletions

View File

@ -1374,7 +1374,8 @@ module Test
def record(suite, method, assertions, time, error, source_location = nil) def record(suite, method, assertions, time, error, source_location = nil)
if writer = @options[:launchable_test_reports] if writer = @options[:launchable_test_reports]
if path = (source_location || suite.instance_method(method).source_location).first if loc = (source_location || suite.instance_method(method).source_location)
path, lineno = loc
# Launchable JSON schema is defined at # Launchable JSON schema is defined at
# https://github.com/search?q=repo%3Alaunchableinc%2Fcli+https%3A%2F%2Flaunchableinc.com%2Fschema%2FRecordTestInput&type=code. # https://github.com/search?q=repo%3Alaunchableinc%2Fcli+https%3A%2F%2Flaunchableinc.com%2Fschema%2FRecordTestInput&type=code.
e = case error e = case error
@ -1416,7 +1417,10 @@ module Test
duration: time, duration: time,
createdAt: Time.now.to_s, createdAt: Time.now.to_s,
stderr: e, stderr: e,
stdout: nil stdout: nil,
data: {
lineNumber: lineno
}
} }
) )
end end

View File

@ -15,7 +15,10 @@ class TestLaunchable < Test::Unit::TestCase
status: "TEST_FAILED", status: "TEST_FAILED",
stdout: nil, stdout: nil,
stderr: nil, stderr: nil,
createdAt: "2021-10-05T12:34:00" createdAt: "2021-10-05T12:34:00",
data: {
lineNumber: 1
}
} }
) )
json_stream_writer.write_object( json_stream_writer.write_object(
@ -25,7 +28,10 @@ class TestLaunchable < Test::Unit::TestCase
status: "TEST_PASSED", status: "TEST_PASSED",
stdout: "This is stdout", stdout: "This is stdout",
stderr: "This is stderr", stderr: "This is stderr",
createdAt: "2021-10-05T12:36:00" createdAt: "2021-10-05T12:36:00",
data: {
lineNumber: 10
}
} }
) )
json_stream_writer.close() json_stream_writer.close()
@ -38,7 +44,10 @@ class TestLaunchable < Test::Unit::TestCase
"status": "TEST_FAILED", "status": "TEST_FAILED",
"stdout": null, "stdout": null,
"stderr": null, "stderr": null,
"createdAt": "2021-10-05T12:34:00" "createdAt": "2021-10-05T12:34:00",
"data": {
"lineNumber": 1
}
}, },
{ {
"testPath": "file=test/test_a.rb#class=class1#testcase=testcase899", "testPath": "file=test/test_a.rb#class=class1#testcase=testcase899",
@ -46,7 +55,10 @@ class TestLaunchable < Test::Unit::TestCase
"status": "TEST_PASSED", "status": "TEST_PASSED",
"stdout": "This is stdout", "stdout": "This is stdout",
"stderr": "This is stderr", "stderr": "This is stderr",
"createdAt": "2021-10-05T12:36:00" "createdAt": "2021-10-05T12:36:00",
"data": {
"lineNumber": 10
}
} }
] ]
} }