# Patch by MSP-Greg, MinGW fix for 61950 diff --git a/spec/ruby/core/file/chmod_spec.rb b/spec/ruby/core/file/chmod_spec.rb index f42dea6585..c4bbf667c0 100644 --- a/spec/ruby/core/file/chmod_spec.rb +++ b/spec/ruby/core/file/chmod_spec.rb @@ -1,5 +1,19 @@ require File.expand_path('../../../spec_helper', __FILE__) +# See umask_spec also +FILE_VALS = + if PlatformGuard.new(:netbsd).match? + # -256, -2 and -1 raise Errno::EFTYPE on NetBSD + [-2**30, -2**16, -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256, 2**16, 2**30] + elsif PlatformGuard.new(:freebsd, :openbsd, :darwin).match? + # -256, -2 and -1 raise Errno::EINVAL on OpenBSD + [ -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256] + elsif PlatformGuard.new(:mingw).match? + [ -2**15, -256, -2, -1,-0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256, 2**15] + else + [-2**30, -2**16, -256, -2, -1,-0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256, 2**16, 2**30] + end + describe "File#chmod" do before :each do @filename = tmp('i_exist.exe') @@ -15,36 +29,10 @@ @file.chmod(0755).should == 0 end - platform_is_not :freebsd, :netbsd, :openbsd, :darwin do - it "always succeeds with any numeric values" do - vals = [-2**30, -2**16, -256, -2, -1, - -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256, 2**16, 2**30] - vals.each { |v| - lambda { @file.chmod(v) }.should_not raise_error - } - end - end - - # -256, -2 and -1 raise Errno::EFTYPE on NetBSD - platform_is :netbsd do - it "always succeeds with any numeric values" do - vals = [-2**30, -2**16, #-256, -2, -1, - -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256, 2**16, 2**30] - vals.each { |v| - lambda { @file.chmod(v) }.should_not raise_error - } - end - end - - # -256, -2 and -1 raise Errno::EINVAL on OpenBSD - platform_is :freebsd, :openbsd, :darwin do - it "always succeeds with any numeric values" do - vals = [#-2**30, -2**16, -256, -2, -1, - -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256]#, 2**16, 2**30 - vals.each { |v| - lambda { @file.chmod(v) }.should_not raise_error - } - end + it "always succeeds with any numeric values" do + FILE_VALS.each { |v| + lambda { @file.chmod(v) }.should_not raise_error + } end it "invokes to_int on non-integer argument" do @@ -123,25 +111,10 @@ @count.should == 1 end - platform_is_not :freebsd, :netbsd, :openbsd, :darwin do - it "always succeeds with any numeric values" do - vals = [-2**30, -2**16, -256, -2, -1, - -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256, 2**16, 2**30] - vals.each { |v| - lambda { File.chmod(v, @file) }.should_not raise_error - } - end - end - - # -256, -2 and -1 raise Errno::EFTYPE on NetBSD - platform_is :netbsd do - it "always succeeds with any numeric values" do - vals = [-2**30, -2**16, #-256, -2, -1, - -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256, 2**16, 2**30] - vals.each { |v| - lambda { File.chmod(v, @file) }.should_not raise_error - } - end + it "always succeeds with any numeric values" do + FILE_VALS.each { |v| + lambda { File.chmod(v, @file) }.should_not raise_error + } end platform_is :darwin do diff --git a/spec/ruby/core/file/umask_spec.rb b/spec/ruby/core/file/umask_spec.rb index 53a07b6a54..4dbd36e2fa 100644 --- a/spec/ruby/core/file/umask_spec.rb +++ b/spec/ruby/core/file/umask_spec.rb @@ -1,5 +1,19 @@ require File.expand_path('../../../spec_helper', __FILE__) +# See chmod_spec also +FILE_VALS = + if PlatformGuard.new(:netbsd).match? + # -256, -2 and -1 raise Errno::EFTYPE on NetBSD + [-2**30, -2**16, -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256, 2**16, 2**30] + elsif PlatformGuard.new(:freebsd, :openbsd, :darwin).match? + # -256, -2 and -1 raise Errno::EINVAL on OpenBSD + [ -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256] + elsif PlatformGuard.new(:mingw).match? + [ -2**15, -256, -2, -1,-0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256, 2**15] + else + [-2**30, -2**16, -256, -2, -1,-0.5, 0, 1, 2, 5.555575, 16, 32, 64, 256, 2**16, 2**30] + end + describe "File.umask" do before :each do @orig_umask = File.umask @@ -30,25 +44,13 @@ end end - platform_is_not :freebsd, :darwin do - it "always succeeds with any integer values" do - vals = [-2**30, -2**16, -256, -2, - -1.5, -1, 0.5, 0, 1, 2, 7.77777, 16, 32, 64, 256, 2**16, 2**30] - vals.each { |v| - lambda { File.umask(v) }.should_not raise_error - } - end + it "always succeeds with any integer values" do + FILE_VALS.each { |v| + lambda { File.umask(v) }.should_not raise_error + } end platform_is :freebsd, :darwin do - it "always succeeds with any integer values" do - vals = [-256, -2, - -1.5, -1, 0.5, 0, 1, 2, 7.77777, 16, 32, 64, 256] - vals.each { |v| - lambda { File.umask(v) }.should_not raise_error - } - end - it "fails with invalid values" do vals = [-2**30, -2**16, 2**16, 2**30] vals.each { |v|