tesler 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -20
- data/README.md +27 -27
- data/Rakefile +53 -53
- data/VERSION +1 -1
- data/example/main.rb +46 -43
- data/example/src/subdir2/file7 +1 -1
- data/lib/tesler.rb +9 -9
- data/lib/tesler/as.rb +23 -23
- data/lib/tesler/config.rb +42 -42
- data/lib/tesler/copier.rb +81 -81
- data/lib/tesler/dsl.rb +20 -20
- data/lib/tesler/ext.rb +29 -29
- data/lib/tesler/operators/base.rb +19 -19
- data/lib/tesler/operators/logger.rb +39 -39
- data/lib/tesler/operators/run.rb +26 -26
- data/test/helper.rb +22 -22
- data/test/src/subdir2/file7 +1 -1
- data/test/test_tesler.rb +347 -325
- metadata +3 -3
data/test/src/subdir2/file7
CHANGED
@@ -1 +1 @@
|
|
1
|
-
aaaaaaaaaaaaaa
|
1
|
+
aaaaaaaaaaaaaa
|
data/test/test_tesler.rb
CHANGED
@@ -1,325 +1,347 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestTesler < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
# reinitialize tesler
|
6
|
-
reset_config
|
7
|
-
|
8
|
-
# assign a mock of the standar output to tesler
|
9
|
-
@output = Output.new
|
10
|
-
Tesler::Config.output = @output
|
11
|
-
end
|
12
|
-
|
13
|
-
should "copy files" do
|
14
|
-
# We delete the destination if it exists
|
15
|
-
FileUtils.rm_r("test/dest/1") if File.exists?("test/dest/1")
|
16
|
-
|
17
|
-
directory 'test\dest\1' do
|
18
|
-
copy 'test\src\file1'
|
19
|
-
copy 'test\src\file2'
|
20
|
-
copy 'test\src\subdir1\file4'
|
21
|
-
|
22
|
-
directory 'subdir1' do
|
23
|
-
copy 'test\src\file3'
|
24
|
-
copy 'test\src\subdir1\file5'
|
25
|
-
|
26
|
-
directory 'subdir3' do
|
27
|
-
copy 'test\src\file1'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
copy 'test\src\file2', :directory => 'subdir4'
|
32
|
-
end
|
33
|
-
|
34
|
-
assert File.exists?("test/dest/1/file1")
|
35
|
-
assert File.exists?("test/dest/1/file2")
|
36
|
-
assert File.exists?("test/dest/1/file4")
|
37
|
-
assert File.exists?("test/dest/1/subdir1/file3")
|
38
|
-
assert File.exists?("test/dest/1/subdir1/file5")
|
39
|
-
assert File.exists?("test/dest/1/subdir1/subdir3/file1")
|
40
|
-
assert File.exists?("test/dest/1/subdir4/file2")
|
41
|
-
end
|
42
|
-
|
43
|
-
should "copy entire directories" do
|
44
|
-
# We delete the destination if it exists
|
45
|
-
FileUtils.rm_r("test/dest/2") if File.exists?("test/dest/2")
|
46
|
-
|
47
|
-
directory 'test\dest\2' do
|
48
|
-
copy 'test\src\subdir2'
|
49
|
-
end
|
50
|
-
|
51
|
-
assert File.exists?("test/dest/2/subdir2")
|
52
|
-
end
|
53
|
-
|
54
|
-
should "support the renaming of the files and directories which are copied" do
|
55
|
-
# We delete the destination if it exists
|
56
|
-
FileUtils.rm_r("test/dest/3") if File.exists?("test/dest/3")
|
57
|
-
|
58
|
-
directory 'test\dest\3' do
|
59
|
-
directory 'subdir1' do
|
60
|
-
directory 'subdir3' do
|
61
|
-
copy 'test\src\file1', :rename => 'file1_renamed'
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
copy 'test\src\subdir2', :rename => 'subdir2_renamed'
|
66
|
-
end
|
67
|
-
|
68
|
-
assert File.exists?("test/dest/3/subdir1/subdir3/file1_renamed")
|
69
|
-
assert File.exists?("test/dest/3/subdir2_renamed")
|
70
|
-
end
|
71
|
-
|
72
|
-
should "support regular expressions on the filenames" do
|
73
|
-
# We delete the destination if it exists
|
74
|
-
FileUtils.rm_r("test/dest/4") if File.exists?("test/dest/4")
|
75
|
-
|
76
|
-
directory 'test\dest\4' do
|
77
|
-
directory 'subdir1' do
|
78
|
-
directory 'subdir3' do
|
79
|
-
copy 'test\src\*.test'
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
copy 'test\src\reg_*.test'
|
84
|
-
copy 'test\src\reg_*.test', :directory => 'subdir2'
|
85
|
-
end
|
86
|
-
|
87
|
-
assert File.exists?("test/dest/4/subdir1/subdir3/noreg_1.test")
|
88
|
-
assert File.exists?("test/dest/4/subdir1/subdir3/noreg_2.test")
|
89
|
-
assert File.exists?("test/dest/4/subdir1/subdir3/reg_1.test")
|
90
|
-
assert File.exists?("test/dest/4/subdir1/subdir3/reg_2.test")
|
91
|
-
assert File.exists?("test/dest/4/subdir1/subdir3/reg_3.test")
|
92
|
-
assert File.exists?("test/dest/4/reg_1.test")
|
93
|
-
assert File.exists?("test/dest/4/reg_2.test")
|
94
|
-
assert File.exists?("test/dest/4/reg_3.test")
|
95
|
-
assert File.exists?("test/dest/4/subdir2/reg_1.test")
|
96
|
-
assert File.exists?("test/dest/4/subdir2/reg_2.test")
|
97
|
-
assert File.exists?("test/dest/4/subdir2/reg_3.test")
|
98
|
-
end
|
99
|
-
|
100
|
-
should "log its actions" do
|
101
|
-
# We delete the destination if it exists
|
102
|
-
FileUtils.rm_r("test/dest/5") if File.exists?("test/dest/5")
|
103
|
-
|
104
|
-
directory 'test\dest\5' do
|
105
|
-
copy 'test\src\file1'
|
106
|
-
copy 'test\src\file2'
|
107
|
-
copy 'test\src\subdir1\file4'
|
108
|
-
|
109
|
-
directory 'subdir1' do
|
110
|
-
copy 'test\src\file3'
|
111
|
-
copy 'test\src\subdir1\file5'
|
112
|
-
|
113
|
-
directory 'subdir3' do
|
114
|
-
copy 'test\src\file1'
|
115
|
-
copy 'test\src\file2', :rename => 'file2_renamed'
|
116
|
-
copy 'test\src\*.test'
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
copy 'test\src\subdir2'
|
121
|
-
copy 'test\src\subdir2', :rename => 'subdir2_renamed'
|
122
|
-
copy 'test\src\reg_*.test'
|
123
|
-
copy 'test\src\file2', :directory => 'subdir4'
|
124
|
-
end
|
125
|
-
|
126
|
-
messages = @output.messages.map { |m| m.strip }
|
127
|
-
assert_match /(create|exists)\ttest\/dest\/5/, messages[0]
|
128
|
-
assert_equal "copy\ttest/src/file1\ttest/dest/5/file1", messages[1]
|
129
|
-
assert_equal "copy\ttest/src/file2\ttest/dest/5/file2", messages[2]
|
130
|
-
assert_equal "copy\ttest/src/subdir1/file4\ttest/dest/5/file4", messages[3]
|
131
|
-
assert_match /(create|exists)\ttest\/dest\/5\/subdir1/, messages[4]
|
132
|
-
assert_equal "copy\ttest/src/file3\ttest/dest/5/subdir1/file3", messages[5]
|
133
|
-
assert_equal "copy\ttest/src/subdir1/file5\ttest/dest/5/subdir1/file5", messages[6]
|
134
|
-
assert_match /(create|exists)\ttest\/dest\/5\/subdir1\/subdir3/, messages[7]
|
135
|
-
assert_equal "copy\ttest/src/file1\ttest/dest/5/subdir1/subdir3/file1", messages[8]
|
136
|
-
assert_equal "copy\ttest/src/file2\ttest/dest/5/subdir1/subdir3/file2_renamed", messages[9]
|
137
|
-
assert_equal "copy\ttest/src/noreg_1.test\ttest/dest/5/subdir1/subdir3/noreg_1.test", messages[10]
|
138
|
-
assert_equal "copy\ttest/src/noreg_2.test\ttest/dest/5/subdir1/subdir3/noreg_2.test", messages[11]
|
139
|
-
assert_equal "copy\ttest/src/reg_1.test\ttest/dest/5/subdir1/subdir3/reg_1.test", messages[12]
|
140
|
-
assert_equal "copy\ttest/src/reg_2.test\ttest/dest/5/subdir1/subdir3/reg_2.test", messages[13]
|
141
|
-
assert_equal "copy\ttest/src/reg_3.test\ttest/dest/5/subdir1/subdir3/reg_3.test", messages[14]
|
142
|
-
assert_equal "copy\ttest/src/subdir2\ttest/dest/5/subdir2", messages[15]
|
143
|
-
assert_equal "copy\ttest/src/subdir2\ttest/dest/5/subdir2_renamed", messages[16]
|
144
|
-
assert_equal "copy\ttest/src/reg_1.test\ttest/dest/5/reg_1.test", messages[17]
|
145
|
-
assert_equal "copy\ttest/src/reg_2.test\ttest/dest/5/reg_2.test", messages[18]
|
146
|
-
assert_equal "copy\ttest/src/reg_3.test\ttest/dest/5/reg_3.test", messages[19]
|
147
|
-
assert_equal "copy\ttest/src/file2\ttest/dest/5/subdir4/file2", messages[20]
|
148
|
-
end
|
149
|
-
|
150
|
-
should "
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
assert File.exists?("test/dest/6
|
179
|
-
assert File.exists?("test/dest/6/
|
180
|
-
assert File.exists?("test/dest/6/
|
181
|
-
assert File.exists?("test/dest/6/
|
182
|
-
assert File.exists?("test/dest/6/
|
183
|
-
assert File.exists?("test/dest/6/
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
assert_equal
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
assert File.exists?("test/dest/
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTesler < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
# reinitialize tesler
|
6
|
+
reset_config
|
7
|
+
|
8
|
+
# assign a mock of the standar output to tesler
|
9
|
+
@output = Output.new
|
10
|
+
Tesler::Config.output = @output
|
11
|
+
end
|
12
|
+
|
13
|
+
should "copy files" do
|
14
|
+
# We delete the destination if it exists
|
15
|
+
FileUtils.rm_r("test/dest/1") if File.exists?("test/dest/1")
|
16
|
+
|
17
|
+
directory 'test\dest\1' do
|
18
|
+
copy 'test\src\file1'
|
19
|
+
copy 'test\src\file2'
|
20
|
+
copy 'test\src\subdir1\file4'
|
21
|
+
|
22
|
+
directory 'subdir1' do
|
23
|
+
copy 'test\src\file3'
|
24
|
+
copy 'test\src\subdir1\file5'
|
25
|
+
|
26
|
+
directory 'subdir3' do
|
27
|
+
copy 'test\src\file1'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
copy 'test\src\file2', :directory => 'subdir4'
|
32
|
+
end
|
33
|
+
|
34
|
+
assert File.exists?("test/dest/1/file1")
|
35
|
+
assert File.exists?("test/dest/1/file2")
|
36
|
+
assert File.exists?("test/dest/1/file4")
|
37
|
+
assert File.exists?("test/dest/1/subdir1/file3")
|
38
|
+
assert File.exists?("test/dest/1/subdir1/file5")
|
39
|
+
assert File.exists?("test/dest/1/subdir1/subdir3/file1")
|
40
|
+
assert File.exists?("test/dest/1/subdir4/file2")
|
41
|
+
end
|
42
|
+
|
43
|
+
should "copy entire directories" do
|
44
|
+
# We delete the destination if it exists
|
45
|
+
FileUtils.rm_r("test/dest/2") if File.exists?("test/dest/2")
|
46
|
+
|
47
|
+
directory 'test\dest\2' do
|
48
|
+
copy 'test\src\subdir2'
|
49
|
+
end
|
50
|
+
|
51
|
+
assert File.exists?("test/dest/2/subdir2")
|
52
|
+
end
|
53
|
+
|
54
|
+
should "support the renaming of the files and directories which are copied" do
|
55
|
+
# We delete the destination if it exists
|
56
|
+
FileUtils.rm_r("test/dest/3") if File.exists?("test/dest/3")
|
57
|
+
|
58
|
+
directory 'test\dest\3' do
|
59
|
+
directory 'subdir1' do
|
60
|
+
directory 'subdir3' do
|
61
|
+
copy 'test\src\file1', :rename => 'file1_renamed'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
copy 'test\src\subdir2', :rename => 'subdir2_renamed'
|
66
|
+
end
|
67
|
+
|
68
|
+
assert File.exists?("test/dest/3/subdir1/subdir3/file1_renamed")
|
69
|
+
assert File.exists?("test/dest/3/subdir2_renamed")
|
70
|
+
end
|
71
|
+
|
72
|
+
should "support regular expressions on the filenames" do
|
73
|
+
# We delete the destination if it exists
|
74
|
+
FileUtils.rm_r("test/dest/4") if File.exists?("test/dest/4")
|
75
|
+
|
76
|
+
directory 'test\dest\4' do
|
77
|
+
directory 'subdir1' do
|
78
|
+
directory 'subdir3' do
|
79
|
+
copy 'test\src\*.test'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
copy 'test\src\reg_*.test'
|
84
|
+
copy 'test\src\reg_*.test', :directory => 'subdir2'
|
85
|
+
end
|
86
|
+
|
87
|
+
assert File.exists?("test/dest/4/subdir1/subdir3/noreg_1.test")
|
88
|
+
assert File.exists?("test/dest/4/subdir1/subdir3/noreg_2.test")
|
89
|
+
assert File.exists?("test/dest/4/subdir1/subdir3/reg_1.test")
|
90
|
+
assert File.exists?("test/dest/4/subdir1/subdir3/reg_2.test")
|
91
|
+
assert File.exists?("test/dest/4/subdir1/subdir3/reg_3.test")
|
92
|
+
assert File.exists?("test/dest/4/reg_1.test")
|
93
|
+
assert File.exists?("test/dest/4/reg_2.test")
|
94
|
+
assert File.exists?("test/dest/4/reg_3.test")
|
95
|
+
assert File.exists?("test/dest/4/subdir2/reg_1.test")
|
96
|
+
assert File.exists?("test/dest/4/subdir2/reg_2.test")
|
97
|
+
assert File.exists?("test/dest/4/subdir2/reg_3.test")
|
98
|
+
end
|
99
|
+
|
100
|
+
should "log its actions" do
|
101
|
+
# We delete the destination if it exists
|
102
|
+
FileUtils.rm_r("test/dest/5") if File.exists?("test/dest/5")
|
103
|
+
|
104
|
+
directory 'test\dest\5' do
|
105
|
+
copy 'test\src\file1'
|
106
|
+
copy 'test\src\file2'
|
107
|
+
copy 'test\src\subdir1\file4'
|
108
|
+
|
109
|
+
directory 'subdir1' do
|
110
|
+
copy 'test\src\file3'
|
111
|
+
copy 'test\src\subdir1\file5'
|
112
|
+
|
113
|
+
directory 'subdir3' do
|
114
|
+
copy 'test\src\file1'
|
115
|
+
copy 'test\src\file2', :rename => 'file2_renamed'
|
116
|
+
copy 'test\src\*.test'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
copy 'test\src\subdir2'
|
121
|
+
copy 'test\src\subdir2', :rename => 'subdir2_renamed'
|
122
|
+
copy 'test\src\reg_*.test'
|
123
|
+
copy 'test\src\file2', :directory => 'subdir4'
|
124
|
+
end
|
125
|
+
|
126
|
+
messages = @output.messages.map { |m| m.strip }
|
127
|
+
assert_match /(create|exists)\ttest\/dest\/5/, messages[0]
|
128
|
+
assert_equal "copy\ttest/src/file1\ttest/dest/5/file1", messages[1]
|
129
|
+
assert_equal "copy\ttest/src/file2\ttest/dest/5/file2", messages[2]
|
130
|
+
assert_equal "copy\ttest/src/subdir1/file4\ttest/dest/5/file4", messages[3]
|
131
|
+
assert_match /(create|exists)\ttest\/dest\/5\/subdir1/, messages[4]
|
132
|
+
assert_equal "copy\ttest/src/file3\ttest/dest/5/subdir1/file3", messages[5]
|
133
|
+
assert_equal "copy\ttest/src/subdir1/file5\ttest/dest/5/subdir1/file5", messages[6]
|
134
|
+
assert_match /(create|exists)\ttest\/dest\/5\/subdir1\/subdir3/, messages[7]
|
135
|
+
assert_equal "copy\ttest/src/file1\ttest/dest/5/subdir1/subdir3/file1", messages[8]
|
136
|
+
assert_equal "copy\ttest/src/file2\ttest/dest/5/subdir1/subdir3/file2_renamed", messages[9]
|
137
|
+
assert_equal "copy\ttest/src/noreg_1.test\ttest/dest/5/subdir1/subdir3/noreg_1.test", messages[10]
|
138
|
+
assert_equal "copy\ttest/src/noreg_2.test\ttest/dest/5/subdir1/subdir3/noreg_2.test", messages[11]
|
139
|
+
assert_equal "copy\ttest/src/reg_1.test\ttest/dest/5/subdir1/subdir3/reg_1.test", messages[12]
|
140
|
+
assert_equal "copy\ttest/src/reg_2.test\ttest/dest/5/subdir1/subdir3/reg_2.test", messages[13]
|
141
|
+
assert_equal "copy\ttest/src/reg_3.test\ttest/dest/5/subdir1/subdir3/reg_3.test", messages[14]
|
142
|
+
assert_equal "copy\ttest/src/subdir2\ttest/dest/5/subdir2", messages[15]
|
143
|
+
assert_equal "copy\ttest/src/subdir2\ttest/dest/5/subdir2_renamed", messages[16]
|
144
|
+
assert_equal "copy\ttest/src/reg_1.test\ttest/dest/5/reg_1.test", messages[17]
|
145
|
+
assert_equal "copy\ttest/src/reg_2.test\ttest/dest/5/reg_2.test", messages[18]
|
146
|
+
assert_equal "copy\ttest/src/reg_3.test\ttest/dest/5/reg_3.test", messages[19]
|
147
|
+
assert_equal "copy\ttest/src/file2\ttest/dest/5/subdir4/file2", messages[20]
|
148
|
+
end
|
149
|
+
|
150
|
+
should "allow to set a default src directory" do
|
151
|
+
# We delete the destination if it exists
|
152
|
+
FileUtils.rm_r("test/dest/6") if File.exists?("test/dest/6")
|
153
|
+
|
154
|
+
# when a source directory is set then all the files are copied from it
|
155
|
+
source_directory 'test\src'
|
156
|
+
|
157
|
+
directory 'test\dest\6' do
|
158
|
+
copy 'file1'
|
159
|
+
copy 'file2'
|
160
|
+
copy 'subdir1\file4'
|
161
|
+
|
162
|
+
directory 'subdir1' do
|
163
|
+
copy 'file3'
|
164
|
+
copy 'subdir1\file5'
|
165
|
+
|
166
|
+
directory 'subdir3' do
|
167
|
+
copy 'file1'
|
168
|
+
copy 'file2', :rename => 'file2_renamed'
|
169
|
+
copy '*.test'
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
copy 'subdir2'
|
174
|
+
copy 'subdir2', :rename => 'subdir2_renamed'
|
175
|
+
copy 'reg_*.test'
|
176
|
+
end
|
177
|
+
|
178
|
+
assert File.exists?("test/dest/6")
|
179
|
+
assert File.exists?("test/dest/6/file1")
|
180
|
+
assert File.exists?("test/dest/6/file2")
|
181
|
+
assert File.exists?("test/dest/6/file4")
|
182
|
+
assert File.exists?("test/dest/6/subdir1")
|
183
|
+
assert File.exists?("test/dest/6/subdir1/file3")
|
184
|
+
assert File.exists?("test/dest/6/subdir1/file5")
|
185
|
+
assert File.exists?("test/dest/6/subdir1/subdir3")
|
186
|
+
assert File.exists?("test/dest/6/subdir1/subdir3/file1")
|
187
|
+
assert File.exists?("test/dest/6/subdir1/subdir3/file2_renamed")
|
188
|
+
assert File.exists?("test/dest/6/subdir2")
|
189
|
+
assert File.exists?("test/dest/6/subdir2_renamed")
|
190
|
+
assert File.exists?("test/dest/6/subdir1/subdir3/noreg_1.test")
|
191
|
+
assert File.exists?("test/dest/6/subdir1/subdir3/noreg_2.test")
|
192
|
+
assert File.exists?("test/dest/6/subdir1/subdir3/reg_1.test")
|
193
|
+
assert File.exists?("test/dest/6/subdir1/subdir3/reg_2.test")
|
194
|
+
assert File.exists?("test/dest/6/subdir1/subdir3/reg_3.test")
|
195
|
+
assert File.exists?("test/dest/6/reg_1.test")
|
196
|
+
assert File.exists?("test/dest/6/reg_2.test")
|
197
|
+
assert File.exists?("test/dest/6/reg_3.test")
|
198
|
+
|
199
|
+
messages = @output.messages.map { |m| m.strip }
|
200
|
+
assert_match /(create|exists)\ttest\/dest\/6/, messages[0]
|
201
|
+
assert_equal "copy\ttest/src/file1\ttest/dest/6/file1", messages[1]
|
202
|
+
assert_equal "copy\ttest/src/file2\ttest/dest/6/file2", messages[2]
|
203
|
+
assert_equal "copy\ttest/src/subdir1/file4\ttest/dest/6/file4", messages[3]
|
204
|
+
assert_match /(create|exists)\ttest\/dest\/6\/subdir1/, messages[4]
|
205
|
+
assert_equal "copy\ttest/src/file3\ttest/dest/6/subdir1/file3", messages[5]
|
206
|
+
assert_equal "copy\ttest/src/subdir1/file5\ttest/dest/6/subdir1/file5", messages[6]
|
207
|
+
assert_match /(create|exists)\ttest\/dest\/6\/subdir1\/subdir3/, messages[7]
|
208
|
+
assert_equal "copy\ttest/src/file1\ttest/dest/6/subdir1/subdir3/file1", messages[8]
|
209
|
+
assert_equal "copy\ttest/src/file2\ttest/dest/6/subdir1/subdir3/file2_renamed", messages[9]
|
210
|
+
assert_equal "copy\ttest/src/noreg_1.test\ttest/dest/6/subdir1/subdir3/noreg_1.test", messages[10]
|
211
|
+
assert_equal "copy\ttest/src/noreg_2.test\ttest/dest/6/subdir1/subdir3/noreg_2.test", messages[11]
|
212
|
+
assert_equal "copy\ttest/src/reg_1.test\ttest/dest/6/subdir1/subdir3/reg_1.test", messages[12]
|
213
|
+
assert_equal "copy\ttest/src/reg_2.test\ttest/dest/6/subdir1/subdir3/reg_2.test", messages[13]
|
214
|
+
assert_equal "copy\ttest/src/reg_3.test\ttest/dest/6/subdir1/subdir3/reg_3.test", messages[14]
|
215
|
+
assert_equal "copy\ttest/src/subdir2\ttest/dest/6/subdir2", messages[15]
|
216
|
+
assert_equal "copy\ttest/src/subdir2\ttest/dest/6/subdir2_renamed", messages[16]
|
217
|
+
assert_equal "copy\ttest/src/reg_1.test\ttest/dest/6/reg_1.test", messages[17]
|
218
|
+
assert_equal "copy\ttest/src/reg_2.test\ttest/dest/6/reg_2.test", messages[18]
|
219
|
+
assert_equal "copy\ttest/src/reg_3.test\ttest/dest/6/reg_3.test", messages[19]
|
220
|
+
end
|
221
|
+
|
222
|
+
should "be able to run in test mode" do
|
223
|
+
# We delete the destination if it exists
|
224
|
+
FileUtils.rm_r("test/dest/7") if File.exists?("test/dest/7")
|
225
|
+
|
226
|
+
# when running in test mode, the files are not copied but the logger displays the results
|
227
|
+
run_in_test_mode
|
228
|
+
source_directory 'test\src'
|
229
|
+
|
230
|
+
directory 'test\dest\7' do
|
231
|
+
copy 'file1'
|
232
|
+
copy 'file2'
|
233
|
+
copy 'subdir1\file4'
|
234
|
+
|
235
|
+
directory 'subdir1' do
|
236
|
+
copy 'file3'
|
237
|
+
copy 'subdir1\file5'
|
238
|
+
|
239
|
+
directory 'subdir3' do
|
240
|
+
copy 'file1'
|
241
|
+
copy 'file2', :rename => 'file2_renamed'
|
242
|
+
copy '*.test'
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
copy 'subdir2'
|
247
|
+
copy 'subdir2', :rename => 'subdir2_renamed'
|
248
|
+
copy 'reg_*.test'
|
249
|
+
end
|
250
|
+
|
251
|
+
assert !File.exists?("test/dest/7")
|
252
|
+
assert !File.exists?("test/dest/7/file1")
|
253
|
+
assert !File.exists?("test/dest/7/file2")
|
254
|
+
assert !File.exists?("test/dest/7/file4")
|
255
|
+
assert !File.exists?("test/dest/7/subdir1")
|
256
|
+
assert !File.exists?("test/dest/7/subdir1/file3")
|
257
|
+
assert !File.exists?("test/dest/7/subdir1/file5")
|
258
|
+
assert !File.exists?("test/dest/7/subdir1/subdir3")
|
259
|
+
assert !File.exists?("test/dest/7/subdir1/subdir3/file1")
|
260
|
+
assert !File.exists?("test/dest/7/subdir1/subdir3/file2_renamed")
|
261
|
+
assert !File.exists?("test/dest/7/subdir2")
|
262
|
+
assert !File.exists?("test/dest/7/subdir2_renamed")
|
263
|
+
assert !File.exists?("test/dest/7/subdir1/subdir3/noreg_1.test")
|
264
|
+
assert !File.exists?("test/dest/7/subdir1/subdir3/noreg_2.test")
|
265
|
+
assert !File.exists?("test/dest/7/subdir1/subdir3/reg_1.test")
|
266
|
+
assert !File.exists?("test/dest/7/subdir1/subdir3/reg_2.test")
|
267
|
+
assert !File.exists?("test/dest/7/subdir1/subdir3/reg_3.test")
|
268
|
+
assert !File.exists?("test/dest/7/reg_1.test")
|
269
|
+
assert !File.exists?("test/dest/7/reg_2.test")
|
270
|
+
assert !File.exists?("test/dest/7/reg_3.test")
|
271
|
+
|
272
|
+
messages = @output.messages.map { |m| m.strip }
|
273
|
+
assert_match /(create|exists)\ttest\/dest\/7/, messages[0]
|
274
|
+
assert_equal "copy\ttest/src/file1\ttest/dest/7/file1", messages[1]
|
275
|
+
assert_equal "copy\ttest/src/file2\ttest/dest/7/file2", messages[2]
|
276
|
+
assert_equal "copy\ttest/src/subdir1/file4\ttest/dest/7/file4", messages[3]
|
277
|
+
assert_match /(create|exists)\ttest\/dest\/7\/subdir1/, messages[4]
|
278
|
+
assert_equal "copy\ttest/src/file3\ttest/dest/7/subdir1/file3", messages[5]
|
279
|
+
assert_equal "copy\ttest/src/subdir1/file5\ttest/dest/7/subdir1/file5", messages[6]
|
280
|
+
assert_match /(create|exists)\ttest\/dest\/7\/subdir1\/subdir3/, messages[7]
|
281
|
+
assert_equal "copy\ttest/src/file1\ttest/dest/7/subdir1/subdir3/file1", messages[8]
|
282
|
+
assert_equal "copy\ttest/src/file2\ttest/dest/7/subdir1/subdir3/file2_renamed", messages[9]
|
283
|
+
assert_equal "copy\ttest/src/noreg_1.test\ttest/dest/7/subdir1/subdir3/noreg_1.test", messages[10]
|
284
|
+
assert_equal "copy\ttest/src/noreg_2.test\ttest/dest/7/subdir1/subdir3/noreg_2.test", messages[11]
|
285
|
+
assert_equal "copy\ttest/src/reg_1.test\ttest/dest/7/subdir1/subdir3/reg_1.test", messages[12]
|
286
|
+
assert_equal "copy\ttest/src/reg_2.test\ttest/dest/7/subdir1/subdir3/reg_2.test", messages[13]
|
287
|
+
assert_equal "copy\ttest/src/reg_3.test\ttest/dest/7/subdir1/subdir3/reg_3.test", messages[14]
|
288
|
+
assert_equal "copy\ttest/src/subdir2\ttest/dest/7/subdir2", messages[15]
|
289
|
+
assert_equal "copy\ttest/src/subdir2\ttest/dest/7/subdir2_renamed", messages[16]
|
290
|
+
assert_equal "copy\ttest/src/reg_1.test\ttest/dest/7/reg_1.test", messages[17]
|
291
|
+
assert_equal "copy\ttest/src/reg_2.test\ttest/dest/7/reg_2.test", messages[18]
|
292
|
+
assert_equal "copy\ttest/src/reg_3.test\ttest/dest/7/reg_3.test", messages[19]
|
293
|
+
end
|
294
|
+
|
295
|
+
should "log when it can't find a source file" do
|
296
|
+
# We delete the destination if it exists
|
297
|
+
FileUtils.rm_r("test/dest/8") if File.exists?("test/dest/8")
|
298
|
+
|
299
|
+
source_directory 'test\src'
|
300
|
+
|
301
|
+
directory 'test\dest\8' do
|
302
|
+
copy 'unknown_file'
|
303
|
+
end
|
304
|
+
|
305
|
+
assert File.exists?("test/dest/8")
|
306
|
+
messages = @output.messages.map { |m| m.strip }
|
307
|
+
assert_match /(create|exists)\ttest\/dest\/8/, messages[0]
|
308
|
+
assert_equal "not found\ttest/src/unknown_file", messages[1]
|
309
|
+
end
|
310
|
+
|
311
|
+
should "detect and replace environment variables" do
|
312
|
+
# We delete the destination if it exists
|
313
|
+
FileUtils.rm_r("test/dest/9") if File.exists?("test/dest/9")
|
314
|
+
|
315
|
+
# create a new environment variable
|
316
|
+
ENV['TESLER_TEST'] = File.dirname(__FILE__)
|
317
|
+
|
318
|
+
directory '%TESLER_TEST%\dest\9' do
|
319
|
+
copy '%TESLER_TEST%\src\file1'
|
320
|
+
copy '%TESLER_TEST%\src\*.test'
|
321
|
+
end
|
322
|
+
|
323
|
+
assert File.exists?("test/dest/9")
|
324
|
+
assert File.exists?("test/dest/9/file1")
|
325
|
+
assert File.exists?("test/dest/9/noreg_1.test")
|
326
|
+
assert File.exists?("test/dest/9/noreg_2.test")
|
327
|
+
assert File.exists?("test/dest/9/reg_1.test")
|
328
|
+
assert File.exists?("test/dest/9/reg_2.test")
|
329
|
+
assert File.exists?("test/dest/9/reg_3.test")
|
330
|
+
end
|
331
|
+
|
332
|
+
should "log when it can't find a source file's directory (regular expressions case only)" do
|
333
|
+
# We delete the destination if it exists
|
334
|
+
FileUtils.rm_r("test/dest/10") if File.exists?("test/dest/10")
|
335
|
+
|
336
|
+
source_directory 'unknown\src'
|
337
|
+
|
338
|
+
directory 'test\dest\10' do
|
339
|
+
copy '*.file'
|
340
|
+
end
|
341
|
+
|
342
|
+
assert File.exists?("test/dest/10")
|
343
|
+
messages = @output.messages.map { |m| m.strip }
|
344
|
+
assert_match /(create|exists)\ttest\/dest\/10/, messages[0]
|
345
|
+
assert_equal "not found\tunknown/src", messages[1]
|
346
|
+
end
|
347
|
+
end
|