handle current directory containing spaces
This commit is contained in:
parent
77ca78c161
commit
1e6e3ca0a2
@ -53,6 +53,11 @@ module Cmdtest
|
||||
return tnew
|
||||
end
|
||||
|
||||
def self.quote_path(str)
|
||||
needed = (str =~ /[^a-zA-Z0-9_]/)
|
||||
return needed ? '"' + str.gsub('"', '\"') + '"' : str
|
||||
end
|
||||
|
||||
def self.windows?
|
||||
RUBY_PLATFORM =~ /mswin32|mingw32/
|
||||
end
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
require "cmdtest/fssnapshot"
|
||||
require "cmdtest/cmdeffects"
|
||||
require "cmdtest/util"
|
||||
|
||||
require "fileutils"
|
||||
|
||||
@ -80,14 +81,14 @@ module Cmdtest
|
||||
end
|
||||
|
||||
def _chdir_str(dir)
|
||||
"cd #{dir}"
|
||||
"cd %s" % _quote(dir)
|
||||
end
|
||||
|
||||
def _set_env_path_str(env_path)
|
||||
if Util.windows?
|
||||
"set path=" + env_path.join(";")
|
||||
else
|
||||
"export PATH=" + env_path.join(":")
|
||||
"export PATH=" + _quote(env_path.join(":"))
|
||||
end
|
||||
end
|
||||
|
||||
@ -103,6 +104,10 @@ module Cmdtest
|
||||
end
|
||||
end
|
||||
|
||||
def _quote(str)
|
||||
return Cmdtest::Util::quote_path(str)
|
||||
end
|
||||
|
||||
def run_cmd(cmdline, env_path)
|
||||
File.open(_tmp_command_sh, "w") do |f|
|
||||
f.puts _ENV_strs(@testcase._env)
|
||||
@ -111,10 +116,10 @@ module Cmdtest
|
||||
f.puts _ruby_S(cmdline)
|
||||
end
|
||||
str = "%s %s > %s 2> %s" % [
|
||||
_shell,
|
||||
_tmp_command_sh,
|
||||
_tmp_stdout_log,
|
||||
_tmp_stderr_log,
|
||||
_quote(_shell),
|
||||
_quote(_tmp_command_sh),
|
||||
_quote(_tmp_stdout_log),
|
||||
_quote(_tmp_stderr_log),
|
||||
]
|
||||
before = _take_snapshot
|
||||
ok = system(str)
|
||||
|
@ -36,8 +36,14 @@ module SelftestUtils
|
||||
]
|
||||
end
|
||||
|
||||
def _quote(str)
|
||||
return Cmdtest::Util::quote_path(str)
|
||||
end
|
||||
|
||||
def cmd_cmdtest(*args)
|
||||
cmd("ruby #{TOP}/bin/cmdtest.rb --quiet", *args) do
|
||||
cmdtest = "#{TOP}/bin/cmdtest.rb"
|
||||
command = "ruby %s --quiet" % _quote(cmdtest)
|
||||
cmd(command, *args) do
|
||||
comment "running local cmdtest"
|
||||
yield
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user