Class: Buildkite::TestCollector::MinitestPlugin::Trace

Inherits:
Object
  • Object
show all
Defined in:
lib/buildkite/test_collector/minitest_plugin/trace.rb

Constant Summary collapse

RESULT_CODES =
{
  '.' => 'passed',
  'F' => 'failed',
  'E' => 'failed',
  'S' => 'pending',
}
FILE_PATH_REGEX =
/^(.*?\.(rb|feature))/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(example, history:) ⇒ Trace

Returns a new instance of Trace.



18
19
20
21
# File 'lib/buildkite/test_collector/minitest_plugin/trace.rb', line 18

def initialize(example, history:)
  @example = example
  @history = history
end

Instance Attribute Details

#exampleObject

Returns the value of attribute example.



5
6
7
# File 'lib/buildkite/test_collector/minitest_plugin/trace.rb', line 5

def example
  @example
end

#failure_expanded=(value) ⇒ Object

Sets the attribute failure_expanded

Parameters:

  • value

    the value to set the attribute failure_expanded to.



6
7
8
# File 'lib/buildkite/test_collector/minitest_plugin/trace.rb', line 6

def failure_expanded=(value)
  @failure_expanded = value
end

#failure_reason=(value) ⇒ Object

Sets the attribute failure_reason

Parameters:

  • value

    the value to set the attribute failure_reason to.



6
7
8
# File 'lib/buildkite/test_collector/minitest_plugin/trace.rb', line 6

def failure_reason=(value)
  @failure_reason = value
end

#historyObject (readonly)

Returns the value of attribute history.



7
8
9
# File 'lib/buildkite/test_collector/minitest_plugin/trace.rb', line 7

def history
  @history
end

Instance Method Details

#as_hashObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/buildkite/test_collector/minitest_plugin/trace.rb', line 31

def as_hash
  strip_invalid_utf8_chars(
    scope: example.class.name,
    name: example.name,
    location: location,
    file_name: file_name,
    result: result,
    failure_reason: failure_reason,
    failure_expanded: failure_expanded,
    history: history,
  ).select { |_, value| !value.nil? }
end

#resultObject



23
24
25
# File 'lib/buildkite/test_collector/minitest_plugin/trace.rb', line 23

def result
  RESULT_CODES[example.result_code]
end

#source_locationObject



27
28
29
# File 'lib/buildkite/test_collector/minitest_plugin/trace.rb', line 27

def source_location
  @source_location ||= example.method(example.name).source_location
end