aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-07 19:39:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-07 19:39:32 +0000
commiteea1895cf20621300ae48f04b61c656f0f1c45ef (patch)
tree33708234b0d3d3759c319e36148e34f68a4561b7
parent99159ae772be6ae5135c34b3abc094bb60301fe8 (diff)
downloadruby-eea1895cf20621300ae48f04b61c656f0f1c45ef.tar.gz
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ruby.c6
-rw-r--r--test/ruby/test_rubyoptions.rb5
2 files changed, 5 insertions, 6 deletions
diff --git a/ruby.c b/ruby.c
index bbf2fdb762..bf71a288d4 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1676,6 +1676,8 @@ warn_cr_in_shebang(const char *str, long len)
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)
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)
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;
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 6ee151e5e8..82fc5e44e7 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -312,9 +312,10 @@ class TestRubyOptions < Test::Unit::TestCase
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",