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