From 1c493df4143b5f871584a5387780f99b4b319dcf Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 2 Feb 2005 15:15:17 +0000 Subject: [PATCH] Easier removal of temporary files for test classes. Added a new exception for handling inside the test classes themselves so that they do not have to use RuntimeError which is used extensively by the Test class itself. --- tests/run.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/run.rb b/tests/run.rb index 6566861f2..128d07bc8 100755 --- a/tests/run.rb +++ b/tests/run.rb @@ -1,5 +1,8 @@ #!/usr/bin/ruby +class SubtestError < RuntimeError +end + class Test attr_reader :commands attr_reader :debug_commands @@ -18,14 +21,18 @@ class Test return error("Trying to run the base class") end + def unlink_tmp_files + n = "mkvtoolnix-auto-test-" + $$.to_s + "-" + Dir.entries("/tmp").each do |e| + File.unlink("/tmp/#{e}") if (e =~ /^#{n}/) + end + end + def run_test begin return run rescue RuntimeError => ex - n = "mkvtoolnix-auto-test-" + $$.to_s + "-" - Dir.entries("/tmp").each do |e| - File.unlink("/tmp/#{e}") if (e =~ /^#{n}/) - end + unlink_tmp_files puts(ex.to_s) return nil end