-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
instrument RSpec::Core::Runner to trace test session
- Loading branch information
1 parent
a6e08e2
commit 4ce7077
Showing
5 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../../ext/test" | ||
require_relative "ext" | ||
|
||
module Datadog | ||
module CI | ||
module Contrib | ||
module RSpec | ||
# Instrument RSpec::Core::Runner | ||
module Runner | ||
def self.included(base) | ||
base.prepend(InstanceMethods) | ||
end | ||
|
||
module InstanceMethods | ||
def run(err, out) | ||
return super unless configuration[:enabled] | ||
|
||
test_session = CI.start_test_session( | ||
tags: { | ||
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK, | ||
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::RSpec::Integration.version.to_s, | ||
CI::Ext::Test::TAG_TYPE => Ext::TEST_TYPE | ||
}, | ||
service: configuration[:service_name] | ||
) | ||
|
||
result = super | ||
|
||
if result != 0 | ||
test_session.failed! | ||
else | ||
test_session.passed! | ||
end | ||
test_session.finish | ||
|
||
result | ||
end | ||
|
||
private | ||
|
||
def configuration | ||
Datadog.configuration.ci[:rspec] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Datadog | ||
module CI | ||
module Contrib | ||
module RSpec | ||
module Runner | ||
def self.included: (untyped base) -> untyped | ||
|
||
module InstanceMethods | ||
include ::RSpec::Core::Runner | ||
|
||
def run: (untyped err, untyped out) -> untyped | ||
|
||
private | ||
|
||
def configuration: () -> untyped | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters