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
|
# File 'lib/kaya/background_jobs/workers/execution_performer.rb', line 7
def perform(result_id)
puts result_id
Kaya::Support::Configuration.get
Kaya::Database::MongoConnector.new Kaya::Support::Configuration.db_connection_data
result = Kaya::Results::Result.get(result_id)
p result
result.kaya_report_file_name= "kaya_report_#{result_id}.html"
begin
File.delete("#{Dir.pwd}/Gemfile.lock")
rescue
end
if !Kaya::Support::ChangeInspector.is_there_gemfile_lock?
bundle_output = Kaya::Support::Console.execute "bundle install"
$K_LOG.debug "[result:#{result.id}] Bundle install performed" if $K_LOG
elsif Kaya::Support::ChangeInspector.is_there_a_change?
bundle_output = Kaya::Support::Console.execute "bundle update"
$K_LOG.debug "[result:#{result.id}] Bundle update performed" if $K_LOG
end
if bundle_output
result.save_to_bundle_output bundle_output
raise "An error ocurred installing gem" if bundle_output.include? "Could not find"
end
result.kaya_command= "#{Kaya::Support::Configuration.headless?} cucumber #{result.command} -f pretty -f html -o kaya/temp/#{result.kaya_report_file_name} #{result.custom_params_values} _id=#{result.id} "
result.console_output_file_name= "kaya_co_#{result.id}.out"
result.save!
command = "#{result.kaya_command} 2>&1 | tee -a kaya/temp/#{result.console_output_file_name}"
$K_LOG.debug "[result:#{result.id}] Running in headless mode" if $K_LOG and Kaya::Support::Configuration.headless?
Dir.mkdir "#{Dir.pwd}/kaya/temp" unless Dir.exist? "#{Dir.pwd}/kaya/temp"
$K_LOG.debug "[result:#{result.id}] Creating process" if $K_LOG
result.pid= Kaya::Support::Processes.fork_this command
result.running!
result.save!
$K_LOG.debug "[result:#{result.id}] Process => #{result.pid}(PID) | command => saved | result as => running" if $K_LOG
suite = Kaya::Suites::Suite.get(result.suite_id)
begin
suite.check_last_result!
sleep 2
end while not suite.is_ready?
end
|