aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/share_lock_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 19:55:02 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 20:16:27 +0200
commit80e66cc4d90bf8c15d1a5f6e3152e90147f00772 (patch)
treee7e75464af04f3cf1935b29238dbd7cb2337b0dd /activesupport/test/share_lock_test.rb
parent411ccbdab2608c62aabdb320d52cb02d446bb39c (diff)
downloadrails-80e66cc4d90bf8c15d1a5f6e3152e90147f00772.tar.gz
rails-80e66cc4d90bf8c15d1a5f6e3152e90147f00772.tar.bz2
rails-80e66cc4d90bf8c15d1a5f6e3152e90147f00772.zip
normalizes indentation and whitespace across the project
Diffstat (limited to 'activesupport/test/share_lock_test.rb')
-rw-r--r--activesupport/test/share_lock_test.rb124
1 files changed, 62 insertions, 62 deletions
diff --git a/activesupport/test/share_lock_test.rb b/activesupport/test/share_lock_test.rb
index 168ead2401..8155d46934 100644
--- a/activesupport/test/share_lock_test.rb
+++ b/activesupport/test/share_lock_test.rb
@@ -489,90 +489,90 @@ class ShareLockTest < ActiveSupport::TestCase
private
- module CustomAssertions
- SUFFICIENT_TIMEOUT = 0.2
+ module CustomAssertions
+ SUFFICIENT_TIMEOUT = 0.2
- private
+ private
- def assert_threads_stuck_but_releasable_by_latch(threads, latch)
- assert_threads_stuck threads
- latch.count_down
- assert_threads_not_stuck threads
- end
+ def assert_threads_stuck_but_releasable_by_latch(threads, latch)
+ assert_threads_stuck threads
+ latch.count_down
+ assert_threads_not_stuck threads
+ end
- def assert_threads_stuck(threads)
- sleep(SUFFICIENT_TIMEOUT) # give threads time to do their business
- assert(Array(threads).all? { |t| t.join(0.001).nil? })
- end
+ def assert_threads_stuck(threads)
+ sleep(SUFFICIENT_TIMEOUT) # give threads time to do their business
+ assert(Array(threads).all? { |t| t.join(0.001).nil? })
+ end
- def assert_threads_not_stuck(threads)
- assert(Array(threads).all? { |t| t.join(SUFFICIENT_TIMEOUT) })
+ def assert_threads_not_stuck(threads)
+ assert(Array(threads).all? { |t| t.join(SUFFICIENT_TIMEOUT) })
+ end
end
- end
- class CustomAssertionsTest < ActiveSupport::TestCase
- include CustomAssertions
+ class CustomAssertionsTest < ActiveSupport::TestCase
+ include CustomAssertions
- def setup
- @latch = Concurrent::CountDownLatch.new
- @thread = Thread.new { @latch.wait }
- end
+ def setup
+ @latch = Concurrent::CountDownLatch.new
+ @thread = Thread.new { @latch.wait }
+ end
- def teardown
- @latch.count_down
- @thread.join
- end
+ def teardown
+ @latch.count_down
+ @thread.join
+ end
- def test_happy_path
- assert_threads_stuck_but_releasable_by_latch @thread, @latch
- end
+ def test_happy_path
+ assert_threads_stuck_but_releasable_by_latch @thread, @latch
+ end
- def test_detects_stuck_thread
- assert_raises(Minitest::Assertion) do
- assert_threads_not_stuck @thread
+ def test_detects_stuck_thread
+ assert_raises(Minitest::Assertion) do
+ assert_threads_not_stuck @thread
+ end
end
- end
- def test_detects_free_thread
- @latch.count_down
- assert_raises(Minitest::Assertion) do
- assert_threads_stuck @thread
+ def test_detects_free_thread
+ @latch.count_down
+ assert_raises(Minitest::Assertion) do
+ assert_threads_stuck @thread
+ end
end
- end
- def test_detects_already_released
- @latch.count_down
- assert_raises(Minitest::Assertion) do
- assert_threads_stuck_but_releasable_by_latch @thread, @latch
+ def test_detects_already_released
+ @latch.count_down
+ assert_raises(Minitest::Assertion) do
+ assert_threads_stuck_but_releasable_by_latch @thread, @latch
+ end
end
- end
- def test_detects_remains_latched
- another_latch = Concurrent::CountDownLatch.new
- assert_raises(Minitest::Assertion) do
- assert_threads_stuck_but_releasable_by_latch @thread, another_latch
+ def test_detects_remains_latched
+ another_latch = Concurrent::CountDownLatch.new
+ assert_raises(Minitest::Assertion) do
+ assert_threads_stuck_but_releasable_by_latch @thread, another_latch
+ end
end
end
- end
- include CustomAssertions
+ include CustomAssertions
- def with_thread_waiting_in_lock_section(lock_section)
- in_section = Concurrent::CountDownLatch.new
- section_release = Concurrent::CountDownLatch.new
+ def with_thread_waiting_in_lock_section(lock_section)
+ in_section = Concurrent::CountDownLatch.new
+ section_release = Concurrent::CountDownLatch.new
- stuck_thread = Thread.new do
- @lock.send(lock_section) do
- in_section.count_down
- section_release.wait
+ stuck_thread = Thread.new do
+ @lock.send(lock_section) do
+ in_section.count_down
+ section_release.wait
+ end
end
- end
- in_section.wait
+ in_section.wait
- yield section_release
- ensure
- section_release.count_down
- stuck_thread.join # clean up
- end
+ yield section_release
+ ensure
+ section_release.count_down
+ stuck_thread.join # clean up
+ end
end