Class: TestRunner::Cli::Command

Inherits:
OsCtl::Lib::Cli::Command
  • Object
show all
Defined in:
lib/test-runner/cli/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(method) ⇒ Object



5
6
7
8
9
10
# File 'lib/test-runner/cli/command.rb', line 5

def self.run(method)
  proc do |global_opts, opts, args|
    cmd = new(global_opts, opts, args)
    cmd.method(method).call
  end
end

Instance Method Details

#debugObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/test-runner/cli/command.rb', line 54

def debug
  require_args!('test')

  tl = TestRunner::TestList.new
  test = tl.by_path(args[0])

  ev = TestRunner::TestEvaluator.new(
    test,
    state_dir: File.join(state_dir, "os-test-#{test.name}"),
    sock_dir: File.join(state_dir, 'socks'),
    default_timeout: opts['timeout'],
    destructive: false
  )
  ev.interactive
end

#listObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/test-runner/cli/command.rb', line 12

def list
  tl = TestRunner::TestList.new
  tests =
    if args[0]
      tl.filter { |t| t.path_matches?(args[0]) }
    else
      tl.all
    end

  tests.each do |test|
    puts test.path
  end
end

#state_dirObject (protected)



72
73
74
# File 'lib/test-runner/cli/command.rb', line 72

def state_dir
  File.join(opts['state-dir'] || File.join(ENV['TMPDIR'] || '/tmp', 'os-test-runner'))
end

#testObject



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
# File 'lib/test-runner/cli/command.rb', line 26

def test
  tl = TestRunner::TestList.new
  tests =
    if args[0]
      tl.filter { |t| t.path_matches?(args[0]) }
    else
      tl.all
    end

  puts 'The following tests will be run:'
  tests.each { |t| puts "  #{t.path}" }
  puts

  exec = TestRunner::Executor.new(
    tests,
    state_dir:,
    jobs: opts['jobs'],
    default_timeout: opts['timeout'],
    stop_on_failure: opts['stop-on-failure'],
    destructive: opts['destructive']
  )
  results = exec.run

  return unless results.detect(&:unexpected_result?)

  raise 'one or more tests did not have expected results'
end