File: serverspec-runner

package info (click to toggle)
serverspec-runner 1.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 192 kB
  • ctags: 18
  • sloc: ruby: 268; makefile: 6
file content (73 lines) | stat: -rwxr-xr-x 2,513 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
#!/usr/bin/env ruby

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])

require 'rubygems'
require 'rake'
require 'getoptlong'

raketask =  'spec'
showtasks = false

opts = GetoptLong.new(
  ["--scenario",     "-s", GetoptLong::REQUIRED_ARGUMENT],
  ["--specroot",     "-r", GetoptLong::REQUIRED_ARGUMENT],
  ["--ssh_options",  "-o", GetoptLong::REQUIRED_ARGUMENT],
  ["--explain",      "-e", GetoptLong::REQUIRED_ARGUMENT],
  ["--tableformat",  "-t", GetoptLong::REQUIRED_ARGUMENT],
  ["--parallel",     "-p", GetoptLong::REQUIRED_ARGUMENT],
  ["--help",         "-h", GetoptLong::NO_ARGUMENT],
  ["--raketask",     "-1", GetoptLong::REQUIRED_ARGUMENT],
  ["--tmpdir",       "-2", GetoptLong::REQUIRED_ARGUMENT],
  ["--tasks",        "-T", GetoptLong::NO_ARGUMENT]
)

opts.each do |opt, arg|
  case opt
  when '--scenario'
    ENV['scenario'] = arg
  when '--specroot'
    ENV['specroot'] = arg
  when '--ssh_options'
    ENV['ssh_options'] = arg
  when '--explain'
    ENV['explain'] = arg
  when '--tableformat'
    ENV['tableformat'] = arg
  when '--parallel'
    ENV['parallels'] = arg
  when '--tmpdir'
    ENV['tmpdir'] = arg
  when '--raketask'
    raketask = arg
  when '--tasks'
    showtasks = true
  else
    puts "Usage: serverspec-runner (options)"
    puts "-s, --scenario     SCENARIO_FILE        path to scenario yml file"
    puts "-r, --specroot     SPEC_ROOT            path to spec tests root dir"
    puts "-o, --ssh_options  SSH_OPTIONS_FILE     path to ssh options yml file"
    puts "-e, --explain      (short|long)         specify result explain length(default: short)"
    puts "-t, --tableformat  (aa|mkd|csv|bool)    specify result table type(default: aa)"
    puts "-T, --tasks                             display the tasks with descriptions(exec rake -T)"
    puts "-p, --parallel                          execute tasks in parallel"
    puts "-1, --raketask     RAKE_TASK_NAME       execute specified rake task only(ex: spec:test::anyhost-01)"
    puts "-h, --help                              show help"
    exit 0
  end
end

Rake::TaskManager.record_task_metadata = showtasks
load "/usr/share/serverspec-runner/Rakefile"

if showtasks
  mLen = (Rake.application.tasks.max_by { |t| t.name_with_args.size }).name_with_args.size
  Rake.application.tasks.reject{|t| ['spec:all', 'spec:stdout'].include?(t.name_with_args)}.each do |t|
    printf("%-#{mLen + 2}s  # %s\n",
      t.name_with_args,
      t.comment)
  end
  exit(0)
end

Rake::Task[raketask.to_sym].invoke