forked from puppetlabs/puppetserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
119 lines (101 loc) · 4.15 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
PROJECT_ROOT = File.dirname(__FILE__)
ACCEPTANCE_ROOT = ENV['ACCEPTANCE_ROOT'] ||
File.join(PROJECT_ROOT, 'acceptance')
PUPPET_SRC = File.join(PROJECT_ROOT, 'ruby', 'puppet')
PUPPET_LIB = File.join(PROJECT_ROOT, 'ruby', 'puppet', 'lib')
PUPPET_SPEC = File.join(PROJECT_ROOT, 'ruby', 'puppet', 'spec')
FACTER_LIB = File.join(PROJECT_ROOT, 'ruby', 'facter', 'lib')
PUPPET_SERVER_RUBY_SRC = File.join(PROJECT_ROOT, 'src', 'ruby', 'puppet-server-lib')
TEST_GEMS_DIR = File.join(PROJECT_ROOT, 'vendor', 'test_gems')
TEST_BUNDLE_DIR = File.join(PROJECT_ROOT, 'vendor', 'test_bundle')
def assemble_default_beaker_config
if ENV["BEAKER_CONFIG"]
return ENV["BEAKER_CONFIG"]
end
platform = ENV['PLATFORM']
layout = ENV['LAYOUT']
if platform and layout
beaker_config = "#{ACCEPTANCE_ROOT}/config/beaker/jenkins/"
beaker_config += "#{platform}-#{layout}.cfg"
else
abort "Must specify an appropriate value for BEAKER_CONFIG. See acceptance/README.md"
end
return beaker_config
end
namespace :spec do
task :init do
if ! Dir.exists? TEST_GEMS_DIR
## Install bundler
## Line 1 launches the JRuby that we depend on via leiningen
## Line 2 programmatically runs 'gem install bundler' via the gem command that comes with JRuby
gem_install_bundler = <<-CMD
lein run -m org.jruby.Main \
-e 'load "META-INF/jruby.home/bin/gem"' install -i '#{TEST_GEMS_DIR}' --no-rdoc --no-ri bundler
CMD
sh gem_install_bundler
path = ENV['PATH']
## Install gems via bundler
## Line 1 makes sure that our local bundler script is on the path first
## Line 2 tells bundler to use puppet's Gemfile
## Line 3 tells JRuby where to look for gems
## Line 4 launches the JRuby that we depend on via leiningen
## Line 5 runs our bundle install script
bundle_install = <<-CMD
PATH='#{TEST_GEMS_DIR}/bin:#{path}' \
BUNDLE_GEMFILE='#{PUPPET_SRC}/Gemfile' \
GEM_HOME='#{TEST_GEMS_DIR}' GEM_PATH='#{TEST_GEMS_DIR}' \
PUPPET_LOADED=true \
lein run -m org.jruby.Main \
-S bundle install --path='#{TEST_BUNDLE_DIR}'
CMD
sh bundle_install
end
end
end
task :spec => ["spec:init"] do
## Run RSpec via our JRuby dependency
## Line 1 tells bundler to use puppet's Gemfile
## Line 2 tells JRuby where to look for gems
## Line 3 launches the JRuby that we depend on via leiningen
## Line 4 adds all our Ruby source to the JRuby LOAD_PATH
## Line 5 runs our rspec wrapper script
## <sarcasm-font>dang ole real easy man</sarcasm-font>
run_rspec_with_jruby = <<-CMD
BUNDLE_GEMFILE='#{PUPPET_SRC}/Gemfile' \
GEM_HOME='#{TEST_GEMS_DIR}' GEM_PATH='#{TEST_GEMS_DIR}' \
lein run -m org.jruby.Main \
-I'#{PUPPET_LIB}' -I'#{PUPPET_SPEC}' -I'#{FACTER_LIB}' -I'#{PUPPET_SERVER_RUBY_SRC}' \
./spec/run_specs.rb
CMD
sh run_rspec_with_jruby
end
namespace :test do
namespace :acceptance do
desc "Run beaker based acceptance tests"
task :beaker do |t, args|
# variables that take a limited set of acceptable strings
type = ENV["BEAKER_TYPE"] || "pe"
# variables that take pathnames
beakeropts = ENV["BEAKER_OPTS"] || ""
presuite = ENV["BEAKER_PRESUITE"] || "#{ACCEPTANCE_ROOT}/suites/pre_suite/#{type}"
postsuite = ENV["BEAKER_POSTSUITE"] || ""
helper = ENV["BEAKER_HELPER"] || "#{ACCEPTANCE_ROOT}/lib/helper.rb"
testsuite = ENV["BEAKER_TESTSUITE"] || "#{ACCEPTANCE_ROOT}/suites/tests"
loadpath = ENV["BEAKER_LOADPATH"] || ""
options = ENV["BEAKER_OPTIONSFILE"] || "#{ACCEPTANCE_ROOT}/config/beaker/options.rb"
# variables requiring some assembly
config = assemble_default_beaker_config
beaker = "beaker "
beaker += " -c #{config}"
beaker += " --helper #{helper}"
beaker += " --type #{type}"
beaker += " --options-file #{options}" if options != ''
beaker += " --load-path #{loadpath}" if loadpath != ''
beaker += " --pre-suite #{presuite}" if presuite != ''
beaker += " --post-suite #{postsuite}" if postsuite != ''
beaker += " --tests " + testsuite if testsuite != ''
beaker += " " + beakeropts
sh beaker
end
end
end