summaryrefslogtreecommitdiff
path: root/test/cgi
diff options
context:
space:
mode:
authorxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-05 00:57:45 +0000
committerxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-05 00:57:45 +0000
commit1362d81a22ab179c1286a61b8d5a54e59784458e (patch)
tree44eec54663cd2129323dd1e2e61d9313b39ef571 /test/cgi
parentd5528ec3580dba09ebbda819c7b10e25d5af5981 (diff)
Mon Nov 5 09:55:05 2012 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
* lib/cgi/core.rb: remove tempfile more early. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/cgi')
-rw-r--r--test/cgi/test_cgi_multipart.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/cgi/test_cgi_multipart.rb b/test/cgi/test_cgi_multipart.rb
index e39003d7c3..62fcc8b0c5 100644
--- a/test/cgi/test_cgi_multipart.rb
+++ b/test/cgi/test_cgi_multipart.rb
@@ -107,6 +107,7 @@ class CGIMultipartTest < Test::Unit::TestCase
def setup
ENV['REQUEST_METHOD'] = 'POST'
+ @tempfiles = []
end
def teardown
@@ -115,6 +116,9 @@ class CGIMultipartTest < Test::Unit::TestCase
end
$stdin.close() if $stdin.is_a?(Tempfile)
$stdin = STDIN
+ @tempfiles.each {|t|
+ t.unlink
+ }
end
def _prepare(data)
@@ -133,6 +137,7 @@ class CGIMultipartTest < Test::Unit::TestCase
ENV['REQUEST_METHOD'] = 'POST'
## set $stdin
tmpfile = Tempfile.new('test_cgi_multipart')
+ @tempfiles << tmpfile
tmpfile.binmode
tmpfile << input
tmpfile.rewind()
@@ -168,6 +173,16 @@ class CGIMultipartTest < Test::Unit::TestCase
assert_equal(hash[:filename] || '', cgi[name].original_filename) #if hash[:filename]
assert_equal(hash[:content_type] || '', cgi[name].content_type) #if hash[:content_type]
end
+ ensure
+ if cgi
+ cgi.params.each {|name, vals|
+ vals.each {|val|
+ if val.kind_of?(Tempfile) && val.path
+ val.unlink
+ end
+ }
+ }
+ end
end
@@ -314,6 +329,7 @@ class CGIMultipartTest < Test::Unit::TestCase
cgi = RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new
assert_equal(cgi['foo'], 'bar')
assert_equal(cgi['file'].read, 'b'*10134)
+ cgi['file'].unlink if cgi['file'].kind_of? Tempfile
end
###