Class: Datadog::CI::Context::Local
- Inherits:
-
Object
- Object
- Datadog::CI::Context::Local
- Defined in:
- lib/datadog/ci/context/local.rb
Instance Method Summary collapse
- #activate_test!(test) ⇒ Object
- #active_test ⇒ Object
- #deactivate_test!(test) ⇒ Object
-
#initialize ⇒ Local
constructor
A new instance of Local.
Constructor Details
#initialize ⇒ Local
Returns a new instance of Local.
7 8 9 10 11 |
# File 'lib/datadog/ci/context/local.rb', line 7 def initialize @key = :datadog_ci_active_test self.active_test = nil end |
Instance Method Details
#activate_test!(test) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/datadog/ci/context/local.rb', line 13 def activate_test!(test) raise "Nested tests are not supported. Currently active test: #{active_test}" unless active_test.nil? if block_given? begin self.active_test = test yield ensure self.active_test = nil end else self.active_test = test end end |
#active_test ⇒ Object
38 39 40 |
# File 'lib/datadog/ci/context/local.rb', line 38 def active_test Thread.current[@key] end |
#deactivate_test!(test) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/datadog/ci/context/local.rb', line 28 def deactivate_test!(test) return if active_test.nil? if active_test == test self.active_test = nil else raise "Trying to deactivate test #{test}, but currently active test is #{active_test}" end end |