ruby-changes:13976
From: akr <ko1@a...>
Date: Mon, 16 Nov 2009 02:12:09 +0900 (JST)
Subject: [ruby-changes:13976] Ruby:r25784 (trunk): tests refined.
akr 2009-11-16 02:11:54 +0900 (Mon, 16 Nov 2009) New Revision: 25784 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25784 Log: tests refined. Modified files: trunk/ChangeLog trunk/test/ruby/envutil.rb trunk/test/ruby/test_dir_m17n.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 25783) +++ ChangeLog (revision 25784) @@ -7,8 +7,8 @@ * encoding.c (rb_filesystem_encindex): use default external encoding instead of locale encoding in Unix. - * ruby.c (process_options): delay inifilesystem encoding - initialization after default external encoding initialization. + * ruby.c (process_options): delay filesystem encoding + initialization until default external encoding initialization. Mon Nov 16 00:06:26 2009 Yusuke Endoh <mame@t...> Index: test/ruby/test_dir_m17n.rb =================================================================== --- test/ruby/test_dir_m17n.rb (revision 25783) +++ test/ruby/test_dir_m17n.rb (revision 25784) @@ -13,37 +13,53 @@ def test_filename_bytes_euc_jp with_tmpdir {|d| - assert_in_out(%w[-EEUC-JP], <<-'EOS', %w[true], nil, :chdir=>d) + assert_ruby_status(%w[-EEUC-JP], <<-'EOS', nil, :chdir=>d) filename = "\xA4\xA2".force_encoding("euc-jp") File.open(filename, "w") {} ents = Dir.entries(".") ents.each {|e| e.force_encoding("ASCII-8BIT") } - p ents.include?(filename.force_encoding("ASCII-8BIT")) + exit ents.include?(filename.force_encoding("ASCII-8BIT")) EOS } end def test_filename_euc_jp with_tmpdir {|d| - assert_in_out(%w[-EEUC-JP], <<-'EOS', %w[true], nil, :chdir=>d) + assert_ruby_status(%w[-EEUC-JP], <<-'EOS', nil, :chdir=>d) filename = "\xA4\xA2".force_encoding("euc-jp") File.open(filename, "w") {} ents = Dir.entries(".") - p ents.include?(filename) + exit ents.include?(filename) EOS } end def test_filename_utf_8 with_tmpdir {|d| - assert_in_out(%w[-EUTF-8], <<-'EOS', %w[true], nil, :chdir=>d) + assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d) filename = "\u3042".force_encoding("utf-8") File.open(filename, "w") {} ents = Dir.entries(".") - p ents.include?(filename) + exit ents.include?(filename) EOS } end + def test_filename_ext_euc_jp_and_int_utf_8 + with_tmpdir {|d| + assert_ruby_status(%w[-EEUC-JP], <<-'EOS', nil, :chdir=>d) + filename = "\xA4\xA2".force_encoding("euc-jp") + File.open(filename, "w") {} + ents = Dir.entries(".") + exit ents.include?(filename) + EOS + assert_ruby_status(%w[-EEUC-JP:UTF-8], <<-'EOS', nil, :chdir=>d) + filename = "\u3042".force_encoding("utf-8") + ents = Dir.entries(".") + exit ents.include?(filename) + EOS + } + end + end Index: test/ruby/envutil.rb =================================================================== --- test/ruby/envutil.rb (revision 25783) +++ test/ruby/envutil.rb (revision 25784) @@ -127,7 +127,8 @@ end LANG_ENVS = %w"LANG LC_ALL LC_CTYPE" - def assert_in_out_err(args, test_stdin = "", test_stdout = [], test_stderr = [], message = nil, opt={}) + + def invoke_ruby_assertion(args, test_stdin="", test_stdout=nil, test_stderr=nil, test_status=true, message = nil, opt={}) in_c, in_p = IO.pipe out_p, out_c = IO.pipe if test_stdout err_p, err_c = IO.pipe if test_stderr @@ -155,6 +156,7 @@ out_p.close if test_stdout err_p.close if test_stderr Process.wait pid + status = $? if block_given? yield(test_stdout ? stdout.lines.map {|l| l.chomp } : nil, test_stderr ? stderr.lines.map {|l| l.chomp } : nil) else @@ -173,6 +175,10 @@ end end end + if test_status + assert(status.success?, "ruby exit stauts is not success: #{status.inspect}") + end + status ensure env.each_pair {|lc, v| if v @@ -191,9 +197,14 @@ (th_stderr.kill; th_stderr.join) if th_stderr end - def assert_in_out(args, test_stdin = "", test_stdout = [], message = nil, opt={}) - assert_in_out_err(args, test_stdin, test_stdout, nil, message, opt) + def assert_in_out_err(args, test_stdin = "", test_stdout = [], test_stderr = [], message = nil, opt={}) + invoke_ruby_assertion(args, test_stdin, test_stdout, test_stderr, false, message, opt) end + + def assert_ruby_status(args, test_stdin = "", message = nil, opt={}) + invoke_ruby_assertion(args, test_stdin, nil, nil, true, message, opt) + end + end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/