aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/test_cleaner.rb
blob: 81c2e27d438d572f034f92b415b1b320ff744718 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'testing_env'
require 'cleaner'

class CleanerTestBall < Formula
  def initialize name=nil
    @url="file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz"
    @homepage = 'http://example.com/'
    super "cleanertestball"
  end

  def install
    TEST_FOLDER.cd do
      bin.mkpath
      lib.mkpath
      cp 'mach/a.out', bin
      cp 'mach/fat.dylib', lib
      cp 'mach/x86_64.dylib', lib
      cp 'mach/i386.dylib', lib
    end
  end
end

class CleanerTests < Test::Unit::TestCase
  def test_clean_file
    f = CleanerTestBall.new
    nostdout { f.brew { f.install } }

    assert_nothing_raised { Cleaner.new f }
    assert_equal 0100555, (f.bin/'a.out').stat.mode
    assert_equal 0100444, (f.lib/'fat.dylib').stat.mode
    assert_equal 0100444, (f.lib/'x86_64.dylib').stat.mode
    assert_equal 0100444, (f.lib/'i386.dylib').stat.mode
  end
end