blob: b0e8247672626bf399658ef632a64966c633f546 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
require "test/support/fixtures/testball"
require "cleanup"
require "fileutils"
require "pathname"
describe Homebrew::Cleanup do
let(:ds_store) { Pathname.new("#{HOMEBREW_PREFIX}/Library/.DS_Store") }
around(:each) do |example|
begin
FileUtils.touch ds_store
example.run
ensure
FileUtils.rm_f ds_store
end
end
describe "::cleanup" do
it "removes .DS_Store files" do
shutup do
described_class.cleanup
end
expect(ds_store).not_to exist
end
it "doesn't remove anything if `--dry-run` is specified" do
ARGV << "--dry-run"
shutup do
described_class.cleanup
end
expect(ds_store).to exist
end
end
specify "::cleanup_formula" do
f1 = Class.new(Testball) do
version "1.0"
end.new
f2 = Class.new(Testball) do
version "0.2"
version_scheme 1
end.new
f3 = Class.new(Testball) do
version "0.3"
version_scheme 1
end.new
f4 = Class.new(Testball) do
version "0.1"
version_scheme 2
end.new
shutup do
[f1, f2, f3, f4].each do |f|
f.brew do
f.install
end
Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
end
end
expect(f1).to be_installed
expect(f2).to be_installed
expect(f3).to be_installed
expect(f4).to be_installed
shutup do
described_class.cleanup_formula f3
end
expect(f1).not_to be_installed
expect(f2).not_to be_installed
expect(f3).to be_installed
expect(f4).to be_installed
end
specify "::cleanup_logs" do
path = (HOMEBREW_LOGS/"delete_me")
path.mkpath
ARGV << "--prune=all"
shutup do
described_class.cleanup_logs
end
expect(path).not_to exist
end
describe "::cleanup_cache" do
it "cleans up incomplete downloads" do
incomplete = (HOMEBREW_CACHE/"something.incomplete")
incomplete.mkpath
shutup do
described_class.cleanup_cache
end
expect(incomplete).not_to exist
end
it "cleans up 'java_cache'" do
java_cache = (HOMEBREW_CACHE/"java_cache")
java_cache.mkpath
shutup do
described_class.cleanup_cache
end
expect(java_cache).not_to exist
end
it "cleans up 'npm_cache'" do
npm_cache = (HOMEBREW_CACHE/"npm_cache")
npm_cache.mkpath
shutup do
described_class.cleanup_cache
end
expect(npm_cache).not_to exist
end
end
end
|