diff --git a/tests/run.rb b/tests/run.rb index 62d693a70..3dd28e175 100755 --- a/tests/run.rb +++ b/tests/run.rb @@ -90,5 +90,8 @@ EOHELP exit controller.num_failed > 0 ? 1 : 0 end -setup -main +Dir.mktmpdir do |dir| + $temp_dir = dir + setup + main +end diff --git a/tests/test.d/simple_test.rb b/tests/test.d/simple_test.rb index fbd8834fd..09f4d405b 100644 --- a/tests/test.d/simple_test.rb +++ b/tests/test.d/simple_test.rb @@ -67,7 +67,7 @@ class SimpleTest end def tmp_name_prefix - [ "/tmp/mkvtoolnix-auto-test-#{self.class.name}", $$.to_s, Thread.current[:number] ].join("-") + "-" + [ "#{$temp_dir}/mkvtoolnix-auto-test-#{self.class.name}", $$.to_s, Thread.current[:number] ].join("-") + "-" end def tmp_name @@ -104,8 +104,8 @@ class SimpleTest def unlink_tmp_files return if ENV["KEEP_TMPFILES"] == "1" re = %r{^#{self.tmp_name_prefix}} - Dir.entries("/tmp").each do |entry| - file = "/tmp/#{entry}" + Dir.entries($temp_dir).each do |entry| + file = "#{$temp_dir}/#{entry}" File.unlink(file) if re.match(file) and File.exists?(file) end end diff --git a/tests/test.d/test.rb b/tests/test.d/test.rb index 9620cbfe2..def4252bc 100644 --- a/tests/test.d/test.rb +++ b/tests/test.d/test.rb @@ -23,8 +23,8 @@ class Test def unlink_tmp_files return if (ENV["KEEP_TMPFILES"] == "1") re = /^#{self.tmp_name_prefix}/ - Dir.entries("/tmp").each do |entry| - file = "/tmp/#{entry}" + Dir.entries($temp_dir).each do |entry| + file = "#{$temp_dir}/#{entry}" File.unlink(file) if re.match(file) and File.exists?(file) end end @@ -59,7 +59,7 @@ class Test end def tmp_name_prefix - [ "/tmp/mkvtoolnix-auto-test", $$.to_s, Thread.current[:number] ].join("-") + "-" + [ "#{$temp_dir}/mkvtoolnix-auto-test", $$.to_s, Thread.current[:number] ].join("-") + "-" end def tmp_name