diff options
author | Andrew White <andrew.white@unboxedconsulting.com> | 2016-04-03 23:40:27 +0100 |
---|---|---|
committer | Andrew White <andrew.white@unboxedconsulting.com> | 2016-04-03 23:47:05 +0100 |
commit | ae2f193c0379453f73ae08a3df541d2cb0ae00e2 (patch) | |
tree | 7700dd6aedde1f285727bc2a97411d5f78fff01c /activesupport/test | |
parent | 811fd0a6b47c83cd4f668127bb822dc5cdcfc0f5 (diff) | |
download | rails-ae2f193c0379453f73ae08a3df541d2cb0ae00e2.tar.gz rails-ae2f193c0379453f73ae08a3df541d2cb0ae00e2.tar.bz2 rails-ae2f193c0379453f73ae08a3df541d2cb0ae00e2.zip |
Use block form of Dir.mktmpdir to ensure tidy up
If the test run was interrupted in some way then it left temporary
directories inside of test causing the git worktree to be in a dirty
state. By overriding the run method we can use the block form of
Dir.mktmpdir to ensure that the directories are cleaned up no matter
which way the test run is exited.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/file_update_checker_shared_tests.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activesupport/test/file_update_checker_shared_tests.rb b/activesupport/test/file_update_checker_shared_tests.rb index 9c07e38fe5..5207860a0e 100644 --- a/activesupport/test/file_update_checker_shared_tests.rb +++ b/activesupport/test/file_update_checker_shared_tests.rb @@ -5,7 +5,7 @@ module FileUpdateCheckerSharedTests include FileUtils def tmpdir - @tmpdir ||= Dir.mktmpdir(nil, __dir__) + @tmpdir end def tmpfile(name) @@ -16,8 +16,8 @@ module FileUpdateCheckerSharedTests @tmpfiles ||= %w(foo.rb bar.rb baz.rb).map { |f| tmpfile(f) } end - def teardown - FileUtils.rm_rf(@tmpdir) if defined? @tmpdir + def run(*args) + Dir.mktmpdir(nil, __dir__) { |dir| @tmpdir = dir; super } end test 'should not execute the block if no paths are given' do |