* test/dbm/test_dbm.rb: split tests for read only database.
* test/gdbm/test_gdbm.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c2c0707949
commit
ddb9acd9f8
@ -1,3 +1,9 @@
|
|||||||
|
Tue Nov 8 20:50:45 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* test/dbm/test_dbm.rb: split tests for read only database.
|
||||||
|
|
||||||
|
* test/gdbm/test_gdbm.rb: ditto.
|
||||||
|
|
||||||
Tue Nov 8 18:59:07 2011 Tanaka Akira <akr@fsij.org>
|
Tue Nov 8 18:59:07 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/pty/pty.c (MasterDevice): define only when used.
|
* ext/pty/pty.c (MasterDevice): define only when used.
|
||||||
|
@ -10,8 +10,8 @@ if defined? DBM
|
|||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
class TestDBM < Test::Unit::TestCase
|
class TestDBM_RDONLY < Test::Unit::TestCase
|
||||||
def TestDBM.uname_s
|
def TestDBM_RDONLY.uname_s
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
case RbConfig::CONFIG['target_os']
|
case RbConfig::CONFIG['target_os']
|
||||||
when 'cygwin'
|
when 'cygwin'
|
||||||
@ -31,7 +31,6 @@ if defined? DBM
|
|||||||
@tmpdir = Dir.mktmpdir("tmptest_dbm")
|
@tmpdir = Dir.mktmpdir("tmptest_dbm")
|
||||||
@prefix = "tmptest_dbm_#{$$}"
|
@prefix = "tmptest_dbm_#{$$}"
|
||||||
@path = "#{@tmpdir}/#{@prefix}_"
|
@path = "#{@tmpdir}/#{@prefix}_"
|
||||||
assert_instance_of(DBM, @dbm = DBM.new(@path))
|
|
||||||
|
|
||||||
# prepare to make readonly DBM file
|
# prepare to make readonly DBM file
|
||||||
DBM.open("#{@tmpdir}/#{@prefix}_rdonly") {|dbm|
|
DBM.open("#{@tmpdir}/#{@prefix}_rdonly") {|dbm|
|
||||||
@ -43,7 +42,6 @@ if defined? DBM
|
|||||||
assert_instance_of(DBM, @dbm_rdonly = DBM.new("#{@tmpdir}/#{@prefix}_rdonly", nil))
|
assert_instance_of(DBM, @dbm_rdonly = DBM.new("#{@tmpdir}/#{@prefix}_rdonly", nil))
|
||||||
end
|
end
|
||||||
def teardown
|
def teardown
|
||||||
assert_nil(@dbm.close)
|
|
||||||
assert_nil(@dbm_rdonly.close)
|
assert_nil(@dbm_rdonly.close)
|
||||||
ObjectSpace.each_object(DBM) do |obj|
|
ObjectSpace.each_object(DBM) do |obj|
|
||||||
obj.close unless obj.closed?
|
obj.close unless obj.closed?
|
||||||
@ -51,6 +49,32 @@ if defined? DBM
|
|||||||
FileUtils.remove_entry_secure @tmpdir
|
FileUtils.remove_entry_secure @tmpdir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_delete_rdonly
|
||||||
|
if /^CYGWIN_9/ !~ SYSTEM
|
||||||
|
assert_raise(DBMError) {
|
||||||
|
@dbm_rdonly.delete("foo")
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_nil(@dbm_rdonly.delete("bar"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class TestDBM < Test::Unit::TestCase
|
||||||
|
def setup
|
||||||
|
@tmpdir = Dir.mktmpdir("tmptest_dbm")
|
||||||
|
@prefix = "tmptest_dbm_#{$$}"
|
||||||
|
@path = "#{@tmpdir}/#{@prefix}_"
|
||||||
|
assert_instance_of(DBM, @dbm = DBM.new(@path))
|
||||||
|
end
|
||||||
|
def teardown
|
||||||
|
assert_nil(@dbm.close)
|
||||||
|
ObjectSpace.each_object(DBM) do |obj|
|
||||||
|
obj.close unless obj.closed?
|
||||||
|
end
|
||||||
|
FileUtils.remove_entry_secure @tmpdir
|
||||||
|
end
|
||||||
|
|
||||||
def check_size(expect, dbm=@dbm)
|
def check_size(expect, dbm=@dbm)
|
||||||
assert_equal(expect, dbm.size)
|
assert_equal(expect, dbm.size)
|
||||||
n = 0
|
n = 0
|
||||||
@ -322,15 +346,8 @@ if defined? DBM
|
|||||||
assert_equal(2, @dbm.size)
|
assert_equal(2, @dbm.size)
|
||||||
|
|
||||||
assert_nil(@dbm.delete(key))
|
assert_nil(@dbm.delete(key))
|
||||||
|
|
||||||
if /^CYGWIN_9/ !~ SYSTEM
|
|
||||||
assert_raise(DBMError) {
|
|
||||||
@dbm_rdonly.delete("foo")
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_nil(@dbm_rdonly.delete("bar"))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_delete_with_block
|
def test_delete_with_block
|
||||||
key = 'no called block'
|
key = 'no called block'
|
||||||
@dbm[key] = 'foo'
|
@dbm[key] = 'foo'
|
||||||
|
@ -10,8 +10,8 @@ if defined? GDBM
|
|||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
class TestGDBM < Test::Unit::TestCase
|
class TestGDBM_RDONLY < Test::Unit::TestCase
|
||||||
def TestGDBM.uname_s
|
def TestGDBM_RDONLY.uname_s
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
case RbConfig::CONFIG['target_os']
|
case RbConfig::CONFIG['target_os']
|
||||||
when 'cygwin'
|
when 'cygwin'
|
||||||
@ -31,7 +31,6 @@ if defined? GDBM
|
|||||||
@tmpdir = Dir.mktmpdir("tmptest_gdbm")
|
@tmpdir = Dir.mktmpdir("tmptest_gdbm")
|
||||||
@prefix = "tmptest_gdbm_#{$$}"
|
@prefix = "tmptest_gdbm_#{$$}"
|
||||||
@path = "#{@tmpdir}/#{@prefix}_"
|
@path = "#{@tmpdir}/#{@prefix}_"
|
||||||
assert_instance_of(GDBM, @gdbm = GDBM.new(@path))
|
|
||||||
|
|
||||||
# prepare to make readonly GDBM file
|
# prepare to make readonly GDBM file
|
||||||
GDBM.open("#{@tmpdir}/#{@prefix}_rdonly", 0400) {|gdbm|
|
GDBM.open("#{@tmpdir}/#{@prefix}_rdonly", 0400) {|gdbm|
|
||||||
@ -40,7 +39,6 @@ if defined? GDBM
|
|||||||
assert_instance_of(GDBM, @gdbm_rdonly = GDBM.new("#{@tmpdir}/#{@prefix}_rdonly", nil))
|
assert_instance_of(GDBM, @gdbm_rdonly = GDBM.new("#{@tmpdir}/#{@prefix}_rdonly", nil))
|
||||||
end
|
end
|
||||||
def teardown
|
def teardown
|
||||||
assert_nil(@gdbm.close)
|
|
||||||
assert_nil(@gdbm_rdonly.close)
|
assert_nil(@gdbm_rdonly.close)
|
||||||
ObjectSpace.each_object(GDBM) do |obj|
|
ObjectSpace.each_object(GDBM) do |obj|
|
||||||
obj.close unless obj.closed?
|
obj.close unless obj.closed?
|
||||||
@ -48,6 +46,34 @@ if defined? GDBM
|
|||||||
FileUtils.remove_entry_secure @tmpdir
|
FileUtils.remove_entry_secure @tmpdir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_delete_rdonly
|
||||||
|
if /^CYGWIN_9/ !~ SYSTEM
|
||||||
|
assert_raise(GDBMError) {
|
||||||
|
@gdbm_rdonly.delete("foo")
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_nil(@gdbm_rdonly.delete("bar"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class TestGDBM < Test::Unit::TestCase
|
||||||
|
SYSTEM = TestGDBM_RDONLY::SYSTEM
|
||||||
|
|
||||||
|
def setup
|
||||||
|
@tmpdir = Dir.mktmpdir("tmptest_gdbm")
|
||||||
|
@prefix = "tmptest_gdbm_#{$$}"
|
||||||
|
@path = "#{@tmpdir}/#{@prefix}_"
|
||||||
|
assert_instance_of(GDBM, @gdbm = GDBM.new(@path))
|
||||||
|
end
|
||||||
|
def teardown
|
||||||
|
assert_nil(@gdbm.close)
|
||||||
|
ObjectSpace.each_object(GDBM) do |obj|
|
||||||
|
obj.close unless obj.closed?
|
||||||
|
end
|
||||||
|
FileUtils.remove_entry_secure @tmpdir
|
||||||
|
end
|
||||||
|
|
||||||
def check_size(expect, gdbm=@gdbm)
|
def check_size(expect, gdbm=@gdbm)
|
||||||
assert_equal(expect, gdbm.size)
|
assert_equal(expect, gdbm.size)
|
||||||
n = 0
|
n = 0
|
||||||
@ -438,15 +464,8 @@ if defined? GDBM
|
|||||||
assert_equal(2, @gdbm.size)
|
assert_equal(2, @gdbm.size)
|
||||||
|
|
||||||
assert_nil(@gdbm.delete(key))
|
assert_nil(@gdbm.delete(key))
|
||||||
|
|
||||||
if /^CYGWIN_9/ !~ SYSTEM
|
|
||||||
assert_raise(GDBMError) {
|
|
||||||
@gdbm_rdonly.delete("foo")
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_nil(@gdbm_rdonly.delete("bar"))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_delete_with_block
|
def test_delete_with_block
|
||||||
key = 'no called block'
|
key = 'no called block'
|
||||||
@gdbm[key] = 'foo'
|
@gdbm[key] = 'foo'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user