@@ -321,42 +321,48 @@ def test_unreachable_statement
321
321
assert_warning ( "tap { redo; foo }" , "statement not reached" )
322
322
end
323
323
324
- def test_shebang_ending_with_carriage_return
325
- msg = "shebang line ending with \\ r may cause problems"
326
-
327
- assert_warning ( <<~RUBY , msg , compare : false )
328
- #!ruby\r
329
- p(123)
330
- RUBY
331
-
332
- assert_warning ( <<~RUBY , msg , compare : false )
333
- #!ruby \r
334
- p(123)
335
- RUBY
336
-
337
- assert_warning ( <<~RUBY , msg , compare : false )
338
- #!ruby -Eutf-8\r
339
- p(123)
340
- RUBY
341
-
342
- # Used with the `-x` object, to ignore the script up until the first shebang that mentioned "ruby".
343
- assert_warning ( <<~SCRIPT , msg , compare : false )
344
- #!/usr/bin/env bash
345
- # Some initial shell script or other content
346
- # that Ruby should ignore
347
- echo "This is shell script part"
348
- exit 0
349
-
350
- #! /usr/bin/env ruby -Eutf-8\r
351
- # Ruby script starts here
352
- puts "Hello from Ruby!"
353
- SCRIPT
354
-
355
- refute_warning ( "#ruby not_a_shebang\r \n " , compare : false )
356
-
357
- # CRuby doesn't emit the warning if a malformed file only has `\r` and not `\n`.
358
- # https://bugs.ruby-lang.org/issues/20700
359
- refute_warning ( "#!ruby\r " , compare : false )
324
+ if RbConfig ::CONFIG [ "host_os" ] . match? ( /bccwin|cygwin|djgpp|mingw|mswin|wince/i )
325
+ def test_shebang_ending_with_carriage_return
326
+ refute_warning ( "#!ruby\r \n p(123)\n " , compare : false )
327
+ end
328
+ else
329
+ def test_shebang_ending_with_carriage_return
330
+ msg = "shebang line ending with \\ r may cause problems"
331
+
332
+ assert_warning ( <<~RUBY , msg , compare : false )
333
+ #!ruby\r
334
+ p(123)
335
+ RUBY
336
+
337
+ assert_warning ( <<~RUBY , msg , compare : false )
338
+ #!ruby \r
339
+ p(123)
340
+ RUBY
341
+
342
+ assert_warning ( <<~RUBY , msg , compare : false )
343
+ #!ruby -Eutf-8\r
344
+ p(123)
345
+ RUBY
346
+
347
+ # Used with the `-x` object, to ignore the script up until the first shebang that mentioned "ruby".
348
+ assert_warning ( <<~SCRIPT , msg , compare : false )
349
+ #!/usr/bin/env bash
350
+ # Some initial shell script or other content
351
+ # that Ruby should ignore
352
+ echo "This is shell script part"
353
+ exit 0
354
+
355
+ #! /usr/bin/env ruby -Eutf-8\r
356
+ # Ruby script starts here
357
+ puts "Hello from Ruby!"
358
+ SCRIPT
359
+
360
+ refute_warning ( "#ruby not_a_shebang\r \n " , compare : false )
361
+
362
+ # CRuby doesn't emit the warning if a malformed file only has `\r` and not `\n`.
363
+ # https://bugs.ruby-lang.org/issues/20700
364
+ refute_warning ( "#!ruby\r " , compare : false )
365
+ end
360
366
end
361
367
362
368
def test_warnings_verbosity
0 commit comments