ruby-changes:70254
From: Yuta <ko1@a...>
Date: Thu, 16 Dec 2021 16:17:04 +0900 (JST)
Subject: [ruby-changes:70254] 332d1e52e6 (master): btest: assign $stderr = STDOUT instead of IO#reopen to be more portable
https://git.ruby-lang.org/ruby.git/commit/?id=332d1e52e6 From 332d1e52e62735ff16e5fb9207ce86695369555d Mon Sep 17 00:00:00 2001 From: Yuta Saito <kateinoigakukun@g...> Date: Mon, 13 Dec 2021 16:48:57 +0900 Subject: btest: assign $stderr = STDOUT instead of IO#reopen to be more portable `IO#reopen` internally uses dup syscall but some platforms don't support the syscall. re-assigning `$stderr` is enough to capture the interpreter's errors and warnings. --- bootstraptest/test_eval.rb | 4 ++-- bootstraptest/test_jump.rb | 4 ++-- bootstraptest/test_syntax.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bootstraptest/test_eval.rb b/bootstraptest/test_eval.rb index efc22efff40..a9f389c6734 100644 --- a/bootstraptest/test_eval.rb +++ b/bootstraptest/test_eval.rb @@ -218,7 +218,7 @@ assert_equal %q{[10, main]}, %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_eval.rb#L218 %w[break next redo].each do |keyword| assert_match %r"Can't escape from eval with #{keyword}\b", %{ - STDERR.reopen(STDOUT) + $stderr = STDOUT begin eval "0 rescue #{keyword}" rescue SyntaxError => e @@ -228,7 +228,7 @@ assert_equal %q{[10, main]}, %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_eval.rb#L228 end assert_normal_exit %q{ - STDERR.reopen(STDOUT) + $stderr = STDOUT class Foo def self.add_method class_eval("def some-bad-name; puts 'hello' unless @some_variable.some_function(''); end") diff --git a/bootstraptest/test_jump.rb b/bootstraptest/test_jump.rb index 18a2737ea33..d07c47a56d7 100644 --- a/bootstraptest/test_jump.rb +++ b/bootstraptest/test_jump.rb @@ -147,7 +147,7 @@ assert_equal %q{131}, %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_jump.rb#L147 } } assert_match %r{Invalid retry}, %q{ -STDERR.reopen(STDOUT) +$stderr = STDOUT begin eval %q{ 1.times{ @@ -297,7 +297,7 @@ assert_equal "true", %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_jump.rb#L297 }, '[ruby-core:21379]' assert_match %r{Invalid yield}, %q{ -STDERR.reopen(STDOUT) +$stderr = STDOUT begin eval %q{ class Object diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb index fa27bf2aeb3..948e2d7809e 100644 --- a/bootstraptest/test_syntax.rb +++ b/bootstraptest/test_syntax.rb @@ -628,7 +628,7 @@ assert_equal '2', %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_syntax.rb#L628 } assert_match /invalid multibyte char/, %q{ - STDERR.reopen(STDOUT) + $stderr = STDOUT eval("\"\xf0".force_encoding("utf-8")) }, '[ruby-dev:32429]' -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/