Skip to content

Commit affef93

Browse files
committed
Skip a new spec for Dir#chdir on Windows when original directory is removed
The following error is raised: ``` Dir#chdir does not raise an Errno::ENOENT if the original directory no longer exists ERROR Errno::ENOENT: No such file or directory @ dir_chdir0 - D:/a/spec/spec/rubyspec_temp/5588_0/27-testdir1 D:/a/spec/spec/core/dir/chdir_spec.rb:192:in `chdir' D:/a/spec/spec/core/dir/chdir_spec.rb:192:in `block (4 levels) in <top (required)>' D:/a/spec/spec/core/dir/chdir_spec.rb:191:in `chdir' D:/a/spec/spec/core/dir/chdir_spec.rb:191:in `block (3 levels) in <top (required)>' D:/a/spec/spec/core/dir/chdir_spec.rb:129:in `block in <top (required)>' D:/a/spec/spec/core/dir/chdir_spec.rb:128:in `<top (required)>' ```
1 parent 64e35ae commit affef93

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

core/dir/chdir_spec.rb

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -177,27 +177,29 @@ def to_str; DirSpecs.mock_dir; end
177177
dir.close
178178
end
179179

180-
it "does not raise an Errno::ENOENT if the original directory no longer exists" do
181-
dir_name1 = tmp('testdir1')
182-
dir_name2 = tmp('testdir2')
183-
Dir.should_not.exist?(dir_name1)
184-
Dir.should_not.exist?(dir_name2)
185-
Dir.mkdir dir_name1
186-
Dir.mkdir dir_name2
187-
188-
dir2 = Dir.new(dir_name2)
189-
190-
begin
191-
Dir.chdir(dir_name1) do
192-
dir2.chdir { Dir.unlink dir_name1 }
180+
platform_is_not :windows do
181+
it "does not raise an Errno::ENOENT if the original directory no longer exists" do
182+
dir_name1 = tmp('testdir1')
183+
dir_name2 = tmp('testdir2')
184+
Dir.should_not.exist?(dir_name1)
185+
Dir.should_not.exist?(dir_name2)
186+
Dir.mkdir dir_name1
187+
Dir.mkdir dir_name2
188+
189+
dir2 = Dir.new(dir_name2)
190+
191+
begin
192+
Dir.chdir(dir_name1) do
193+
dir2.chdir { Dir.unlink dir_name1 }
194+
end
195+
Dir.pwd.should == @original
196+
ensure
197+
Dir.unlink dir_name1 if Dir.exist?(dir_name1)
198+
Dir.unlink dir_name2 if Dir.exist?(dir_name2)
193199
end
194-
Dir.pwd.should == @original
195200
ensure
196-
Dir.unlink dir_name1 if Dir.exist?(dir_name1)
197-
Dir.unlink dir_name2 if Dir.exist?(dir_name2)
201+
dir2.close
198202
end
199-
ensure
200-
dir2.close
201203
end
202204

203205
it "always returns to the original directory when given a block" do

0 commit comments

Comments
 (0)