Added "set_path" method. Cleanup of PATH handling.
This commit is contained in:
parent
aabd98a9b1
commit
43dd9acebf
@ -186,17 +186,21 @@ module Cmdtest
|
||||
Config::CONFIG["PATH_SEPARATOR"] || ":"
|
||||
end
|
||||
|
||||
def prepend_path_dirs(full_path_dirs)
|
||||
new_env_path = (full_path_dirs + [@orig_envpath]).join(_path_separator)
|
||||
if new_env_path != ENV["PATH"]
|
||||
ENV["PATH"] = new_env_path
|
||||
def orig_env_path
|
||||
@orig_env_path
|
||||
end
|
||||
|
||||
def set_env_path(path_arr)
|
||||
path_str = path_arr.join(_path_separator)
|
||||
if path_str != ENV["PATH"]
|
||||
ENV["PATH"] = path_str
|
||||
end
|
||||
end
|
||||
|
||||
def run
|
||||
@orig_cwd = Dir.pwd
|
||||
ENV["PATH"] = Dir.pwd + _path_separator + ENV["PATH"]
|
||||
@orig_envpath = ENV["PATH"]
|
||||
@orig_env_path = ENV["PATH"].split(_path_separator)
|
||||
@n_assert_failures = 0
|
||||
@n_assert_errors = 0
|
||||
@n_assert_successes = 0
|
||||
|
@ -68,7 +68,7 @@ module Cmdtest
|
||||
@_work_dir = Workdir.new(runner)
|
||||
@_in_cmd = false
|
||||
@_comment_str = nil
|
||||
@_prepend_path_dirs = []
|
||||
@_env_path = @_runner.orig_env_path
|
||||
@_t1 = @_t2 = 0
|
||||
end
|
||||
|
||||
@ -153,7 +153,7 @@ module Cmdtest
|
||||
# was started.
|
||||
|
||||
def prepend_path(dir)
|
||||
@_prepend_path_dirs.unshift(File.expand_path(dir, @_runner.orig_cwd))
|
||||
@_env_path.unshift(File.expand_path(dir, @_runner.orig_cwd))
|
||||
end
|
||||
|
||||
#------------------------------
|
||||
@ -162,7 +162,13 @@ module Cmdtest
|
||||
# of the call was started.
|
||||
|
||||
def prepend_local_path(dir)
|
||||
@_prepend_path_dirs.unshift(File.expand_path(dir, Dir.pwd))
|
||||
@_env_path.unshift(File.expand_path(dir, Dir.pwd))
|
||||
end
|
||||
|
||||
#------------------------------
|
||||
|
||||
def set_path(*dirs)
|
||||
@_env_path = dirs.flatten
|
||||
end
|
||||
|
||||
#==============================
|
||||
@ -515,7 +521,7 @@ module Cmdtest
|
||||
|
||||
@_runner.notify("cmdline", @_cmdline, @_comment_str)
|
||||
@_comment_str = nil
|
||||
@_runner.prepend_path_dirs(@_prepend_path_dirs)
|
||||
@_runner.set_env_path(@_env_path)
|
||||
@_t1 = Time.now
|
||||
@_effects = @_work_dir.run_cmd(@_cmdline)
|
||||
@_t2 = Time.now
|
||||
|
@ -69,7 +69,7 @@ module Cmdtest
|
||||
end
|
||||
|
||||
def _shell
|
||||
_windows ? "cmd /Q /c" : "sh"
|
||||
_windows ? "cmd /Q /c" : "/bin/sh"
|
||||
end
|
||||
|
||||
def _tmp_command_sh
|
||||
|
Loading…
x
Reference in New Issue
Block a user