2010-08-14 06:26:04 +00:00
|
|
|
require 'rubygems'
|
|
|
|
require 'bundler/setup'
|
2010-01-22 03:09:18 +00:00
|
|
|
require 'rake/testtask'
|
2010-08-14 06:26:04 +00:00
|
|
|
Bundler::GemHelper.install_tasks
|
2010-01-22 03:09:18 +00:00
|
|
|
|
2011-11-05 22:36:38 +00:00
|
|
|
task :default => "test:unit"
|
2010-02-10 06:48:08 +00:00
|
|
|
|
2011-11-05 22:36:38 +00:00
|
|
|
namespace :test do
|
|
|
|
Rake::TestTask.new do |t|
|
|
|
|
t.name = "unit"
|
|
|
|
t.libs << "test/unit"
|
|
|
|
t.pattern = "test/unit/**/*_test.rb"
|
|
|
|
end
|
|
|
|
|
|
|
|
Rake::TestTask.new do |t|
|
|
|
|
t.name = "acceptance"
|
|
|
|
t.libs << "test/acceptance"
|
|
|
|
t.pattern = "test/acceptance/**/*_test.rb"
|
|
|
|
end
|
2010-01-22 05:07:01 +00:00
|
|
|
end
|
2011-11-03 04:09:38 +00:00
|
|
|
|
|
|
|
namespace :acceptance do
|
|
|
|
desc "Generates the configuration for acceptance tests from current source."
|
|
|
|
task :config do
|
|
|
|
require 'yaml'
|
|
|
|
require 'posix-spawn'
|
|
|
|
|
|
|
|
require File.expand_path("../lib/vagrant/version", __FILE__)
|
|
|
|
require File.expand_path('../test/acceptance/helpers/tempdir', __FILE__)
|
|
|
|
|
|
|
|
# Generate the binstubs for the Vagrant binary
|
|
|
|
tempdir = Tempdir.new
|
|
|
|
pid, stdin, stdout, stderr =
|
|
|
|
POSIX::Spawn.popen4("bundle", "install", "--binstubs", tempdir.path)
|
|
|
|
pid, status = Process.waitpid2(pid)
|
|
|
|
if status.exitstatus != 0
|
|
|
|
# Bundle install failed...
|
|
|
|
puts "Bundle install failed! Error:"
|
|
|
|
puts stderr.read
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
|
|
|
# Generate the actual configuration
|
|
|
|
config = {
|
|
|
|
"vagrant_path" => File.join(tempdir.path, "vagrant"),
|
|
|
|
"vagrant_version" => Vagrant::VERSION,
|
|
|
|
"env" => {
|
|
|
|
"BUNDLE_GEMFILE" => File.expand_path("../Gemfile", __FILE__)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
File.open("acceptance_config.yml", "w+") do |f|
|
|
|
|
f.write(YAML.dump(config))
|
|
|
|
end
|
|
|
|
|
|
|
|
puts <<-OUTPUT
|
|
|
|
Acceptance test configuration is now in this directory in
|
|
|
|
"acceptance_config.yml." Set your ACCEPTANCE_CONFIG environmental
|
|
|
|
variable to this file and run any of the acceptance tests now.
|
|
|
|
OUTPUT
|
|
|
|
end
|
|
|
|
end
|