Cleanup temporary directory after running

This commit is contained in:
Mitchell Hashimoto 2011-11-02 21:41:41 -07:00
parent 4c6f8d2b52
commit a19fa6a07c
2 changed files with 13 additions and 0 deletions

View File

@ -47,4 +47,8 @@ class AcceptanceTest < Test::Unit::TestCase
apps = { "vagrant" => config.vagrant_path }
@environment = Acceptance::IsolatedEnvironment.new(apps, config.env)
end
teardown do
@environment.close
end
end

View File

@ -12,6 +12,9 @@ module Acceptance
class IsolatedEnvironment
include POSIX::Spawn
attr_reader :homedir
attr_reader :workdir
# Initializes an isolated environment. You can pass in some
# options here to configure runing custom applications in place
# of others as well as specifying environmental variables.
@ -55,6 +58,12 @@ module Acceptance
return ExecuteProcess.new(status.exitstatus, stdout, stderr)
end
# Closes the environment, cleans up the temporary directories, etc.
def close
# Delete the temporary directory
FileUtils.rm_rf(@tempdir.path)
end
end
# This class represents a process which has run via the IsolatedEnvironment.