mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									69a7eaae38
								
							
						
					
					
						commit
						332d1e52e6
					
				
				
				Notes:
				
					git
				
				2021-12-16 16:16:59 +09:00 
				
			
			
			
		
		
					 3 changed files with 5 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -218,7 +218,7 @@ assert_equal %q{[10, main]}, %q{
 | 
			
		|||
 | 
			
		||||
%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{
 | 
			
		|||
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")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -147,7 +147,7 @@ assert_equal %q{131}, %q{
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
assert_match %r{Invalid retry}, %q{
 | 
			
		||||
STDERR.reopen(STDOUT)
 | 
			
		||||
$stderr = STDOUT
 | 
			
		||||
begin
 | 
			
		||||
  eval %q{
 | 
			
		||||
    1.times{
 | 
			
		||||
| 
						 | 
				
			
			@ -297,7 +297,7 @@ assert_equal "true", %q{
 | 
			
		|||
}, '[ruby-core:21379]'
 | 
			
		||||
 | 
			
		||||
assert_match %r{Invalid yield}, %q{
 | 
			
		||||
STDERR.reopen(STDOUT)
 | 
			
		||||
$stderr = STDOUT
 | 
			
		||||
begin
 | 
			
		||||
  eval %q{
 | 
			
		||||
    class Object
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -628,7 +628,7 @@ assert_equal '2', %q{
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
assert_match /invalid multibyte char/, %q{
 | 
			
		||||
  STDERR.reopen(STDOUT)
 | 
			
		||||
  $stderr = STDOUT
 | 
			
		||||
  eval("\"\xf0".force_encoding("utf-8"))
 | 
			
		||||
}, '[ruby-dev:32429]'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue