tests/tests_extensions.rb
author Jan Vrany <jan.vrany@labware.com>
Tue, 23 Jun 2020 12:16:02 +0100
changeset 294 0f3980335d2b
parent 175 c28460fb4b9d
child 334 eb15c224410b
permissions -rw-r--r--
CI: do not archive (and publish) i686 versions any more 32bit Intel is phasing out already - Microsoft is dropping i686 Windows 10, many Linux distros are dropping i686 architecture too. We still build and test 32bit versions, but no longer archive it nor publish it to save space and bandwidth. We might make it available again upon request.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
173
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
require File.join(File.dirname(__FILE__), '..' , 'rakelib' , 'extensions')
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
require 'tmpdir'
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
require 'test/unit'
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
include RakeFileUtils
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
class RakeFileUtilsTests < Test::Unit::TestCase
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
  def test_which()    
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
    assert File.executable?( which('ls') )
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
    assert which('boguscommand').nil?
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
  end
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
174
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    13
  # A helper for `test_zip_01()`
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    14
  def test_zip_01_fmt(fmt)
173
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
    Dir.mktmpdir do | tmp |
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
      chdir File.join(File.dirname(__FILE__), '..') do
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
        archive = File.join(tmp, "rakelib#{fmt}")
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
        zip "rakelib", archive: archive
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
        assert File.exist? archive
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
        unzip archive
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
        assert File.exist? File.join(tmp, 'rakelib')
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
        assert File.exist? File.join(tmp, 'rakelib', 'extensions.rb')
174
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    23
        assert File.exist? File.join(tmp, 'rakelib', 'support.rb')
173
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
      end
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
    end
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
  end  
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
  def test_zip_01()    
174
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    29
    test_zip_01_fmt('.zip') if which 'zip'
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    30
    test_zip_01_fmt('.tar.bz2') if which 'tar' and which 'bzip2'
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    31
    test_zip_01_fmt('.tar.gz') if which 'tar' and which 'gzip'
173
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
  end
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
  def test_zip_02()     
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
    chdir File.join(File.dirname(__FILE__), '..') do        
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
      fmt = win32? ? '.zip' : '.tar.bz2'
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
      begin
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
        zip "rakelib"        
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
        assert(File.exist? "rakelib#{fmt}")
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
      ensure
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
        rm_f "rakelib#{fmt}" 
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
      end
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
    end
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
  end
174
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    45
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    46
  # A helper for `test_zip_03()`
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    47
  def test_zip_03_fmt(fmt)
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    48
    Dir.mktmpdir do | tmp |
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    49
      chdir File.join(File.dirname(__FILE__), '..') do
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    50
        archive = File.join(tmp, "rakelib#{fmt}")
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    51
        zip "rakelib", archive: archive, include: [ 'extensions.rb' ]
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    52
        assert File.exist? archive
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    53
        unzip archive
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    54
        assert File.exist? File.join(tmp, 'rakelib')
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    55
        assert File.exist? File.join(tmp, 'rakelib', 'extensions.rb')
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    56
        assert (not File.exist? File.join(tmp, 'rakelib', 'support.rb'))
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    57
      end
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    58
    end
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    59
  end  
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    60
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    61
  def test_zip_03()    
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    62
    test_zip_03_fmt('.zip') if which 'zip'
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    63
    test_zip_03_fmt('.tar.bz2') if which 'tar' and which 'bzip2'
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    64
    test_zip_03_fmt('.tar.gz') if which 'tar' and which 'gzip'
89e357ae48b4 Rakefiles: allow `zip()` to archive only a subset of files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 173
diff changeset
    65
  end
175
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    66
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    67
  def test_rm_rf_ex() 
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    68
    def with_test_dir(&block) 
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    69
      Dir.mktmpdir do | tmp |
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    70
        chdir tmp do
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    71
          mkdir_p File.join("a", "b", "c")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    72
          touch File.join("a", "aaa1.txt")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    73
          touch File.join("a", "aaa2.txt")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    74
          touch File.join("a", "aaa3.txt")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    75
          touch File.join("a", "b", "bbb1.txt")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    76
          touch File.join("a", "b", "bbb2.txt")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    77
          touch File.join("a", "b", "bbb3.txt")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    78
          touch File.join("a", "b", "c", "ccc1.txt")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    79
          touch File.join("a", "b", "c", "ccc2.txt")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    80
          touch File.join("a", "b", "c", "ccc3.txt")          
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    81
          yield block
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    82
        end
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    83
      end
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    84
    end    
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    85
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    86
    with_test_dir do
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    87
      rm_rf_ex "a"
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    88
      sh 'ls -lr'
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    89
      assert (not File.exists? "a")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    90
    end
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    91
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    92
    with_test_dir do
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    93
      rm_rf_ex "a", exceptions: ['aaa1.txt']
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    94
      sh 'ls -lr'
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    95
      assert (    File.exists? "a")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    96
      assert (    File.exists? (File.join("a", "aaa1.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    97
      assert (not File.exists? (File.join("a", "aaa2.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    98
      assert (not File.exists? (File.join("a", "aaa3.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    99
      assert (not File.exists? (File.join("a", "b")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   100
    end
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   101
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   102
    with_test_dir do
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   103
      rm_rf_ex "a", exceptions: ['bogus']
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   104
      sh 'ls -lr'
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   105
      assert (not File.exists? "a")      
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   106
    end
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   107
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   108
    with_test_dir do
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   109
      rm_rf_ex "a", exceptions: [File.join('b' 'bogus')]
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   110
      sh 'ls -lr'
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   111
      assert (not File.exists? "a")      
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   112
    end
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   113
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   114
    with_test_dir do
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   115
      rm_rf_ex "a", exceptions: ['b']
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   116
      sh 'ls -lr'
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   117
      assert (    File.exists? "a")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   118
      assert (not File.exists? (File.join("a", "aaa1.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   119
      assert (not File.exists? (File.join("a", "aaa2.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   120
      assert (not File.exists? (File.join("a", "aaa3.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   121
      assert (    File.exists? (File.join("a", "b")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   122
      assert (    File.exists? (File.join("a", "b", "bbb1.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   123
      assert (    File.exists? (File.join("a", "b", "bbb2.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   124
      assert (    File.exists? (File.join("a", "b", "bbb3.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   125
      assert (    File.exists? (File.join("a", "b", "c")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   126
      assert (    File.exists? (File.join("a", "b", "c", "ccc1.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   127
      assert (    File.exists? (File.join("a", "b", "c", "ccc2.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   128
      assert (    File.exists? (File.join("a", "b", "c", "ccc3.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   129
    end
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   130
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   131
    with_test_dir do
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   132
      rm_rf_ex "a", exceptions: [File.join('b', 'bbb1.txt'), File.join('b', 'c', 'ccc3.txt') ]
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   133
      sh 'ls -lr'
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   134
      assert (    File.exists? "a")
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   135
      assert (not File.exists? (File.join("a", "aaa1.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   136
      assert (not File.exists? (File.join("a", "aaa2.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   137
      assert (not File.exists? (File.join("a", "aaa3.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   138
      assert (    File.exists? (File.join("a", "b")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   139
      assert (    File.exists? (File.join("a", "b", "bbb1.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   140
      assert (not File.exists? (File.join("a", "b", "bbb2.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   141
      assert (not File.exists? (File.join("a", "b", "bbb3.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   142
      assert (    File.exists? (File.join("a", "b", "c")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   143
      assert (not File.exists? (File.join("a", "b", "c", "ccc1.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   144
      assert (not File.exists? (File.join("a", "b", "c", "ccc2.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   145
      assert (    File.exists? (File.join("a", "b", "c", "ccc3.txt")))
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   146
    end
c28460fb4b9d Rakefiles: introduced new fileutils functions - `rm_r_ex()` and `rm_rf_ex()`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
   147
  end
173
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
end
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
if __FILE__ == $0
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
  require 'test/unit/ui/console/testrunner'
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
  Test::Unit::UI::Console::TestRunner.run(RakeFileUtilsTests)
43ecb6a2bcbd Rakelib: put `zip()` in par with `unzip()` and guess archive type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
end