Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a prep script option

  • Loading branch information...
commit b87eda650b1657cb3c6f9957f8c5afc33dbe257e 1 parent 1faf689
Hari Manikarnika & Michael Sofaer authored
Showing with 14 additions and 2 deletions.
  1. +7 −2 lib/hellspawn.rb
  2. +7 −0 test/hellspawn_test.rb
View
9 lib/hellspawn.rb
@@ -24,6 +24,7 @@ def march!
def summon(options)
by_flag = options.delete :by_flag
+ options[:legion_options] = @options
if by_flag
by_flag[1].each do |value|
new_options = options.dup
@@ -69,10 +70,14 @@ def log_script log_dir
"#! /bin/bash\nexec multilog #{log_dir}/#{self[:name]}.log"
end
def run_prep
- "#! /bin/bash\nexec 2>&1" + dir_snippet
+ "#! /bin/bash\nexec 2>&1" + dir_snippet + prep_source_snippet
end
def dir_snippet
- "\ncd #{self[:directory]}" if key? :directory
+ key?(:directory) ? "\ncd #{self[:directory]}" : ""
+ end
+ def prep_source_snippet
+ path = self[:legion_options][:prep_script]
+ path ? "\nsource #{path}" : ""
end
def dt_options
parts = []
View
7 test/hellspawn_test.rb
@@ -100,4 +100,11 @@ def test_shorctuts
Hellspawn.march!
assert {Dir.glob(File.join(@base, "thin", "run")).size == 1}
end
+ def test_prep
+ legion = Hellspawn.legion(:base => @base, :log_dir => @log_dir, :prep_script => "/etc/sod/environment")
+ legion.summon @thin
+ legion.march!
+ run_script = File.read("#{@base}/thin/run")
+ assert { run_script.match /source \/etc\/sod\/environment/ }
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.