~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to test/test_tempfile.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
  def test_saves_in_dir_tmpdir_by_default
31
31
    t = tempfile("foo")
32
32
    assert_equal Dir.tmpdir, File.dirname(t.path)
 
33
    bug3733 = '[ruby-dev:42089]'
 
34
    assert_nothing_raised(SecurityError, bug3733) {
 
35
      proc {$SAFE = 1; File.expand_path(Dir.tmpdir)}.call
 
36
    }
33
37
  end
34
38
 
35
39
  def test_saves_in_given_directory
86
90
  end
87
91
 
88
92
  def test_unlink_before_close_works_on_posix_systems
89
 
    skip "on Windows, unlink is always delayed" if /mswin|mingw/ =~ RUBY_PLATFORM
90
93
    tempfile = tempfile("foo")
91
94
    begin
92
95
      path = tempfile.path
100
103
      tempfile.close
101
104
      tempfile.unlink
102
105
    end
103
 
  end
 
106
  end unless /mswin|mingw/ =~ RUBY_PLATFORM
104
107
 
105
108
  def test_close_and_close_p
106
109
    t = tempfile("foo")
119
122
  end
120
123
 
121
124
  def test_close_with_unlink_now_true_does_not_unlink_if_already_unlinked
122
 
    skip "on Windows, unlink is always delayed" if /mswin|mingw/ =~ RUBY_PLATFORM
123
125
    t = tempfile("foo")
124
126
    path = t.path
125
127
    t.unlink
130
132
    ensure
131
133
      File.unlink(path) rescue nil
132
134
    end
133
 
  end
 
135
  end unless /mswin|mingw/ =~ RUBY_PLATFORM
134
136
 
135
137
  def test_close_bang_works
136
138
    t = tempfile("foo")
142
144
  end
143
145
 
144
146
  def test_close_bang_does_not_unlink_if_already_unlinked
145
 
    skip "on Windows, unlink is always delayed" if /mswin|mingw/ =~ RUBY_PLATFORM
146
147
    t = tempfile("foo")
147
148
    path = t.path
148
149
    t.unlink
153
154
    ensure
154
155
      File.unlink(path) rescue nil
155
156
    end
156
 
  end
 
157
  end unless /mswin|mingw/ =~ RUBY_PLATFORM
157
158
 
158
159
  def test_finalizer_does_not_unlink_if_already_unlinked
159
 
    skip "on Windows, unlink is always delayed" if /mswin|mingw/ =~ RUBY_PLATFORM
160
160
    assert_in_out_err('-rtempfile', <<-'EOS') do |(filename,*), (error,*)|
161
161
file = Tempfile.new('foo')
162
162
path = file.path
183
183
      end
184
184
      assert_nil error
185
185
    end
186
 
  end
 
186
  end unless /mswin|mingw/ =~ RUBY_PLATFORM
187
187
 
188
188
  def test_close_does_not_make_path_nil
189
189
    t = tempfile("foo")