diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-17 05:41:10 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-17 05:41:10 +0000 |
commit | c1aec85d88cee9583f3dbe1607eb420209f97321 (patch) | |
tree | 9dbf29fc34858de8a4374b8c769f86efbe6e8a2a /bootstraptest | |
parent | b7f4a583888483cdd45cce998b359a1547b88a66 (diff) | |
download | ruby-c1aec85d88cee9583f3dbe1607eb420209f97321.tar.gz ruby-c1aec85d88cee9583f3dbe1607eb420209f97321.tar.xz ruby-c1aec85d88cee9583f3dbe1607eb420209f97321.zip |
* bootstraptest/runner.rb (in_temporary_working_directory): use
Dir.mktmpdir to create and remove temporary directory.
(Dir.mktmpdir): define if not available.
[ruby-dev:31431]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/runner.rb | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb index bada52062..117f03036 100644 --- a/bootstraptest/runner.rb +++ b/bootstraptest/runner.rb @@ -13,10 +13,38 @@ rescue LoadError retry end +if !Dir.respond_to?(:mktmpdir) + # copied from lib/tmpdir.rb + def Dir.mktmpdir(prefix="d", tmpdir=nil) + tmpdir ||= Dir.tmpdir + t = Time.now.strftime("%Y%m%d") + n = nil + begin + path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}" + path << "-#{n}" if n + Dir.mkdir(path, 0700) + rescue Errno::EEXIST + n ||= 0 + n += 1 + retry + end + + if block_given? + begin + yield path + ensure + FileUtils.remove_entry_secure path + end + else + path + end + end +end + def main @ruby = File.expand_path('miniruby') @verbose = false - dir = File.join(Dir.tmpdir, 'bootstraptest.tmpwd') + dir = nil quiet = false tests = nil ARGV.delete_if {|arg| @@ -176,11 +204,19 @@ def error(msg, additional_message) end def in_temporary_working_directory(dir) - FileUtils.rm_rf dir - Dir.mkdir dir - Dir.chdir(dir) { - yield - } + if dir + FileUtils.rm_rf dir + Dir.mkdir dir + Dir.chdir(dir) { + yield + } + else + Dir.mktmpdir("bootstraptest.tmpwd") {|d| + Dir.chdir(d) { + yield + } + } + end end def cleanup_coredump |