Class: Roby::App::TestServer

Inherits:
Object
  • Object
show all
Includes:
Hooks::InstanceHooks, Hooks
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.



123
124
125
126
# File 'lib/roby/app/test_server.rb', line 123

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)


111
112
113
# File 'lib/roby/app/test_server.rb', line 111

def manager
  @manager
end

#server_idObject (readonly)

A value that allows to identify this server uniquely

Usually the server PID



106
107
108
# File 'lib/roby/app/test_server.rb', line 106

def server_id
  @server_id
end

Class Method Details

.path(pid = Process.pid) ⇒ Object



36
37
38
# File 'lib/roby/app/test_server.rb', line 36

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

.start(id) ⇒ Object



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

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

.stopObject



119
120
121
# File 'lib/roby/app/test_server.rb', line 119

def self.stop
    DRb.stop_service
end

Instance Method Details

#discovery_finished(pid) ⇒ Object



132
133
134
# File 'lib/roby/app/test_server.rb', line 132

def discovery_finished(pid)
    run_hook :on_discovery_finished, pid
end

#discovery_start(pid) ⇒ Object



128
129
130
# File 'lib/roby/app/test_server.rb', line 128

def discovery_start(pid)
    run_hook :on_discovery_start, pid
end

#exception(pid, e) ⇒ Object



136
137
138
# File 'lib/roby/app/test_server.rb', line 136

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



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

define_hooks :on_discovery_finished

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

Hook called when a discovery process starts

Yield Parameters:

  • pid (Integer)

    the client PID



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

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)


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

define_hooks :on_exception

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

Hook called when a test finished

Yield Parameters:

  • pid (Integer)

    the client PID



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

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



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

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



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

define_hooks :on_test_result

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

Hook called when a test starts

Yield Parameters:

  • pid (Integer)

    the client PID



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

define_hooks :on_test_start

#test_finished(pid) ⇒ Object



153
154
155
# File 'lib/roby/app/test_server.rb', line 153

def test_finished(pid)
    run_hook :on_test_finished, pid
end

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



144
145
146
# File 'lib/roby/app/test_server.rb', line 144

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



148
149
150
151
# File 'lib/roby/app/test_server.rb', line 148

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



140
141
142
# File 'lib/roby/app/test_server.rb', line 140

def test_start(pid)
    run_hook :on_test_start, pid
end