summaryrefslogtreecommitdiff
path: root/test/test_pstore.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-31 00:01:32 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-31 00:01:32 +0000
commit1c01f22d93ed22a489c98ac56032d0a7108f0ed6 (patch)
tree276e4d47277594f0d85194498b46b8dd5ae25f1c /test/test_pstore.rb
parentdd20f90408c6664766f57fa3014839237d84cdf1 (diff)
Join threads.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_pstore.rb')
-rw-r--r--test/test_pstore.rb20
1 files changed, 14 insertions, 6 deletions
diff --git a/test/test_pstore.rb b/test/test_pstore.rb
index ee66266..522f2d1 100644
--- a/test/test_pstore.rb
+++ b/test/test_pstore.rb
@@ -77,28 +77,36 @@ class PStoreTest < Test::Unit::TestCase
def test_thread_safe
assert_raise(PStore::Error) do
flag = false
- Thread.new do
+ th = Thread.new do
@pstore.transaction do
@pstore[:foo] = "bar"
flag = true
sleep 1
end
end
- sleep 0.1 until flag
- @pstore.transaction {}
+ begin
+ sleep 0.1 until flag
+ @pstore.transaction {}
+ ensure
+ th.join
+ end
end
begin
pstore = PStore.new(second_file, true)
flag = false
- Thread.new do
+ th = Thread.new do
pstore.transaction do
pstore[:foo] = "bar"
flag = true
sleep 1
end
end
- sleep 0.1 until flag
- assert_equal("bar", pstore.transaction { pstore[:foo] })
+ begin
+ sleep 0.1 until flag
+ assert_equal("bar", pstore.transaction { pstore[:foo] })
+ ensure
+ th.join
+ end
end
ensure
File.unlink(second_file) rescue nil