Test running shell scripts inline

This commit is contained in:
Mitchell Hashimoto 2011-12-14 19:02:10 -08:00
parent 6dbade0fc6
commit 9e4475cb77
2 changed files with 27 additions and 3 deletions

View File

@ -27,9 +27,12 @@ module Vagrant
end end
# Validate the existence of a script to upload # Validate the existence of a script to upload
expanded_path = Pathname.new(path).expand_path(env.root_path) if path
if path && !expanded_path.file? expanded_path = Pathname.new(path).expand_path(env.root_path)
errors.add(I18n.t("vagrant.provisioners.shell.path_invalid", :path => expanded_path)) if !expanded_path.file?
errors.add(I18n.t("vagrant.provisioners.shell.path_invalid",
:path => expanded_path))
end
end end
# There needs to be a path to upload the script to # There needs to be a path to upload the script to

View File

@ -29,4 +29,25 @@ vf
result_file.exist?.should be result_file.exist?.should be
result_file.read.should == "success\n" result_file.read.should == "success\n"
end end
it "runs an inline script" do
require_box("default")
assert_execute("vagrant", "box", "add", "base", box_path("default"))
environment.workdir.join("Vagrantfile").open("w+") do |f|
f.write(<<-vf)
Vagrant::Config.run do |config|
config.vm.box = "base"
config.vm.provision :shell, :inline => "echo success > /vagrant/results"
end
vf
end
assert_execute("vagrant", "up")
result_file = environment.workdir.join("results")
result_file.exist?.should be
result_file.read.should == "success\n"
end
end end