summaryrefslogtreecommitdiff
path: root/test/test_pstore.rb
diff options
context:
space:
mode:
authorsorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-03-07 14:03:41 +0000
committersorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-03-07 14:03:41 +0000
commite267617f3e359cf40a28ba3baa360b9cd7ca2bf2 (patch)
tree2f6bb47cb99c3652ad95c8be59f3d9f0e5f22171 /test/test_pstore.rb
parent52b40be04b961a38379d559b3a10d8a6252ba43b (diff)
* lib/pstore.rb: Delete variable @transaction and fix #4474. Patch by
Masaki Matsushita (Glass_saga). * test/test_pstore.rb(test_thread_safe): Add test for #4474. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_pstore.rb')
-rw-r--r--test/test_pstore.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/test_pstore.rb b/test/test_pstore.rb
index e10ce90..32d79ea 100644
--- a/test/test_pstore.rb
+++ b/test/test_pstore.rb
@@ -71,4 +71,33 @@ class PStoreTest < Test::Unit::TestCase
end
end
end
+
+ def test_thread_safe
+ assert_raise(PStore::Error) do
+ flag = false
+ Thread.new do
+ @pstore.transaction do
+ @pstore[:foo] = "bar"
+ flag = true
+ sleep 1
+ end
+ end
+ until flag; end
+ @pstore.transaction {}
+ end
+ assert_block do
+ pstore = PStore.new("pstore.tmp2.#{Process.pid}",true)
+ flag = false
+ Thread.new do
+ pstore.transaction do
+ pstore[:foo] = "bar"
+ flag = true
+ sleep 1
+ end
+ end
+ until flag; end
+ pstore.transaction { pstore[:foo] == "bar" }
+ File.unlink("pstore.tmp2.#{Process.pid}") rescue nil
+ end
+ end
end