diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-05-31 18:22:49 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-05-31 18:22:49 +0200 |
commit | 34776105c8a6739ca3aad1de4a2c942f4a8f2f29 (patch) | |
tree | 0103cf2cc89c1322d8c3e88fff0a80b54db8320b /spec/ruby/core/thread | |
parent | f4502b001a665109bf776f9037ecbc52cb5f2d88 (diff) | |
download | ruby-34776105c8a6739ca3aad1de4a2c942f4a8f2f29.tar.gz |
Update to ruby/spec@4e486fa
Diffstat (limited to 'spec/ruby/core/thread')
3 files changed, 54 insertions, 27 deletions
diff --git a/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb b/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb index d38659c257..67f9274f32 100644 --- a/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb +++ b/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb @@ -29,33 +29,35 @@ describe 'Thread::Backtrace::Location#absolute_path' do end end - platform_is_not :windows do - before :each do - @file = fixture(__FILE__, "absolute_path.rb") - @symlink = tmp("symlink.rb") - File.symlink(@file, @symlink) - ScratchPad.record [] - end - - after :each do - rm_r @symlink - end - - it "returns a canonical path without symlinks, even when __FILE__ does not" do - realpath = File.realpath(@symlink) - realpath.should_not == @symlink - - load @symlink - ScratchPad.recorded.should == [@symlink, realpath] - end - - it "returns a canonical path without symlinks, even when __FILE__ is removed" do - realpath = File.realpath(@symlink) - realpath.should_not == @symlink - - ScratchPad << -> { rm_r(@symlink) } - load @symlink - ScratchPad.recorded.should == [@symlink, realpath] + context "canonicalization" do + platform_is_not :windows do + before :each do + @file = fixture(__FILE__, "absolute_path.rb") + @symlink = tmp("symlink.rb") + File.symlink(@file, @symlink) + ScratchPad.record [] + end + + after :each do + rm_r @symlink + end + + it "returns a canonical path without symlinks, even when __FILE__ does not" do + realpath = File.realpath(@symlink) + realpath.should_not == @symlink + + load @symlink + ScratchPad.recorded.should == [@symlink, realpath] + end + + it "returns a canonical path without symlinks, even when __FILE__ is removed" do + realpath = File.realpath(@symlink) + realpath.should_not == @symlink + + ScratchPad << -> { rm_r(@symlink) } + load @symlink + ScratchPad.recorded.should == [@symlink, realpath] + end end end end diff --git a/spec/ruby/core/thread/backtrace/location/fixtures/path.rb b/spec/ruby/core/thread/backtrace/location/fixtures/path.rb new file mode 100644 index 0000000000..fba34cb0bc --- /dev/null +++ b/spec/ruby/core/thread/backtrace/location/fixtures/path.rb @@ -0,0 +1,2 @@ +ScratchPad << __FILE__ +ScratchPad << caller_locations(0)[0].path diff --git a/spec/ruby/core/thread/backtrace/location/path_spec.rb b/spec/ruby/core/thread/backtrace/location/path_spec.rb index b1a3439747..93eb4982d8 100644 --- a/spec/ruby/core/thread/backtrace/location/path_spec.rb +++ b/spec/ruby/core/thread/backtrace/location/path_spec.rb @@ -86,4 +86,27 @@ describe 'Thread::Backtrace::Location#path' do end end end + + context "canonicalization" do + platform_is_not :windows do + before :each do + @file = fixture(__FILE__, "path.rb") + @symlink = tmp("symlink.rb") + File.symlink(@file, @symlink) + ScratchPad.record [] + end + + after :each do + rm_r @symlink + end + + it "returns a non-canonical path with symlinks, the same as __FILE__" do + realpath = File.realpath(@symlink) + realpath.should_not == @symlink + + load @symlink + ScratchPad.recorded.should == [@symlink, @symlink] + end + end + end end |