Class: Datadog::CI::TestVisibility::Context::Global
- Inherits:
-
Object
- Object
- Datadog::CI::TestVisibility::Context::Global
- Defined in:
- lib/datadog/ci/test_visibility/context/global.rb
Overview
This context is shared between threads and represents the current test session and test module.
Instance Method Summary collapse
- #active_test_module ⇒ Object
- #active_test_session ⇒ Object
- #active_test_suite(test_suite_name) ⇒ Object
- #deactivate_test_module! ⇒ Object
- #deactivate_test_session! ⇒ Object
- #deactivate_test_suite!(test_suite_name) ⇒ Object
- #fetch_or_activate_test_module(&block) ⇒ Object
- #fetch_or_activate_test_session(&block) ⇒ Object
- #fetch_or_activate_test_suite(test_suite_name, &block) ⇒ Object
- #inheritable_session_tags ⇒ Object
-
#initialize ⇒ Global
constructor
A new instance of Global.
- #service ⇒ Object
Constructor Details
#initialize ⇒ Global
Returns a new instance of Global.
9 10 11 12 13 14 15 16 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 9 def initialize # we are using Monitor instead of Mutex because it is reentrant @mutex = Monitor.new @test_session = nil @test_module = nil @test_suites = {} end |
Instance Method Details
#active_test_module ⇒ Object
36 37 38 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 36 def active_test_module @test_module end |
#active_test_session ⇒ Object
40 41 42 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 40 def active_test_session @test_session end |
#active_test_suite(test_suite_name) ⇒ Object
44 45 46 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 44 def active_test_suite(test_suite_name) @mutex.synchronize { @test_suites[test_suite_name] } end |
#deactivate_test_module! ⇒ Object
71 72 73 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 71 def deactivate_test_module! @mutex.synchronize { @test_module = nil } end |
#deactivate_test_session! ⇒ Object
67 68 69 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 67 def deactivate_test_session! @mutex.synchronize { @test_session = nil } end |
#deactivate_test_suite!(test_suite_name) ⇒ Object
75 76 77 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 75 def deactivate_test_suite!(test_suite_name) @mutex.synchronize { @test_suites.delete(test_suite_name) } end |
#fetch_or_activate_test_module(&block) ⇒ Object
24 25 26 27 28 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 24 def fetch_or_activate_test_module(&block) @mutex.synchronize do @test_module ||= block.call end end |
#fetch_or_activate_test_session(&block) ⇒ Object
30 31 32 33 34 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 30 def fetch_or_activate_test_session(&block) @mutex.synchronize do @test_session ||= block.call end end |
#fetch_or_activate_test_suite(test_suite_name, &block) ⇒ Object
18 19 20 21 22 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 18 def fetch_or_activate_test_suite(test_suite_name, &block) @mutex.synchronize do @test_suites[test_suite_name] ||= block.call end end |
#inheritable_session_tags ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 56 def @mutex.synchronize do test_session = @test_session if test_session test_session. else {} end end end |
#service ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/datadog/ci/test_visibility/context/global.rb', line 48 def service @mutex.synchronize do # thank you RBS for this weirdness test_session = @test_session test_session.service if test_session end end |