Add method "prepend_path" to control PATH when running commands.

This commit is contained in:
Johan Holmberg
2009-03-27 07:23:10 +00:00
committed by holmberg556
parent 0a15996b2a
commit 54b7536481
2 changed files with 21 additions and 0 deletions

View File

@ -160,8 +160,18 @@ module Cmdtest
end
end
def prepend_path_dirs(path_dirs)
full_path_dirs = path_dirs.map {|dir| File.expand_path(dir, @orig_cwd) }
new_env_path = (full_path_dirs + [@orig_envpath]).join(Config::CONFIG["PATH_SEPARATOR"])
if new_env_path != ENV["PATH"]
ENV["PATH"] = new_env_path
end
end
def run
@orig_cwd = Dir.pwd
ENV["PATH"] = Dir.pwd + Config::CONFIG["PATH_SEPARATOR"] + ENV["PATH"]
@orig_envpath = ENV["PATH"]
@n_assert_failures = 0
@n_assert_errors = 0
@n_assert_successes = 0