Module: Anyt::Cli

Defined in:
lib/anyt/cli.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.runObject

CLI entrypoint



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/anyt/cli.rb', line 18

def run
  parse_options!

  ActionCable.server.config.logger = Rails.logger = AnyCable.logger

  result = 1

  $stdout.puts "Starting AnyT v#{Anyt::VERSION} (pid: #{Process.pid})\n"

  begin
    # "Enable" AnyCable as early as possible to activate all the features in tests
    unless Anyt.config.use_action_cable
      ActionCable.server.config.cable = {"adapter" => "any_cable"}
      require "anycable-rails"
    end

    # Load all test scenarios
    Tests.load_tests unless @skip_tests

    Rails.application.initialize!

    # Start RPC server (unless specified otherwise, e.g. when
    # we want to test Action Cable itself)
    unless @skip_rpc
      RPC.start

      if @only_rpc
        RPC.server.wait_till_terminated
        return
      end
    end

    # Start webosocket server under test
    Command.run

    unless @skip_tests
      # Run tests
      result = Tests.run ? 0 : 1
    end

    wait_till_terminated if @only_rails
  rescue Interrupt => e
    $stdout.puts "#{e.message}. Good-bye!"
  ensure
    RPC.stop unless @skip_rpc
    Command.stop
  end

  result
end