-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrakefile
97 lines (88 loc) · 2.84 KB
/
rakefile
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env rake
# encoding: utf-8
require 'fileutils'
require 'rake/clean'
begin
task :default => :spec
desc "Run all specs in spec directory"
task :spec do
fail unless system("bundle exec rspec spec")
end
require 'rspec/core/rake_task'
# don't know why I must use it with an external command
# RSpec::Core::RakeTask.new(:spec)
end
MockScriptDir = File.join(Dir.pwd, 'mock_scripts')
batchFiles = [
'install_elexis.rb',
'mysql_switch_db_server.rb',
'mysql_dump_elexis.rb',
'mysql_load_main.rb',
'mysql_load_test.rb',
'pg_switch_db_server.rb',
'pg_dump_elexis.rb',
'pg_load_main.rb',
'pg_load_test.rb',
'backup_encrypted.rb',
'reboot.sh',
'halt.sh',
'start.rb',
]
mock_script_files = batchFiles.map{ |x| File.join(MockScriptDir, x) }
mock_script_files.each { |mock_script|
task mock_script do |t|
FileUtils.makedirs(MockScriptDir, :verbose => true) unless File.directory?(MockScriptDir)
task file('mock_config.yaml') => mock_script
file mock_script do
out = File.open(mock_script, 'w+')
out.puts("#!/bin/bash -v")
out.puts("echo File $0 called with args $*")
if /load/.match(File.basename(mock_script)) # make these take 3 seconds and fail
puts "mock_script aus #{t}"
out.puts("sleep 3")
out.puts("exit 1")
else # short and pass
out.puts("sleep 0.1")
out.puts("exit")
end
out.close
File.chmod(0777, mock_script)
end unless File.exists?(mock_script)
end
}
CLOBBER.include(MockScriptDir)
desc "Mock Scripts erstellen und mock_config.yaml ergänzen"
task :mock_scripts => mock_script_files
task :mock_scripts => file('mock_config.yaml')
file 'mock_config.yaml' => 'demo_config.yaml' do |t|
src = 'demo_config.yaml'
target = 'mock_config.yaml'
unless uptodate?(target, [ src ])
puts "Patching #{target} to use scrpts from #{MockScriptDir}"
inhalt = IO.readlines(src)
out = File.open(target, 'w+')
inhalt.each{ |line| out.puts line.gsub('/usr/local/bin', MockScriptDir) }
out.close
end
end
CLOBBER.include('mock_config.yaml')
ScreenshotTarget = 'screenshots_done'
wikiImages = 'wiki/images'
desc "Mit watir die screenshots von Elexis-Cockpit erstellen
set environment variable COCKPIT_BROWSER to use either firefox (default), chrome or ie"
file ScreenshotTarget => [ :spec, :mock_scripts ] do
unless File.exists?(ScreenshotTarget)
FileUtils.rm_rf(wikiImages)
# We want to use mocks for the screenshots
ENV['COCKPIT_CONFIG'] = 'mock_config.yaml'
ENV['RUNNING_WATIR_TEST'] = "true"
okay = system('spec/gen_screenshots.rb')
if okay then
out = File.open(ScreenshotTarget, 'w+')
out.puts "Watir-Tests did run successfully on #{Time.now}"
out.puts "Created #{Dir.glob(wikiImages+'/*.png').size} screenshots in #{wikiImages}"
end
end
end
CLOBBER.include(ScreenshotTarget)
CLOBBER.include(wikiImages)