ruby-changes:41950
From: nobu <ko1@a...>
Date: Tue, 8 Mar 2016 04:39:36 +0900 (JST)
Subject: [ruby-changes:41950] nobu:r54024 (trunk): test_rubyoptions.rb: fix test
nobu 2016-03-08 04:39:32 +0900 (Tue, 08 Mar 2016) New Revision: 54024 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54024 Log: test_rubyoptions.rb: fix test * test/ruby/test_rubyoptions.rb (test_shebang): adjust only expected stderr as a warning, assertion has meaning on all platforms. Modified files: trunk/ruby.c trunk/test/ruby/test_rubyoptions.rb Index: ruby.c =================================================================== --- ruby.c (revision 54023) +++ ruby.c (revision 54024) @@ -1676,6 +1676,8 @@ warn_cr_in_shebang(const char *str, long https://github.com/ruby/ruby/blob/trunk/ruby.c#L1676 rb_warn("shebang line ends with \\r may cause a problem"); } } +#else +#define warn_cr_in_shebang(str, len) (void)0 #endif struct load_file_arg { @@ -1725,9 +1727,7 @@ load_file_internal(VALUE argp_v) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1727 line_start++; RSTRING_GETMEM(line, str, len); if (len > 2 && str[0] == '#' && str[1] == '!') { -#ifndef DOSISH if (line_start == 1) warn_cr_in_shebang(str, len); -#endif if ((p = strstr(str+2, ruby_engine)) != 0) { goto start_read; } @@ -1745,9 +1745,7 @@ load_file_internal(VALUE argp_v) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1745 return 0; RSTRING_GETMEM(line, str, len); -#ifndef DOSISH warn_cr_in_shebang(str, len); -#endif if ((p = strstr(str, ruby_engine)) == 0) { /* not ruby script, assume -x flag */ goto search_shebang; Index: test/ruby/test_rubyoptions.rb =================================================================== --- test/ruby/test_rubyoptions.rb (revision 54023) +++ test/ruby/test_rubyoptions.rb (revision 54024) @@ -312,9 +312,10 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L312 assert_in_out_err([], "#! /test_r_u_b_y_test_r_u_b_y_options_foobarbazqux -foo -bar\r\np 1\r\n", [], /: no Ruby script found in input/) + warning = /mswin|mingw/ =~ RUBY_PLATFORM ? [] : /shebang line ends with \\r/ assert_in_out_err([{'RUBYOPT' => nil}], "#!ruby -KU -Eutf-8\r\np \"\u3042\"\r\n", - ["\"\u3042\""], /shebang line ends with \\r/, - encoding: Encoding::UTF_8) if /mswin|mingw/ !~ RUBY_PLATFORM + ["\"\u3042\""], warning, + encoding: Encoding::UTF_8) bug4118 = '[ruby-dev:42680]' assert_in_out_err(%w[], "#!/bin/sh\n""#!shebang\n""#!ruby\n""puts __LINE__\n", -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/