Module: TestR::Server

Included in:
Driver, Master
Defined in:
lib/testr/server.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(server) ⇒ Object



33
34
35
# File 'lib/testr/server.rb', line 33

def self.extended server
  trap(:SIGTERM){ server.quit }
end

Instance Method Details

#loopObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/testr/server.rb', line 10

def loop
  (@client = STDOUT.dup).sync = true
  STDOUT.reopen(STDERR).sync = true

  catch :testr_server_quit do
    while line = STDIN.gets
      warn "#{caller[2]} RECV #{line.chomp}" if $DEBUG

      command = JSON.load(line)
      method = command.first

      if respond_to? method and method != __method__ # prevent loops
        @command, @command_line = command, line
        __send__(*command)
      else
        warn "#{self}: bad command: #{method}"
      end
    end
  end
rescue Interrupt
  # forced quit
end

#quitObject



6
7
8
# File 'lib/testr/server.rb', line 6

def quit
  throw :testr_server_quit
end