Class: TestRunner::Cli::App

Inherits:
Object
  • Object
show all
Includes:
GLI::App
Defined in:
lib/test-runner/cli/app.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.getObject



7
8
9
10
11
# File 'lib/test-runner/cli/app.rb', line 7

def self.get
  cli = new
  cli.setup
  cli
end

.runObject



13
14
15
# File 'lib/test-runner/cli/app.rb', line 13

def self.run
  exit(get.run(ARGV))
end

Instance Method Details

#setupObject



17
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/test-runner/cli/app.rb', line 17

def setup
  program_desc 'vpsAdminOS test suite evaluator'
  version TestRunner::VERSION
  subcommand_option_handling :normal
  preserve_argv true
  arguments :strict
  hide_commands_without_desc true

  desc 'List available tests'
  arg_name '[path-pattern]'
  command 'ls' do |c|
    c.desc 'Filter by label'
    c.flag %w[l label], multiple: true

    c.desc 'Filter by tag'
    c.flag %w[t tag], multiple: true

    c.desc 'Filter by metadata expression'
    c.flag 'filter', multiple: true

    c.desc 'Nix system to evaluate tests for'
    c.flag 'system', default_value: TestRunner::NixCli::DEFAULT_SYSTEM

    c.desc 'Path to a Nix file returning the test framework configuration'
    c.flag 'test-config'

    c.action(&Command.run(:list))
  end

  desc 'Run test'
  arg_name '[path-pattern]'
  command 'test' do |c|
    c.desc 'Filter by label'
    c.flag %w[l label], multiple: true

    c.desc 'Filter by tag'
    c.flag %w[t tag], multiple: true

    c.desc 'Filter by metadata expression'
    c.flag 'filter', multiple: true

    c.desc 'How many tests to run in parallel, or auto'
    c.flag %w[j jobs], default_value: '1'

    c.desc 'Maximum memory available to running test VMs, in MiB'
    c.flag 'max-memory-mib', type: Integer

    c.desc 'Maximum /dev/shm space available to running test VMs, in MiB'
    c.flag 'max-shm-mib', type: Integer

    c.desc 'Maximum CPUs available to running test VMs'
    c.flag 'max-cpus', type: Integer

    c.desc 'Memory to reserve from detected capacity, in MiB'
    c.flag 'memory-reserve-mib', type: Integer

    c.desc '/dev/shm space to reserve from detected capacity, in MiB'
    c.flag 'shm-reserve-mib', type: Integer

    c.desc 'CPUs to reserve from detected capacity'
    c.flag 'cpu-reserve', type: Integer

    c.desc 'Memory overcommit factor for detected capacity'
    c.flag 'memory-overcommit'

    c.desc '/dev/shm overcommit factor for detected capacity'
    c.flag 'shm-overcommit'

    c.desc 'CPU overcommit factor for detected capacity'
    c.flag 'cpu-overcommit'

    c.desc 'Seconds between detected resource capacity refreshes'
    c.flag 'resource-refresh-interval'

    c.desc 'Recreate disk files'
    c.switch %w[f fresh], default_value: false

    c.desc 'Nix system to evaluate tests for'
    c.flag 'system', default_value: TestRunner::NixCli::DEFAULT_SYSTEM

    c.desc 'Path to a Nix file returning the test framework configuration'
    c.flag 'test-config'

    c.desc 'Default timeout for machine commands, in seconds'
    c.flag %w[timeout], type: Integer, default_value: 900

    c.desc 'Stop testing when one test fails'
    c.switch 'stop-on-failure', default_value: false

    c.desc 'Determines where machine disk files are kept'
    c.switch 'destructive', default_value: true

    c.desc 'Directory where test logs and state are stored'
    c.flag 'state-dir'

    c.action(&Command.run(:test))
  end

  desc 'Debug test'
  arg_name '<test>'
  command 'debug' do |c|
    c.desc 'Directory where test logs and state are stored'
    c.flag 'state-dir'

    c.desc 'Nix system to evaluate tests for'
    c.flag 'system', default_value: TestRunner::NixCli::DEFAULT_SYSTEM

    c.desc 'Path to a Nix file returning the test framework configuration'
    c.flag 'test-config'

    c.desc 'Default timeout for machine commands, in seconds'
    c.flag %w[t timeout], type: Integer, default_value: 900

    c.action(&Command.run(:debug))
  end

  default_command 'ls'
end