Class: Roby::App::TestServer

Inherits:
Object
  • Object
show all
Includes:
Hooks, Hooks::InstanceHooks
Defined in:
lib/roby/app/test_server.rb

Overview

DRuby server for a client/server scheme in autotest

The client side is implemented in TestReporter

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hooks

included

Constructor Details

#initialize(server_id, manager = DRoby::Marshal.new(auto_create_plans: true)) ⇒ TestServer

Returns a new instance of TestServer.



125
126
127
128
# File 'lib/roby/app/test_server.rb', line 125

def initialize(server_id, manager = DRoby::Marshal.new(auto_create_plans: true))
    @server_id = server_id
    @manager = manager
end

Instance Attribute Details

#managerAutorespawn::Manager (readonly)

The autorespawn manager

Returns:

  • (Autorespawn::Manager)


113
114
115
# File 'lib/roby/app/test_server.rb', line 113

def manager
  @manager
end

#server_idObject (readonly)

A value that allows to identify this server uniquely

Usually the server PID



108
109
110
# File 'lib/roby/app/test_server.rb', line 108

def server_id
  @server_id
end

Class Method Details

.path(pid = Process.pid) ⇒ Object



38
39
40
# File 'lib/roby/app/test_server.rb', line 38

def self.path(pid = Process.pid)
    "drbunix:#{Dir.tmpdir}/minitest.#{pid}"
end

.start(id) ⇒ Object



115
116
117
118
119
# File 'lib/roby/app/test_server.rb', line 115

def self.start(id)
    server = new(id)
    DRb.start_service path, server
    server
end

.stopObject



121
122
123
# File 'lib/roby/app/test_server.rb', line 121

def self.stop
    DRb.stop_service
end

Instance Method Details

#discovery_finished(pid) ⇒ Object



134
135
136
# File 'lib/roby/app/test_server.rb', line 134

def discovery_finished(pid)
    run_hook :on_discovery_finished, pid
end

#discovery_start(pid) ⇒ Object



130
131
132
# File 'lib/roby/app/test_server.rb', line 130

def discovery_start(pid)
    run_hook :on_discovery_start, pid
end

#exception(pid, e) ⇒ Object



138
139
140
# File 'lib/roby/app/test_server.rb', line 138

def exception(pid, e)
    run_hook :on_exception, pid, manager.local_object(e)
end

#on_discovery_finished {|pid, id| ... } ⇒ Object

Hook called when a discovery process finishes

Yield Parameters:

  • pid (Integer)

    the client PID

  • id (Hash)

    the test ID



66
# File 'lib/roby/app/test_server.rb', line 66

define_hooks :on_discovery_finished

#on_discovery_start {|pid| ... } ⇒ Object

Hook called when a discovery process starts

Yield Parameters:

  • pid (Integer)

    the client PID



58
# File 'lib/roby/app/test_server.rb', line 58

define_hooks :on_discovery_start

#on_exception {|pid, exception| ... } ⇒ Object

Hook called when an exception has been caught by Autorespawn

Yield Parameters:

  • pid (Integer)

    the client PID

  • exception (Exception)


51
# File 'lib/roby/app/test_server.rb', line 51

define_hooks :on_exception

#on_test_finished {|pid| ... } ⇒ Object

Hook called when a test finished

Yield Parameters:

  • pid (Integer)

    the client PID



103
# File 'lib/roby/app/test_server.rb', line 103

define_hooks :on_test_finished

#on_test_method {|pid, file, test_case_name, test_name| ... } ⇒ Object

Hook called when a test method starts its execution

Yield Parameters:

  • pid (Integer)

    the client PID

  • file (String)

    the file containing the test

  • test_case_name (String)

    the test case name

  • test_name (String)

    the test name



83
# File 'lib/roby/app/test_server.rb', line 83

define_hooks :on_test_method

#on_test_result {|pid, file, test_case_name, test_name, failures, assertions, time| ... } ⇒ Object

Hook called when a test has been executed

Yield Parameters:

  • pid (Integer)

    the client PID

  • file (String)

    the file containing the test

  • test_case_name (String)

    the test case name

  • test_name (String)

    the test name

  • failures (Array<Minitest::Assertion>)

    the list of test failures

  • assertions (Integer)

    the number of assertions

  • time (Time)

    the time spent running the test



96
# File 'lib/roby/app/test_server.rb', line 96

define_hooks :on_test_result

#on_test_start {|pid| ... } ⇒ Object

Hook called when a test starts

Yield Parameters:

  • pid (Integer)

    the client PID



73
# File 'lib/roby/app/test_server.rb', line 73

define_hooks :on_test_start

#test_finished(pid) ⇒ Object



155
156
157
# File 'lib/roby/app/test_server.rb', line 155

def test_finished(pid)
    run_hook :on_test_finished, pid
end

#test_method(pid, file, klass, method) ⇒ Object



146
147
148
# File 'lib/roby/app/test_server.rb', line 146

def test_method(pid, file, klass, method)
    run_hook :on_test_method, pid, file, klass, method
end

#test_result(pid, file, klass, method, fails, assertions, time) ⇒ Object



150
151
152
153
# File 'lib/roby/app/test_server.rb', line 150

def test_result(pid, file, klass, method, fails, assertions, time)
    run_hook :on_test_result, pid, file, klass, method,
             manager.local_object(fails), assertions, time
end

#test_start(pid) ⇒ Object



142
143
144
# File 'lib/roby/app/test_server.rb', line 142

def test_start(pid)
    run_hook :on_test_start, pid
end