1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activesupport/test/file_update_checker_test.rb
Jonathan Hefner 86c732a606 Avoid double wait in EventedFileUpdateCheckerTest
Waiting after touching the file system is a concern of
`EventedFileUpdateCheckerTest`.  Therefore, only call `wait` inside
`EventedFileUpdateCheckerTest`.  This avoids calling `wait` an extra
time when calling `touch`.

Before:

    $ bin/test test/evented_file_update_checker_test.rb test/file_update_checker_test.rb

    Finished in 43.357019s, 0.9918 runs/s, 2.5371 assertions/s.
    43 runs, 110 assertions, 0 failures, 0 errors, 0 skips

After:

    $ bin/test test/evented_file_update_checker_test.rb test/file_update_checker_test.rb

    Finished in 34.351007s, 1.2518 runs/s, 3.2022 assertions/s.
    43 runs, 110 assertions, 0 failures, 0 errors, 0 skips
2021-07-22 12:29:27 -05:00

17 lines
429 B
Ruby

# frozen_string_literal: true
require_relative "abstract_unit"
require_relative "file_update_checker_shared_tests"
class FileUpdateCheckerTest < ActiveSupport::TestCase
include FileUpdateCheckerSharedTests
def new_checker(files = [], dirs = {}, &block)
ActiveSupport::FileUpdateChecker.new(files, dirs, &block)
end
def touch(files)
sleep 1 # let's wait a bit to ensure there's a new mtime
super
end
end