[前][次][番号順一覧][スレッド一覧]

ruby-changes:60933

From: Nobuyoshi <ko1@a...>
Date: Wed, 29 Apr 2020 18:18:26 +0900 (JST)
Subject: [ruby-changes:60933] 32e7d9140e (master): [ruby/spec] Temporary directories should be under the mock_dir

https://git.ruby-lang.org/ruby.git/commit/?id=32e7d9140e

From 32e7d9140eb2bc9890a690fd62bf1690ee8fd5e3 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 29 Apr 2020 14:38:03 +0900
Subject: [ruby/spec] Temporary directories should be under the mock_dir


diff --git a/spec/ruby/core/dir/fixtures/common.rb b/spec/ruby/core/dir/fixtures/common.rb
index f6708b0..96dba56 100644
--- a/spec/ruby/core/dir/fixtures/common.rb
+++ b/spec/ruby/core/dir/fixtures/common.rb
@@ -22,7 +22,7 @@ module DirSpecs https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/fixtures/common.rb#L22
       [0xe9].pack('U')
     ].each do |dir|
       begin
-        Dir.rmdir dir
+        Dir.rmdir mock_dir(dir)
       rescue
       end
     end
diff --git a/spec/ruby/core/dir/mkdir_spec.rb b/spec/ruby/core/dir/mkdir_spec.rb
index c6e2f16..0ed28f5 100644
--- a/spec/ruby/core/dir/mkdir_spec.rb
+++ b/spec/ruby/core/dir/mkdir_spec.rb
@@ -13,29 +13,33 @@ describe "Dir.mkdir" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/mkdir_spec.rb#L13
   it "creates the named directory with the given permissions" do
     DirSpecs.clear_dirs
 
+    nonexisting = DirSpecs.mock_dir('nonexisting')
+    default_perms = DirSpecs.mock_dir('default_perms')
+    reduced = DirSpecs.mock_dir('reduced')
     begin
-      File.should_not.exist?('nonexisting')
-      Dir.mkdir 'nonexisting'
-      File.should.exist?('nonexisting')
+      File.should_not.exist?(nonexisting)
+      Dir.mkdir nonexisting
+      File.should.exist?(nonexisting)
       platform_is_not :windows do
-        Dir.mkdir 'default_perms'
-        a = File.stat('default_perms').mode
-        Dir.mkdir 'reduced', (a - 1)
-        File.stat('reduced').mode.should_not == a
+        Dir.mkdir default_perms
+        a = File.stat(default_perms).mode
+        Dir.mkdir reduced, (a - 1)
+        File.stat(reduced).mode.should_not == a
       end
       platform_is :windows do
-        Dir.mkdir 'default_perms', 0666
-        a = File.stat('default_perms').mode
-        Dir.mkdir 'reduced', 0444
-        File.stat('reduced').mode.should_not == a
+        Dir.mkdir default_perms, 0666
+        a = File.stat(default_perms).mode
+        Dir.mkdir reduced, 0444
+        File.stat(reduced).mode.should_not == a
       end
 
-      Dir.mkdir('always_returns_0').should == 0
+      always_returns_0 = DirSpecs.mock_dir('always_returns_0')
+      Dir.mkdir(always_returns_0).should == 0
       platform_is_not(:windows) do
-        File.chmod(0777, "nonexisting","default_perms","reduced","always_returns_0")
+        File.chmod(0777, nonexisting, default_perms, reduced, always_returns_0)
       end
       platform_is_not(:windows) do
-        File.chmod(0644, "nonexisting","default_perms","reduced","always_returns_0")
+        File.chmod(0644, nonexisting, default_perms, reduced, always_returns_0)
       end
     ensure
       DirSpecs.clear_dirs
@@ -45,7 +49,7 @@ describe "Dir.mkdir" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/mkdir_spec.rb#L49
   it "calls #to_path on non-String arguments" do
     DirSpecs.clear_dirs
     p = mock('path')
-    p.should_receive(:to_path).and_return('nonexisting')
+    p.should_receive(:to_path).and_return(DirSpecs.mock_dir('nonexisting'))
     Dir.mkdir(p)
     DirSpecs.clear_dirs
   end
diff --git a/spec/ruby/shared/file/world_readable.rb b/spec/ruby/shared/file/world_readable.rb
index 85761e6..c2c6264 100644
--- a/spec/ruby/shared/file/world_readable.rb
+++ b/spec/ruby/shared/file/world_readable.rb
@@ -35,7 +35,7 @@ describe :file_world_readable, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/shared/file/world_readable.rb#L35
   end
 
   it "returns a Fixnum if the file is a directory and chmod 644" do
-    dir = rand().to_s + '-ww'
+    dir = tmp(rand().to_s + '-ww')
     Dir.mkdir(dir)
     Dir.should.exist?(dir)
     File.chmod(0644, dir)
diff --git a/spec/ruby/shared/file/world_writable.rb b/spec/ruby/shared/file/world_writable.rb
index 61b691b..84d7deb 100644
--- a/spec/ruby/shared/file/world_writable.rb
+++ b/spec/ruby/shared/file/world_writable.rb
@@ -34,7 +34,7 @@ describe :file_world_writable, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/shared/file/world_writable.rb#L34
     end
 
     it "returns a Fixnum if the file is a directory and chmod 777" do
-      dir = rand().to_s + '-ww'
+      dir = tmp(rand().to_s + '-ww')
       Dir.mkdir(dir)
       Dir.should.exist?(dir)
       File.chmod(0777, dir)
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]