Make file update checker tests more resilient on Windows

Without the `wdm` gem, it appears that `listen` keeps an open handle to
each of these files, causing them not to be removed when the tempdir
tries to clean iteslf up, and then directory to fail to unlink. In
addition to fixing that particular failure, we now construct OS agnostic
paths, and capture exceptions if the directory fails to unlink so that
minitest will report it rather than crash
This commit is contained in:
Sean Griffin 2016-04-21 10:54:54 -06:00
parent 81f4a7dce4
commit 1f47c4b0df
3 changed files with 10 additions and 5 deletions

@ -129,3 +129,4 @@ end
# A gem necessary for Active Record tests with IBM DB.
gem 'ibm_db' if ENV['IBM_DB']
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'wdm', '>= 0.1.0', platforms: [:mingw, :mswin, :x64_mingw, :mswin64]

@ -265,6 +265,7 @@ GEM
w3c_validators (1.2)
json
nokogiri
wdm (0.1.1)
websocket-driver (0.6.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
@ -323,6 +324,7 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
w3c_validators
wdm (>= 0.1.0)
BUNDLED WITH
1.11.2

@ -9,7 +9,7 @@ def tmpdir
end
def tmpfile(name)
"#{tmpdir}/#{name}"
File.join(tmpdir, name)
end
def tmpfiles
@ -17,7 +17,9 @@ def tmpfiles
end
def run(*args)
Dir.mktmpdir(nil, __dir__) { |dir| @tmpdir = dir; super }
capture_exceptions do
Dir.mktmpdir(nil, __dir__) { |dir| @tmpdir = dir; super }
end
end
test 'should not execute the block if no paths are given' do
@ -225,7 +227,7 @@ def run(*args)
assert !checker.execute_if_updated
assert_equal 0, i
touch("#{subdir}/nested.rb")
touch(File.join(subdir, "nested.rb"))
assert checker.execute_if_updated
assert_equal 1, i
@ -245,12 +247,12 @@ def run(*args)
assert_equal 0, i
# subdir does not look for Ruby files, but its parent tmpdir does.
touch("#{subdir}/nested.rb")
touch(File.join(subdir, "nested.rb"))
assert checker.execute_if_updated
assert_equal 1, i
touch("#{subdir}/nested.txt")
touch(File.join(subdir, "nested.txt"))
assert checker.execute_if_updated
assert_equal 2, i