puppet 3.2.0.rc1 → 3.2.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/Gemfile +4 -4
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/application/master.rb +1 -1
- data/lib/puppet/daemon.rb +2 -0
- data/lib/puppet/defaults.rb +7 -0
- data/lib/puppet/file_serving/fileset.rb +73 -82
- data/lib/puppet/indirector/catalog/static_compiler.rb +1 -1
- data/lib/puppet/network/http/connection.rb +1 -1
- data/lib/puppet/network/http/webrick.rb +5 -1
- data/lib/puppet/network/server.rb +4 -0
- data/lib/puppet/provider/service/init.rb +2 -1
- data/lib/puppet/provider/service/systemd.rb +1 -0
- data/lib/puppet/rails/fact_name.rb +1 -0
- data/lib/puppet/rails/fact_value.rb +2 -0
- data/lib/puppet/resource/type_collection.rb +5 -3
- data/lib/puppet/settings/file_setting.rb +1 -1
- data/lib/puppet/transaction/resource_harness.rb +6 -0
- data/lib/puppet/util/adsi.rb +1 -1
- data/lib/puppet/util/monkey_patches.rb +0 -19
- data/lib/puppet/version.rb +1 -1
- data/spec/lib/puppet_spec/database.rb +1 -1
- data/spec/unit/daemon_spec.rb +12 -2
- data/spec/unit/file_serving/fileset_spec.rb +255 -305
- data/spec/unit/pops/parser/rgen_sanitycheck_spec.rb +1 -2
- data/spec/unit/provider/service/init_spec.rb +1 -1
- data/spec/unit/provider/service/systemd_spec.rb +10 -0
- data/spec/unit/resource/type_collection_spec.rb +3 -1
- data/spec/unit/settings/file_setting_spec.rb +7 -1
- data/spec/unit/transaction/resource_harness_spec.rb +30 -1
- metadata +2713 -2713
data/spec/unit/daemon_spec.rb
CHANGED
@@ -39,6 +39,8 @@ describe Puppet::Daemon, :unless => Puppet.features.microsoft_windows? do
|
|
39
39
|
@daemon.reopen_logs
|
40
40
|
end
|
41
41
|
|
42
|
+
let(:server) { stub("Server", :start => nil, :wait_for_shutdown => nil) }
|
43
|
+
|
42
44
|
describe "when setting signal traps" do
|
43
45
|
signals = {:INT => :stop, :TERM => :stop }
|
44
46
|
signals.update({:HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs}) unless Puppet.features.microsoft_windows?
|
@@ -74,12 +76,21 @@ describe Puppet::Daemon, :unless => Puppet.features.microsoft_windows? do
|
|
74
76
|
end
|
75
77
|
|
76
78
|
it "should start its server if one is configured" do
|
77
|
-
server =
|
79
|
+
@daemon.server = server
|
80
|
+
|
78
81
|
server.expects(:start)
|
79
82
|
@daemon.stubs(:server).returns server
|
80
83
|
|
81
84
|
@daemon.start
|
82
85
|
end
|
86
|
+
|
87
|
+
it "waits for the server to shutdown when there is one" do
|
88
|
+
@daemon.server = server
|
89
|
+
|
90
|
+
server.expects(:wait_for_shutdown)
|
91
|
+
|
92
|
+
@daemon.start
|
93
|
+
end
|
83
94
|
end
|
84
95
|
|
85
96
|
describe "when stopping" do
|
@@ -97,7 +108,6 @@ describe Puppet::Daemon, :unless => Puppet.features.microsoft_windows? do
|
|
97
108
|
end
|
98
109
|
|
99
110
|
it "should stop its server if one is configured" do
|
100
|
-
server = mock 'server'
|
101
111
|
server.expects(:stop)
|
102
112
|
@daemon.stubs(:server).returns server
|
103
113
|
expect { @daemon.stop }.to exit_with 0
|
@@ -3,376 +3,326 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
require 'puppet/file_serving/fileset'
|
5
5
|
|
6
|
-
describe Puppet::FileServing::Fileset
|
6
|
+
describe Puppet::FileServing::Fileset do
|
7
7
|
include PuppetSpec::Files
|
8
|
+
let(:somefile) { make_absolute("/some/file") }
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should require a path" do
|
16
|
-
proc { Puppet::FileServing::Fileset.new }.should raise_error(ArgumentError)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should fail if its path is not fully qualified" do
|
20
|
-
proc { Puppet::FileServing::Fileset.new("some/file") }.should raise_error(ArgumentError)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should not fail if the path is fully qualified, with a trailing separator" do
|
24
|
-
path_with_separator = "#{@somefile}#{File::SEPARATOR}"
|
25
|
-
File.stubs(:lstat).with(@somefile).returns stub('stat')
|
26
|
-
fileset = Puppet::FileServing::Fileset.new(path_with_separator)
|
27
|
-
fileset.path.should == @somefile
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should not fail if the path is just the file separator" do
|
31
|
-
path = File.expand_path(File::SEPARATOR)
|
32
|
-
File.stubs(:lstat).with(path).returns stub('stat')
|
33
|
-
fileset = Puppet::FileServing::Fileset.new(path)
|
34
|
-
fileset.path.should == path
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should fail if its path does not exist" do
|
38
|
-
File.expects(:lstat).with(@somefile).returns nil
|
39
|
-
proc { Puppet::FileServing::Fileset.new(@somefile) }.should raise_error(ArgumentError)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should accept a 'recurse' option" do
|
43
|
-
File.expects(:lstat).with(@somefile).returns stub("stat")
|
44
|
-
set = Puppet::FileServing::Fileset.new(@somefile, :recurse => true)
|
45
|
-
set.recurse.should be_true
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should accept a 'recurselimit' option" do
|
49
|
-
File.expects(:lstat).with(@somefile).returns stub("stat")
|
50
|
-
set = Puppet::FileServing::Fileset.new(@somefile, :recurselimit => 3)
|
51
|
-
set.recurselimit.should == 3
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should accept an 'ignore' option" do
|
55
|
-
File.expects(:lstat).with(@somefile).returns stub("stat")
|
56
|
-
set = Puppet::FileServing::Fileset.new(@somefile, :ignore => ".svn")
|
57
|
-
set.ignore.should == [".svn"]
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should accept a 'links' option" do
|
61
|
-
File.expects(:lstat).with(@somefile).returns stub("stat")
|
62
|
-
set = Puppet::FileServing::Fileset.new(@somefile, :links => :manage)
|
63
|
-
set.links.should == :manage
|
64
|
-
end
|
10
|
+
context "when initializing" do
|
11
|
+
it "requires a path" do
|
12
|
+
expect { Puppet::FileServing::Fileset.new }.to raise_error(ArgumentError)
|
13
|
+
end
|
65
14
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
set.checksum_type.should == :test
|
70
|
-
end
|
15
|
+
it "fails if its path is not fully qualified" do
|
16
|
+
expect { Puppet::FileServing::Fileset.new("some/file") }.to raise_error(ArgumentError, "Fileset paths must be fully qualified: some/file")
|
17
|
+
end
|
71
18
|
|
72
|
-
|
73
|
-
|
74
|
-
|
19
|
+
it "removes a trailing file path separator" do
|
20
|
+
path_with_separator = "#{somefile}#{File::SEPARATOR}"
|
21
|
+
File.stubs(:lstat).with(somefile).returns stub('stat')
|
22
|
+
fileset = Puppet::FileServing::Fileset.new(path_with_separator)
|
23
|
+
fileset.path.should == somefile
|
24
|
+
end
|
75
25
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
26
|
+
it "can be created from the root directory" do
|
27
|
+
path = File.expand_path(File::SEPARATOR)
|
28
|
+
File.stubs(:lstat).with(path).returns stub('stat')
|
29
|
+
fileset = Puppet::FileServing::Fileset.new(path)
|
30
|
+
fileset.path.should == path
|
31
|
+
end
|
80
32
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
33
|
+
it "fails if its path does not exist" do
|
34
|
+
File.expects(:lstat).with(somefile).raises(Errno::ENOENT)
|
35
|
+
expect { Puppet::FileServing::Fileset.new(somefile) }.to raise_error(ArgumentError, "Fileset paths must exist")
|
36
|
+
end
|
85
37
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
38
|
+
it "accepts a 'recurse' option" do
|
39
|
+
File.expects(:lstat).with(somefile).returns stub("stat")
|
40
|
+
set = Puppet::FileServing::Fileset.new(somefile, :recurse => true)
|
41
|
+
set.recurse.should be_true
|
42
|
+
end
|
90
43
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
44
|
+
it "accepts a 'recurselimit' option" do
|
45
|
+
File.expects(:lstat).with(somefile).returns stub("stat")
|
46
|
+
set = Puppet::FileServing::Fileset.new(somefile, :recurselimit => 3)
|
47
|
+
set.recurselimit.should == 3
|
48
|
+
end
|
95
49
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
50
|
+
it "accepts an 'ignore' option" do
|
51
|
+
File.expects(:lstat).with(somefile).returns stub("stat")
|
52
|
+
set = Puppet::FileServing::Fileset.new(somefile, :ignore => ".svn")
|
53
|
+
set.ignore.should == [".svn"]
|
54
|
+
end
|
100
55
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
@myfile = make_absolute("/my/file")
|
56
|
+
it "accepts a 'links' option" do
|
57
|
+
File.expects(:lstat).with(somefile).returns stub("stat")
|
58
|
+
set = Puppet::FileServing::Fileset.new(somefile, :links => :manage)
|
59
|
+
set.links.should == :manage
|
106
60
|
end
|
107
61
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
62
|
+
it "accepts a 'checksum_type' option" do
|
63
|
+
File.expects(:lstat).with(somefile).returns stub("stat")
|
64
|
+
set = Puppet::FileServing::Fileset.new(somefile, :checksum_type => :test)
|
65
|
+
set.checksum_type.should == :test
|
66
|
+
end
|
113
67
|
|
114
|
-
|
115
|
-
|
116
|
-
Puppet::FileServing::Fileset.new(@myfile, request).send(option).should == @values[option]
|
117
|
-
end
|
68
|
+
it "fails if 'links' is set to anything other than :manage or :follow" do
|
69
|
+
expect { Puppet::FileServing::Fileset.new(somefile, :links => :whatever) }.to raise_error(ArgumentError, "Invalid :links value 'whatever'")
|
118
70
|
end
|
119
71
|
|
120
|
-
it "
|
121
|
-
|
122
|
-
Puppet::FileServing::Fileset.new(
|
72
|
+
it "defaults to 'false' for recurse" do
|
73
|
+
File.expects(:lstat).with(somefile).returns stub("stat")
|
74
|
+
Puppet::FileServing::Fileset.new(somefile).recurse.should == false
|
123
75
|
end
|
124
76
|
|
125
|
-
it "
|
126
|
-
|
127
|
-
Puppet::FileServing::Fileset.new(
|
77
|
+
it "defaults to :infinite for recurselimit" do
|
78
|
+
File.expects(:lstat).with(somefile).returns stub("stat")
|
79
|
+
Puppet::FileServing::Fileset.new(somefile).recurselimit.should == :infinite
|
128
80
|
end
|
129
81
|
|
130
|
-
it "
|
131
|
-
|
132
|
-
Puppet::FileServing::Fileset.new(
|
82
|
+
it "defaults to an empty ignore list" do
|
83
|
+
File.expects(:lstat).with(somefile).returns stub("stat")
|
84
|
+
Puppet::FileServing::Fileset.new(somefile).ignore.should == []
|
133
85
|
end
|
134
|
-
end
|
135
|
-
end
|
136
86
|
|
137
|
-
|
138
|
-
|
87
|
+
it "defaults to :manage for links" do
|
88
|
+
File.expects(:lstat).with(somefile).returns stub("stat")
|
89
|
+
Puppet::FileServing::Fileset.new(somefile).links.should == :manage
|
90
|
+
end
|
139
91
|
|
140
|
-
|
141
|
-
|
142
|
-
File.expects(:lstat).with(@path).returns stub("stat")
|
143
|
-
@fileset = Puppet::FileServing::Fileset.new(@path)
|
144
|
-
end
|
92
|
+
describe "using an indirector request" do
|
93
|
+
let(:values) { { :links => :manage, :ignore => %w{a b}, :recurse => true, :recurselimit => 1234 } }
|
145
94
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
@fileset.recurse?(0).should be_true
|
150
|
-
end
|
95
|
+
before :each do
|
96
|
+
File.stubs(:lstat).returns stub("stat")
|
97
|
+
end
|
151
98
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
end
|
99
|
+
[:recurse, :recurselimit, :ignore, :links].each do |option|
|
100
|
+
it "passes the #{option} option on to the fileset if present" do
|
101
|
+
request = Puppet::Indirector::Request.new(:file_serving, :find, "foo", nil, {option => values[option]})
|
156
102
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
@fileset.recurse?(0).should be_true
|
161
|
-
end
|
103
|
+
Puppet::FileServing::Fileset.new(somefile, request).send(option).should == values[option]
|
104
|
+
end
|
105
|
+
end
|
162
106
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
@fileset.recurse?(1).should be_true
|
167
|
-
end
|
107
|
+
it "converts the integer as a string to their integer counterpart when setting options" do
|
108
|
+
request = Puppet::Indirector::Request.new(:file_serving, :find, "foo", nil,
|
109
|
+
{:recurselimit => "1234"})
|
168
110
|
|
169
|
-
|
170
|
-
|
171
|
-
@fileset.recurselimit = 1
|
172
|
-
@fileset.recurse?(2).should be_false
|
173
|
-
end
|
174
|
-
end
|
111
|
+
Puppet::FileServing::Fileset.new(somefile, request).recurselimit.should == 1234
|
112
|
+
end
|
175
113
|
|
176
|
-
|
177
|
-
|
114
|
+
it "converts the string 'true' to the boolean true when setting options" do
|
115
|
+
request = Puppet::Indirector::Request.new(:file_serving, :find, "foo", nil,
|
116
|
+
{:recurse => "true"})
|
178
117
|
|
179
|
-
|
180
|
-
|
181
|
-
File.expects(:lstat).with(@path).returns stub("stat", :directory? => true)
|
182
|
-
@fileset = Puppet::FileServing::Fileset.new(@path)
|
118
|
+
Puppet::FileServing::Fileset.new(somefile, request).recurse.should == true
|
119
|
+
end
|
183
120
|
|
184
|
-
|
185
|
-
|
186
|
-
|
121
|
+
it "converts the string 'false' to the boolean false when setting options" do
|
122
|
+
request = Puppet::Indirector::Request.new(:file_serving, :find, "foo", nil,
|
123
|
+
{:recurse => "false"})
|
187
124
|
|
188
|
-
|
189
|
-
File.stubs(stat_method).with(path).returns(@dirstat)
|
190
|
-
Dir.stubs(:entries).with(path).returns(%w{one two .svn CVS})
|
191
|
-
|
192
|
-
# Keep track of the files we're stubbing.
|
193
|
-
@files = %w{.}
|
194
|
-
|
195
|
-
%w{one two .svn CVS}.each do |subdir|
|
196
|
-
@files << subdir # relative path
|
197
|
-
subpath = File.join(path, subdir)
|
198
|
-
File.stubs(stat_method).with(subpath).returns(@dirstat)
|
199
|
-
Dir.stubs(:entries).with(subpath).returns(%w{.svn CVS file1 file2})
|
200
|
-
%w{file1 file2 .svn CVS}.each do |file|
|
201
|
-
@files << File.join(subdir, file) # relative path
|
202
|
-
File.stubs(stat_method).with(File.join(subpath, file)).returns(@filestat)
|
125
|
+
Puppet::FileServing::Fileset.new(somefile, request).recurse.should == false
|
203
126
|
end
|
204
127
|
end
|
205
128
|
end
|
206
129
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
130
|
+
context "when recursing" do
|
131
|
+
before do
|
132
|
+
@path = make_absolute("/my/path")
|
133
|
+
File.expects(:lstat).with(@path).returns stub("stat", :directory? => true)
|
134
|
+
@fileset = Puppet::FileServing::Fileset.new(@path)
|
212
135
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
@fileset.files.should == %w{.}
|
217
|
-
end
|
136
|
+
@dirstat = stub 'dirstat', :directory? => true
|
137
|
+
@filestat = stub 'filestat', :directory? => false
|
138
|
+
end
|
218
139
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
140
|
+
def mock_dir_structure(path, stat_method = :lstat)
|
141
|
+
File.stubs(stat_method).with(path).returns(@dirstat)
|
142
|
+
Dir.stubs(:entries).with(path).returns(%w{one two .svn CVS})
|
143
|
+
|
144
|
+
# Keep track of the files we're stubbing.
|
145
|
+
@files = %w{.}
|
146
|
+
|
147
|
+
%w{one two .svn CVS}.each do |subdir|
|
148
|
+
@files << subdir # relative path
|
149
|
+
subpath = File.join(path, subdir)
|
150
|
+
File.stubs(stat_method).with(subpath).returns(@dirstat)
|
151
|
+
Dir.stubs(:entries).with(subpath).returns(%w{.svn CVS file1 file2})
|
152
|
+
%w{file1 file2 .svn CVS}.each do |file|
|
153
|
+
@files << File.join(subdir, file) # relative path
|
154
|
+
File.stubs(stat_method).with(File.join(subpath, file)).returns(@filestat)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
227
158
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
159
|
+
MockStat = Struct.new(:path, :directory) do
|
160
|
+
# struct doesn't support thing ending in ?
|
161
|
+
def directory?
|
162
|
+
directory
|
163
|
+
end
|
164
|
+
end
|
233
165
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
166
|
+
MockDirectory = Struct.new(:name, :entries) do
|
167
|
+
def mock(base_path)
|
168
|
+
path = File.join(base_path, name)
|
169
|
+
File.stubs(:lstat).with(path).returns(MockStat.new(path, true))
|
170
|
+
Dir.stubs(:entries).with(path).returns(['.', '..'] + entries.map(&:name))
|
171
|
+
entries.each do |entry|
|
172
|
+
entry.mock(path)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
240
176
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
177
|
+
MockFile = Struct.new(:name) do
|
178
|
+
def mock(base_path)
|
179
|
+
path = File.join(base_path, name)
|
180
|
+
File.stubs(:lstat).with(path).returns(MockStat.new(path, false))
|
181
|
+
end
|
182
|
+
end
|
247
183
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
184
|
+
it "doesn't ignore pending directories when the last entry at the top level is a file" do
|
185
|
+
structure = MockDirectory.new('path',
|
186
|
+
[MockDirectory.new('dir1',
|
187
|
+
[MockDirectory.new('a', [MockFile.new('f')])]),
|
188
|
+
MockFile.new('file')])
|
189
|
+
structure.mock(make_absolute('/your'))
|
190
|
+
fileset = Puppet::FileServing::Fileset.new(make_absolute('/your/path'))
|
191
|
+
fileset.recurse = true
|
192
|
+
fileset.links = :manage
|
193
|
+
fileset.files.should == [".", "dir1", "file", "dir1/a", "dir1/a/f"]
|
194
|
+
end
|
254
195
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
end
|
196
|
+
it "recurses through the whole file tree if :recurse is set to 'true'" do
|
197
|
+
mock_dir_structure(@path)
|
198
|
+
@fileset.recurse = true
|
199
|
+
@fileset.files.sort.should == @files.sort
|
200
|
+
end
|
261
201
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
end
|
202
|
+
it "does not recurse if :recurse is set to 'false'" do
|
203
|
+
mock_dir_structure(@path)
|
204
|
+
@fileset.recurse = false
|
205
|
+
@fileset.files.should == %w{.}
|
206
|
+
end
|
268
207
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
@fileset.files.sort.should == @files.sort
|
276
|
-
end
|
277
|
-
end
|
208
|
+
it "recurses to the level set by :recurselimit" do
|
209
|
+
mock_dir_structure(@path)
|
210
|
+
@fileset.recurse = true
|
211
|
+
@fileset.recurselimit = 1
|
212
|
+
@fileset.files.should == %w{. one two .svn CVS}
|
213
|
+
end
|
278
214
|
|
279
|
-
|
280
|
-
|
215
|
+
it "ignores the '.' and '..' directories in subdirectories" do
|
216
|
+
mock_dir_structure(@path)
|
217
|
+
@fileset.recurse = true
|
218
|
+
@fileset.files.sort.should == @files.sort
|
219
|
+
end
|
281
220
|
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
221
|
+
it "does not fail if the :ignore value provided is nil" do
|
222
|
+
mock_dir_structure(@path)
|
223
|
+
@fileset.recurse = true
|
224
|
+
@fileset.ignore = nil
|
225
|
+
expect { @fileset.files }.to_not raise_error
|
226
|
+
end
|
288
227
|
|
289
|
-
|
228
|
+
it "ignores files that match a single pattern in the ignore list" do
|
229
|
+
mock_dir_structure(@path)
|
230
|
+
@fileset.recurse = true
|
231
|
+
@fileset.ignore = ".svn"
|
232
|
+
@fileset.files.find { |file| file.include?(".svn") }.should be_nil
|
233
|
+
end
|
290
234
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
235
|
+
it "ignores files that match any of multiple patterns in the ignore list" do
|
236
|
+
mock_dir_structure(@path)
|
237
|
+
@fileset.recurse = true
|
238
|
+
@fileset.ignore = %w{.svn CVS}
|
239
|
+
@fileset.files.find { |file| file.include?(".svn") or file.include?("CVS") }.should be_nil
|
240
|
+
end
|
295
241
|
|
296
|
-
|
297
|
-
|
298
|
-
|
242
|
+
it "uses File.stat if :links is set to :follow" do
|
243
|
+
mock_dir_structure(@path, :stat)
|
244
|
+
@fileset.recurse = true
|
245
|
+
@fileset.links = :follow
|
246
|
+
@fileset.files.sort.should == @files.sort
|
247
|
+
end
|
248
|
+
|
249
|
+
it "uses File.lstat if :links is set to :manage" do
|
250
|
+
mock_dir_structure(@path, :lstat)
|
251
|
+
@fileset.recurse = true
|
252
|
+
@fileset.links = :manage
|
253
|
+
@fileset.files.sort.should == @files.sort
|
254
|
+
end
|
299
255
|
|
300
|
-
|
301
|
-
|
256
|
+
it "works when paths have regexp significant characters" do
|
257
|
+
@path = make_absolute("/my/path/rV1x2DafFr0R6tGG+1bbk++++TM")
|
258
|
+
File.expects(:lstat).with(@path).returns stub("stat", :directory? => true)
|
259
|
+
@fileset = Puppet::FileServing::Fileset.new(@path)
|
260
|
+
mock_dir_structure(@path)
|
261
|
+
@fileset.recurse = true
|
262
|
+
@fileset.files.sort.should == @files.sort
|
263
|
+
end
|
302
264
|
end
|
303
|
-
end
|
304
265
|
|
305
|
-
|
306
|
-
|
266
|
+
it "manages the links to missing files" do
|
267
|
+
path = make_absolute("/my/path")
|
268
|
+
stat = stub 'stat', :directory? => true
|
307
269
|
|
308
|
-
|
309
|
-
|
310
|
-
File.expects(:
|
311
|
-
@fileset = Puppet::FileServing::Fileset.new(@path)
|
312
|
-
end
|
270
|
+
File.expects(:lstat).with(path).returns(stat)
|
271
|
+
File.expects(:stat).with(path).returns(stat)
|
272
|
+
File.expects(:stat).with(File.join(path, "mylink")).raises(Errno::ENOENT)
|
313
273
|
|
314
|
-
|
315
|
-
@fileset.ignore = ".svn"
|
316
|
-
File.expects(:fnmatch?).with(".svn", "my_file")
|
317
|
-
@fileset.ignore?("my_file")
|
318
|
-
end
|
274
|
+
Dir.stubs(:entries).with(path).returns(["mylink"])
|
319
275
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
end
|
276
|
+
fileset = Puppet::FileServing::Fileset.new(path)
|
277
|
+
|
278
|
+
fileset.links = :follow
|
279
|
+
fileset.recurse = true
|
325
280
|
|
326
|
-
|
327
|
-
@fileset.ignore = [".svn", "CVS"]
|
328
|
-
File.stubs(:fnmatch?).with(".svn", "my_file").returns false
|
329
|
-
File.stubs(:fnmatch?).with("CVS", "my_file").returns true
|
330
|
-
@fileset.ignore?("my_file").should be_true
|
281
|
+
fileset.files.sort.should == %w{. mylink}.sort
|
331
282
|
end
|
332
|
-
end
|
333
283
|
|
334
|
-
|
335
|
-
|
284
|
+
context "when merging other filesets" do
|
285
|
+
before do
|
286
|
+
@paths = [make_absolute("/first/path"), make_absolute("/second/path"), make_absolute("/third/path")]
|
287
|
+
File.stubs(:lstat).returns stub("stat", :directory? => false)
|
336
288
|
|
337
|
-
|
338
|
-
|
339
|
-
|
289
|
+
@filesets = @paths.collect do |path|
|
290
|
+
File.stubs(:lstat).with(path).returns stub("stat", :directory? => true)
|
291
|
+
Puppet::FileServing::Fileset.new(path, :recurse => true)
|
292
|
+
end
|
340
293
|
|
341
|
-
|
342
|
-
File.stubs(:lstat).with(path).returns stub("stat", :directory? => true)
|
343
|
-
Puppet::FileServing::Fileset.new(path, :recurse => true)
|
294
|
+
Dir.stubs(:entries).returns []
|
344
295
|
end
|
345
296
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
"tres" => make_absolute("/third/path"),
|
362
|
-
}
|
363
|
-
end
|
297
|
+
it "returns a hash of all files in each fileset with the value being the base path" do
|
298
|
+
Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one uno})
|
299
|
+
Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{two dos})
|
300
|
+
Dir.expects(:entries).with(make_absolute("/third/path")).returns(%w{three tres})
|
301
|
+
|
302
|
+
Puppet::FileServing::Fileset.merge(*@filesets).should == {
|
303
|
+
"." => make_absolute("/first/path"),
|
304
|
+
"one" => make_absolute("/first/path"),
|
305
|
+
"uno" => make_absolute("/first/path"),
|
306
|
+
"two" => make_absolute("/second/path"),
|
307
|
+
"dos" => make_absolute("/second/path"),
|
308
|
+
"three" => make_absolute("/third/path"),
|
309
|
+
"tres" => make_absolute("/third/path"),
|
310
|
+
}
|
311
|
+
end
|
364
312
|
|
365
|
-
|
366
|
-
|
367
|
-
|
313
|
+
it "includes the base directory from the first fileset" do
|
314
|
+
Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one})
|
315
|
+
Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{two})
|
368
316
|
|
369
|
-
|
370
|
-
|
317
|
+
Puppet::FileServing::Fileset.merge(*@filesets)["."].should == make_absolute("/first/path")
|
318
|
+
end
|
371
319
|
|
372
|
-
|
373
|
-
|
374
|
-
|
320
|
+
it "uses the base path of the first found file when relative file paths conflict" do
|
321
|
+
Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one})
|
322
|
+
Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{one})
|
375
323
|
|
376
|
-
|
324
|
+
Puppet::FileServing::Fileset.merge(*@filesets)["one"].should == make_absolute("/first/path")
|
325
|
+
end
|
377
326
|
end
|
378
327
|
end
|
328
|
+
|