test.rb

Test script (requires bindfs and linux but easy enough to modify) - Martin Pärtel, 01/17/2013 04:05 AM

Download (627 Bytes)

 
1

    
2
# Requires http://code.google.com/p/bindfs/ and linux. Can be apt-get'ed.
3

    
4
require 'fileutils'
5

    
6
def test
7
  FileUtils.rm_rf('testdir')
8
  FileUtils.mkdir('testdir')
9
  Dir.chdir 'testdir' do
10
    FileUtils.mkdir_p('fs1/from')
11
    FileUtils.mkdir_p('fs2/to')
12
    system('bindfs fs2 fs2')
13
    begin
14
      Dir.chdir 'fs1/from' do
15
        system('ln -sf a b')
16
        FileUtils.touch('a')
17
      end
18
      FileUtils::Verbose.mv('fs1/from', 'fs2/to')
19
    ensure
20
      system('fusermount -uz fs2') # Mac users can try umount instead of fusermount -u
21
    end
22
  end
23
end
24

    
25

    
26
begin
27
  100.times { test }
28
ensure
29
  FileUtils.rm_rf('testdir')
30
end