From 2076c2c3c401d9ab9324468818bbc46d4e4b870a Mon Sep 17 00:00:00 2001 From: eregon Date: Sat, 29 Dec 2018 00:22:52 +0000 Subject: Update to ruby/spec@944ea57 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/ruby/core/io/dup_spec.rb | 20 +++++++++++++++++++- spec/ruby/core/io/reopen_spec.rb | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'spec/ruby/core/io') diff --git a/spec/ruby/core/io/dup_spec.rb b/spec/ruby/core/io/dup_spec.rb index 421ae27f24..c88d109ec9 100644 --- a/spec/ruby/core/io/dup_spec.rb +++ b/spec/ruby/core/io/dup_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "IO#dup" do before :each do - @file = tmp("rubinius_spec_io_dup_#{$$}_#{Time.now.to_f}") + @file = tmp("spec_io_dup") @f = File.open @file, 'w+' @i = @f.dup @@ -66,4 +66,22 @@ end it "raises IOError on closed stream" do lambda { IOSpecs.closed_io.dup }.should raise_error(IOError) end + + it "always sets the close-on-exec flag for the new IO object" do + @f.close_on_exec = true + dup = @f.dup + begin + dup.close_on_exec?.should == true + ensure + dup.close + end + + @f.close_on_exec = false + dup = @f.dup + begin + dup.close_on_exec?.should == true + ensure + dup.close + end + end end diff --git a/spec/ruby/core/io/reopen_spec.rb b/spec/ruby/core/io/reopen_spec.rb index e769991554..53fcc9dede 100644 --- a/spec/ruby/core/io/reopen_spec.rb +++ b/spec/ruby/core/io/reopen_spec.rb @@ -162,6 +162,18 @@ describe "IO#reopen with a String" do end end + it "always resets the close-on-exec flag to true on non-STDIO objects" do + @io = new_io @name, "w" + + @io.close_on_exec = true + @io.reopen @other_name + @io.close_on_exec?.should == true + + @io.close_on_exec = false + @io.reopen @other_name + @io.close_on_exec?.should == true + end + it "creates the file if it doesn't exist if the IO is opened in write mode" do @io = new_io @name, "w" @@ -294,6 +306,18 @@ describe "IO#reopen with an IO" do File.read(@other_name).should == "io data" end + it "always resets the close-on-exec flag to true on non-STDIO objects" do + @other_io.close_on_exec = true + @io.close_on_exec = true + @io.reopen @other_io + @io.close_on_exec?.should == true + + @other_io.close_on_exec = false + @io.close_on_exec = false + @io.reopen @other_io + @io.close_on_exec?.should == true + end + it "may change the class of the instance" do @io.reopen @other_io @io.should be_an_instance_of(File) -- cgit v1.2.3