Improve detection of Windows.
This commit is contained in:
parent
21411e4a87
commit
daa7f12fbd
@ -344,7 +344,7 @@ module Cmdtest
|
||||
@fast = false
|
||||
@xml = nil
|
||||
@set_exit_code = true
|
||||
@ruby_s = false
|
||||
@ruby_s = Util.windows?
|
||||
@incremental = false
|
||||
@patterns = []
|
||||
|
||||
@ -369,7 +369,7 @@ module Cmdtest
|
||||
when opt =~ /^--no-exit-code$/
|
||||
@set_exit_code = false
|
||||
when opt =~ /^--ruby_s$/
|
||||
@ruby_s = true
|
||||
@ruby_s = ! @ruby_s
|
||||
when opt =~ /^-r$/
|
||||
@incremental = true
|
||||
when opt =~ /^-i$/
|
||||
|
@ -187,6 +187,12 @@ module Cmdtest
|
||||
@_env_path = dirs.flatten
|
||||
end
|
||||
|
||||
#------------------------------
|
||||
|
||||
def windows?
|
||||
Util.windows?
|
||||
end
|
||||
|
||||
#==============================
|
||||
|
||||
# Used in methods invoked from the "cmd" do-block, in methods that
|
||||
@ -330,7 +336,7 @@ module Cmdtest
|
||||
#------------------------------
|
||||
|
||||
def _read_file(file)
|
||||
if File.directory?(file) && RUBY_PLATFORM =~ /mswin32/
|
||||
if File.directory?(file) && Util.windows?
|
||||
:is_directory
|
||||
else
|
||||
File.read(file)
|
||||
@ -558,7 +564,7 @@ module Cmdtest
|
||||
def _args_to_quoted_string(args)
|
||||
quoted_args = []
|
||||
for arg in args
|
||||
if RUBY_PLATFORM =~ /mswin32/
|
||||
if Util.windows?
|
||||
if arg =~ /[;&()><\\| $%"]/
|
||||
quoted_arg = arg.dup
|
||||
# \ --- no change needed
|
||||
|
@ -63,5 +63,9 @@ module Cmdtest
|
||||
end
|
||||
end
|
||||
|
||||
def self.windows?
|
||||
RUBY_PLATFORM =~ /mswin32|mingw32/
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -55,12 +55,8 @@ module Cmdtest
|
||||
FsSnapshot.new(@dir, @ignored_files)
|
||||
end
|
||||
|
||||
def _windows
|
||||
RUBY_PLATFORM =~ /mswin32/
|
||||
end
|
||||
|
||||
def _shell
|
||||
if _windows
|
||||
if Util.windows?
|
||||
cmd_exe = ENV["COMSPEC"] || "cmd.exe"
|
||||
"#{cmd_exe} /Q /c"
|
||||
else
|
||||
@ -70,7 +66,7 @@ module Cmdtest
|
||||
|
||||
def _tmp_command_sh
|
||||
File.join(@testcase.tmp_dir,
|
||||
_windows ? "tmp-command.bat" : "tmp-command.sh")
|
||||
Util.windows? ? "tmp-command.bat" : "tmp-command.sh")
|
||||
end
|
||||
|
||||
def _tmp_stdout_log
|
||||
@ -82,7 +78,7 @@ module Cmdtest
|
||||
end
|
||||
|
||||
def _set_env_path_str(env_path)
|
||||
if _windows
|
||||
if Util.windows?
|
||||
"set path=" + env_path.join(";")
|
||||
else
|
||||
"export PATH=" + env_path.join(":")
|
||||
|
@ -121,7 +121,7 @@ _END_
|
||||
|
||||
def test_array_with_DOLLAR_arguments_2
|
||||
#
|
||||
return unless RUBY_PLATFORM =~ /mswin32/
|
||||
return unless windows?
|
||||
|
||||
create_CMDTEST_foo <<'_END_'
|
||||
cmd ["clines", "emb$edded1", "emb$$edded2"] do
|
||||
@ -144,7 +144,7 @@ _END_
|
||||
def test_cmd_all_characters
|
||||
# (but not backslash for now)
|
||||
#
|
||||
return unless RUBY_PLATFORM !~ /mswin32/
|
||||
return unless ! windows?
|
||||
|
||||
create_CMDTEST_foo <<'_END_'
|
||||
all = " !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~"
|
||||
|
@ -232,7 +232,7 @@ class CMDTEST_file_equal < Cmdtest::Testcase
|
||||
|
||||
def test_file_equal_OTHER_ERROR
|
||||
#
|
||||
return unless RUBY_PLATFORM !~ /mswin32/
|
||||
return unless ! windows?
|
||||
|
||||
create_CMDTEST_foo [
|
||||
"File.symlink 'foo', 'foo'",
|
||||
|
@ -846,9 +846,10 @@ _END_
|
||||
# TODO: this test should be improved to actually trigger the difference
|
||||
# between lstat/stat in "_update_hardlinks".
|
||||
#
|
||||
# REQUIRE: RUBY_PLATFORM !~ /mswin32/
|
||||
|
||||
def test_symlinks_in_tree
|
||||
return unless ! windows?
|
||||
|
||||
create_CMDTEST_foo [
|
||||
"File.symlink 'non-existing', 'non-existing-link'",
|
||||
"",
|
||||
|
@ -9,7 +9,7 @@ class CMDTEST_simple < Cmdtest::Testcase
|
||||
|
||||
def test_try_to_run_non_existing_command_LINUX
|
||||
#
|
||||
return unless RUBY_PLATFORM !~ /mswin32/
|
||||
return unless ! windows?
|
||||
|
||||
create_CMDTEST_foo [
|
||||
'cmd "non-existing" do',
|
||||
@ -29,7 +29,7 @@ class CMDTEST_simple < Cmdtest::Testcase
|
||||
|
||||
def test_try_to_run_non_existing_command_WINDOWS
|
||||
#
|
||||
return unless RUBY_PLATFORM =~ /mswin32/
|
||||
return unless windows?
|
||||
|
||||
create_CMDTEST_foo [
|
||||
'cmd "non-existing" do',
|
||||
@ -52,7 +52,7 @@ class CMDTEST_simple < Cmdtest::Testcase
|
||||
|
||||
def test_FAILING_try_to_run_non_existing_command_LINUX
|
||||
#
|
||||
return unless RUBY_PLATFORM !~ /mswin32/
|
||||
return unless ! windows?
|
||||
|
||||
create_CMDTEST_foo [
|
||||
'cmd "non-existing" do',
|
||||
@ -75,7 +75,7 @@ class CMDTEST_simple < Cmdtest::Testcase
|
||||
|
||||
def test_FAILING_try_to_run_non_existing_command_WIN32
|
||||
#
|
||||
return unless RUBY_PLATFORM =~ /mswin32/
|
||||
return unless windows?
|
||||
|
||||
create_CMDTEST_foo [
|
||||
'cmd "non-existing" do',
|
||||
|
@ -5,7 +5,7 @@ module SelftestUtils
|
||||
TOP = Dir.pwd
|
||||
BIN = File.join(TOP, "t/bin")
|
||||
|
||||
if RUBY_PLATFORM =~ /mswin/
|
||||
if Cmdtest::Util.windows?
|
||||
PLATFORM_BIN = File.join(TOP, "t/bin/windows")
|
||||
else
|
||||
PLATFORM_BIN = File.join(TOP, "t/bin/unix")
|
||||
|
Loading…
x
Reference in New Issue
Block a user