diff --git a/bin/cmdtest.rb b/bin/cmdtest.rb index f5b26c4..f37cf38 100755 --- a/bin/cmdtest.rb +++ b/bin/cmdtest.rb @@ -190,13 +190,6 @@ module Cmdtest @orig_env_path.dup 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"] diff --git a/lib/cmdtest/testcase.rb b/lib/cmdtest/testcase.rb index 5dc804f..82a2664 100644 --- a/lib/cmdtest/testcase.rb +++ b/lib/cmdtest/testcase.rb @@ -521,9 +521,8 @@ module Cmdtest @_runner.notify("cmdline", @_cmdline, @_comment_str) @_comment_str = nil - @_runner.set_env_path(@_env_path) @_t1 = Time.now - @_effects = @_work_dir.run_cmd(@_cmdline) + @_effects = @_work_dir.run_cmd(@_cmdline, @_env_path) @_t2 = Time.now @_checked_status = false diff --git a/lib/cmdtest/workdir.rb b/lib/cmdtest/workdir.rb index 6f52680..5b53c6f 100644 --- a/lib/cmdtest/workdir.rb +++ b/lib/cmdtest/workdir.rb @@ -90,6 +90,14 @@ module Cmdtest File.join(Workdir.tmp_cmdtest_dir, "tmp-stderr.log") end + def _set_env_path_str(env_path) + if _windows + "set path=" + env_path.join(";") + else + "export PATH=" + env_path.join(":") + end + end + def _ruby_S(cmdline) if @runner.opts.ruby_s if cmdline =~ /ruby/ @@ -102,8 +110,9 @@ module Cmdtest end end - def run_cmd(cmdline) + def run_cmd(cmdline, env_path) File.open(_tmp_command_sh, "w") do |f| + f.puts _set_env_path_str(env_path) f.puts _ruby_S(cmdline) end str = "%s %s > %s 2> %s" % [