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