Class: Roby::App::TestReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/roby/app/test_reporter.rb

Overview

Minitest reporter for a client/server scheme in autotest

Note that the idea and a big chunk of the implementation has been taken from the minitest-server plugin. The main differences is that it accounts for load errors (exceptions that happen outside of minitest itself) and is using DRoby’s marshalling for exceptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pid, slave_name, server_pid, manager: DRoby::Marshal.new) ⇒ TestReporter

Returns a new instance of TestReporter.



19
20
21
22
23
24
25
26
# File 'lib/roby/app/test_reporter.rb', line 19

def initialize(pid, slave_name, server_pid, manager: DRoby::Marshal.new)
    @pid = pid
    @slave_name = slave_name
    uri = TestServer.path(server_pid)
    @server = DRbObject.new_with_uri uri
    @manager = manager
    super()
end

Instance Attribute Details

#managerObject (readonly)

Returns the value of attribute manager.



14
15
16
# File 'lib/roby/app/test_reporter.rb', line 14

def manager
  @manager
end

#pidObject (readonly)

Returns the value of attribute pid.



14
15
16
# File 'lib/roby/app/test_reporter.rb', line 14

def pid
  @pid
end

#serverObject (readonly)

Returns the value of attribute server.



14
15
16
# File 'lib/roby/app/test_reporter.rb', line 14

def server
  @server
end

#slave_nameObject (readonly)

Returns the value of attribute slave_name.



14
15
16
# File 'lib/roby/app/test_reporter.rb', line 14

def slave_name
  @slave_name
end

Instance Method Details

#discovery_finishedObject



37
38
39
# File 'lib/roby/app/test_reporter.rb', line 37

def discovery_finished
    server.discovery_finished(pid)
end

#discovery_startObject



33
34
35
# File 'lib/roby/app/test_reporter.rb', line 33

def discovery_start
    server.discovery_start(pid)
end

#exception(e) ⇒ Object



28
29
30
31
# File 'lib/roby/app/test_reporter.rb', line 28

def exception(e)
    @has_failures = true
    server.exception(pid, manager.dump(e))
end

#prerecord(klass, method_name) ⇒ Object

This method is part of the minitest API



46
47
48
49
# File 'lib/roby/app/test_reporter.rb', line 46

def prerecord(klass, method_name)
    file, = klass.instance_method(method_name).source_location
    server.test_method(pid, file, klass.name, method_name)
end

#record(result) ⇒ Object

This method is part of the minitest API … cannot change its name



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/roby/app/test_reporter.rb', line 52

def record(result)
    r = result
    if r.respond_to?(:source_location) # Minitest 3.11+
        class_name = r.klass
        file, = r.source_location
    else
        c = r.class
        file, = c.instance_method(r.name).source_location
        class_name = c.name
    end
    failures = manager.dump(r.failures)
    @has_failures ||= r.failures.any? { |e| !e.kind_of?(Minitest::Skip) }
    server.test_result(pid, file, class_name, r.name, failures, r.assertions, r.time)
end

#test_finishedObject



67
68
69
# File 'lib/roby/app/test_reporter.rb', line 67

def test_finished
    server.test_finished(pid)
end

#test_startObject



41
42
43
# File 'lib/roby/app/test_reporter.rb', line 41

def test_start
    server.test_start(pid)
end