From 2b5bb9ad00ac8205cda18a3a35e6bd906ba5223d Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 12 Aug 2005 15:53:06 +0000 Subject: dbm/test_dbm.rb: specify pid for Process.wait. gdbm/test_gdbm.rb: ditto. sdbm/test_sdbm.rb: ditto. dbm/test_dbm.rb: add tests for open when db is not exist. gdbm/test_gdbm.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/gdbm/test_gdbm.rb | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'test/gdbm') diff --git a/test/gdbm/test_gdbm.rb b/test/gdbm/test_gdbm.rb index 307cd1c3da..db4a656436 100644 --- a/test/gdbm/test_gdbm.rb +++ b/test/gdbm/test_gdbm.rb @@ -118,7 +118,7 @@ if defined? GDBM end def test_s_open_lock return unless have_fork? # snip this test - fork() { + pid = fork() { assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644)) sleep 2 } @@ -132,7 +132,7 @@ if defined? GDBM end } ensure - Process.wait + Process.wait pid end end @@ -158,7 +158,7 @@ if defined? GDBM end return unless have_fork? # snip this test - fork() { + pid = fork() { assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644, GDBM::NOLOCK)) sleep 2 @@ -170,13 +170,13 @@ if defined? GDBM assert_instance_of(GDBM, gdbm2 = GDBM.open("tmptest_gdbm", 0644)) } ensure - Process.wait + Process.wait pid gdbm2.close if gdbm2 end p Dir.glob("tmptest_gdbm*") if $DEBUG - fork() { + pid = fork() { assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644)) sleep 2 } @@ -189,7 +189,7 @@ if defined? GDBM GDBM::NOLOCK)) } ensure - Process.wait + Process.wait pid gdbm2.close if gdbm2 end end @@ -660,8 +660,32 @@ if defined? GDBM FileUtils.rm_rf TMPROOT if File.directory?(TMPROOT) end + def test_reader_open_notexist + assert_raise(Errno::ENOENT) { + GDBM.open("#{TMPROOT}/a", 0666, GDBM::READER) + } + end + + def test_writer_open_notexist + assert_raise(Errno::ENOENT) { + GDBM.open("#{TMPROOT}/a", 0666, GDBM::WRITER) + } + end + + def test_wrcreat_open_notexist + v = GDBM.open("#{TMPROOT}/a", 0666, GDBM::WRCREAT) + assert_instance_of(GDBM, v) + v.close + end + + def test_newdb_open_notexist + v = GDBM.open("#{TMPROOT}/a", 0666, GDBM::NEWDB) + assert_instance_of(GDBM, v) + v.close + end + def test_reader_open - GDBM.open("#{TMPROOT}/a.dbm") {} + GDBM.open("#{TMPROOT}/a.dbm") {} # create a db. v = GDBM.open("#{TMPROOT}/a.dbm", nil, GDBM::READER) {|d| assert_raises(GDBMError) { d["k"] = "v" } true -- cgit v1.2.3