make tests more Windows-friendly
by using Ruby helper scripts instead fo relying on the existence of Unix commands
This commit is contained in:
parent
1ed22c3163
commit
6a7bdbdfe4
@ -21,7 +21,7 @@ class CMDTEST_chdir < Cmdtest::Testcase
|
||||
def test_chdir_NONE
|
||||
create_CMDTEST_foo [
|
||||
"create_file 'SUBDIR/.flagfile', ''",
|
||||
"system 'pwd'",
|
||||
"puts Dir.pwd",
|
||||
]
|
||||
cmd_cmdtest do
|
||||
stdout_equal /^\/.*\/top\/work$/
|
||||
@ -34,7 +34,7 @@ class CMDTEST_chdir < Cmdtest::Testcase
|
||||
create_CMDTEST_foo [
|
||||
"create_file 'SUBDIR/.flagfile', ''",
|
||||
"chdir 'SUBDIR'",
|
||||
"system 'pwd'",
|
||||
"puts Dir.pwd",
|
||||
]
|
||||
cmd_cmdtest do
|
||||
stdout_equal /^\/.*\/top\/work\/SUBDIR$/
|
||||
@ -47,7 +47,7 @@ class CMDTEST_chdir < Cmdtest::Testcase
|
||||
create_CMDTEST_foo [
|
||||
"create_file 'SUBDIR/.flagfile', ''",
|
||||
"Dir.chdir 'SUBDIR'",
|
||||
"system 'pwd'",
|
||||
"puts Dir.pwd",
|
||||
]
|
||||
cmd_cmdtest do
|
||||
stdout_equal /^\/.*\/top\/work\/SUBDIR$/
|
||||
@ -59,13 +59,13 @@ class CMDTEST_chdir < Cmdtest::Testcase
|
||||
def test_chdir_NONE_cmd
|
||||
create_CMDTEST_foo [
|
||||
"create_file 'SUBDIR/.flagfile', ''",
|
||||
"cmd 'echo PWD=$(pwd)' do",
|
||||
"cmd 'echo_pwd.rb' do",
|
||||
" stdout_equal /^PWD=\\/.*\\/top\\/work$/",
|
||||
"end",
|
||||
]
|
||||
cmd_cmdtest do
|
||||
stdout_equal [
|
||||
"### echo PWD=$(pwd)",
|
||||
"### echo_pwd.rb",
|
||||
]
|
||||
end
|
||||
end
|
||||
@ -75,13 +75,13 @@ class CMDTEST_chdir < Cmdtest::Testcase
|
||||
create_CMDTEST_foo [
|
||||
"create_file 'SUBDIR/.flagfile', ''",
|
||||
"chdir 'SUBDIR'",
|
||||
"cmd 'echo PWD=$(pwd)' do",
|
||||
"cmd 'echo_pwd.rb' do",
|
||||
" stdout_equal /^PWD=\\/.*\\/top\\/work\\/SUBDIR$/",
|
||||
"end",
|
||||
]
|
||||
cmd_cmdtest do
|
||||
stdout_equal [
|
||||
"### echo PWD=$(pwd)",
|
||||
"### echo_pwd.rb",
|
||||
]
|
||||
end
|
||||
end
|
||||
@ -110,7 +110,7 @@ class CMDTEST_chdir < Cmdtest::Testcase
|
||||
"Dir.chdir 'SUBDIR'",
|
||||
"create_file 'f2.txt', ''",
|
||||
"Dir.chdir '..'",
|
||||
"cmd 'find . -type f | sort' do",
|
||||
"cmd 'find_files.rb' do",
|
||||
" stdout_equal [",
|
||||
" './SUBDIR/f0.txt',",
|
||||
" './SUBDIR/f2.txt',",
|
||||
@ -120,7 +120,7 @@ class CMDTEST_chdir < Cmdtest::Testcase
|
||||
]
|
||||
cmd_cmdtest do
|
||||
stdout_equal [
|
||||
"### find . -type f | sort",
|
||||
"### find_files.rb",
|
||||
]
|
||||
end
|
||||
end
|
||||
|
@ -4,39 +4,39 @@ require "selftest_utils"
|
||||
class CMDTEST_simple < Cmdtest::Testcase
|
||||
|
||||
include SelftestUtils
|
||||
|
||||
|
||||
#-----------------------------------
|
||||
|
||||
def test_get_path
|
||||
create_CMDTEST_foo [
|
||||
'old = get_path()',
|
||||
'cmd "echo $PATH > old.path" do',
|
||||
'cmd "echo_path.rb > old.path" do',
|
||||
' created_files "old.path"',
|
||||
'end',
|
||||
'set_path("extra/dir", *old)',
|
||||
'cmd "echo $PATH > new.path" do',
|
||||
'cmd "echo_path.rb > new.path" do',
|
||||
' created_files "new.path"',
|
||||
'end',
|
||||
'cmd "diff -q old.path new.path" do',
|
||||
'cmd "diff.rb old.path new.path" do',
|
||||
' exit_nonzero',
|
||||
' stdout_equal /differ/',
|
||||
'end',
|
||||
|
||||
'set_path(*old)',
|
||||
'cmd "echo $PATH > restored.path" do',
|
||||
'cmd "echo_path.rb > restored.path" do',
|
||||
' created_files "restored.path"',
|
||||
'end',
|
||||
'cmd "diff -q old.path restored.path" do',
|
||||
'cmd "diff.rb old.path restored.path" do',
|
||||
'end',
|
||||
]
|
||||
|
||||
cmd_cmdtest do
|
||||
stdout_equal [
|
||||
"### echo $PATH > old.path",
|
||||
"### echo $PATH > new.path",
|
||||
"### diff -q old.path new.path",
|
||||
"### echo $PATH > restored.path",
|
||||
"### diff -q old.path restored.path",
|
||||
"### echo_path.rb > old.path",
|
||||
"### echo_path.rb > new.path",
|
||||
"### diff.rb old.path new.path",
|
||||
"### echo_path.rb > restored.path",
|
||||
"### diff.rb old.path restored.path",
|
||||
]
|
||||
end
|
||||
end
|
||||
@ -70,7 +70,7 @@ class CMDTEST_simple < Cmdtest::Testcase
|
||||
def test_try_to_run_non_existing_command_LINUX
|
||||
#
|
||||
return unless ! windows?
|
||||
|
||||
|
||||
create_CMDTEST_foo [
|
||||
'cmd "non-existing" do',
|
||||
' exit_nonzero',
|
||||
|
10
t/bin/diff.rb
Executable file
10
t/bin/diff.rb
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
a = File.read(ARGV[0], encoding: 'BINARY')
|
||||
b = File.read(ARGV[1], encoding: 'BINARY')
|
||||
if a == b
|
||||
exit(0)
|
||||
else
|
||||
puts "file differ: %s and %s" % [ARGV[0], ARGV[1]]
|
||||
exit(1)
|
||||
end
|
3
t/bin/echo_path.rb
Executable file
3
t/bin/echo_path.rb
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
puts ENV['PATH']
|
3
t/bin/echo_pwd.rb
Executable file
3
t/bin/echo_pwd.rb
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
puts "PWD=" + Dir.pwd
|
12
t/bin/find_files.rb
Executable file
12
t/bin/find_files.rb
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require "find"
|
||||
|
||||
files = []
|
||||
Find.find('.') do |path|
|
||||
if File.file?(path)
|
||||
files << path
|
||||
end
|
||||
end
|
||||
|
||||
puts files.sort
|
Loading…
x
Reference in New Issue
Block a user