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
|
# File 'lib/vagrant-rspec-ci/command.rb', line 8
def execute
opts = OptionParser.new do |opts|
opts.banner = "Usage: vagrant rpsec [vm-name]"
end
argv = parse_options(opts)
return if !argv
with_target_vms(argv[0]) do |vm|
s = vm.state.short_description
if s != 'running'
vm.ui.error("VM not running. Not running tests.")
else
vm.config.rspec.finalize!
tests = expand_test_list(vm.config.rspec)
cmd = rspec_command(vm)
tests.each do |testfile|
vm.ui.info("Running rspec test: #{testfile}")
cmd = "#{cmd} #{testfile}"
env = prep_env(vm)
system(env, cmd)
result = $?
if result.nil? then
vm.ui.error "Unable to execute rspec command: #{$!} \n #{cmd}"
elsif result.exitstatus == 1 then
vm.ui.warn "Rspec test #{testfile} has at least one failure - see report output for details"
elsif result.exitstatus == 0 then
vm.ui.success "Rspec test #{testfile} passed"
else
vm.ui.error "Unrecognized exit code from rspec: #{result.exitstatus}\nfor:#{cmd}"
end
end
if tests.empty?
vm.ui.info("No rspec tests found.")
end
end
end
end
|