diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-06-17 10:19:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-17 10:19:56 -0400 |
commit | 30dd8b2cb0913b2ecc94d2b1d9e29b15e5913f71 (patch) | |
tree | 17fa12921aa5b9817458be4c3639ad526ff5abc1 /activesupport/test | |
parent | 58b70b4ed562f0086314d15bb9efcc0fec573b0f (diff) | |
parent | 844af9fa7c18a0ee3316d6cf1289b144d48d84d7 (diff) | |
download | rails-30dd8b2cb0913b2ecc94d2b1d9e29b15e5913f71.tar.gz rails-30dd8b2cb0913b2ecc94d2b1d9e29b15e5913f71.tar.bz2 rails-30dd8b2cb0913b2ecc94d2b1d9e29b15e5913f71.zip |
Merge pull request #25302 from schneems/schneems/evented-file-boot-at-check-time-master
EventedFileUpdateChecker boots once per process
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/evented_file_update_checker_test.rb | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/activesupport/test/evented_file_update_checker_test.rb b/activesupport/test/evented_file_update_checker_test.rb index bc3f77bd54..2cb2d8167f 100644 --- a/activesupport/test/evented_file_update_checker_test.rb +++ b/activesupport/test/evented_file_update_checker_test.rb @@ -11,7 +11,7 @@ class EventedFileUpdateCheckerTest < ActiveSupport::TestCase end def new_checker(files = [], dirs = {}, &block) - ActiveSupport::EventedFileUpdateChecker.new(files, dirs, &block).tap do + ActiveSupport::EventedFileUpdateChecker.new(files, dirs, &block).tap do |c| wait end end @@ -34,6 +34,48 @@ class EventedFileUpdateCheckerTest < ActiveSupport::TestCase super wait end + + test 'notifies forked processes' do + FileUtils.touch(tmpfiles) + + checker = new_checker(tmpfiles) { } + assert !checker.updated? + + # Pipes used for flow controll across fork. + boot_reader, boot_writer = IO.pipe + touch_reader, touch_writer = IO.pipe + + pid = fork do + assert checker.updated? + + # Clear previous check value. + checker.execute + assert !checker.updated? + + # Fork is booted, ready for file to be touched + # notify parent process. + boot_writer.write("booted") + + # Wait for parent process to signal that file + # has been touched. + IO.select([touch_reader]) + + assert checker.updated? + end + + assert pid + + # Wait for fork to be booted before touching files. + IO.select([boot_reader]) + touch(tmpfiles) + + # Notify fork that files have been touched. + touch_writer.write("touched") + + assert checker.updated? + + Process.wait(pid) + end end class EventedFileUpdateCheckerPathHelperTest < ActiveSupport::TestCase |