rbatch 1.4.0 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/LICENSE +0 -0
  2. data/README.ja.md +1 -13
  3. data/README.md +2 -13
  4. data/Rakefile +1 -24
  5. metadata +12 -123
  6. data/CHANGELOG +0 -25
  7. data/VERSION +0 -1
  8. data/doc/rdoc/CHANGELOG.html +0 -160
  9. data/doc/rdoc/LICENSE.html +0 -94
  10. data/doc/rdoc/RBatch/Cmd.html +0 -329
  11. data/doc/rdoc/RBatch/CmdException.html +0 -154
  12. data/doc/rdoc/RBatch/CmdResult.html +0 -492
  13. data/doc/rdoc/RBatch/Log.html +0 -739
  14. data/doc/rdoc/RBatch.html +0 -476
  15. data/doc/rdoc/created.rid +0 -8
  16. data/doc/rdoc/images/brick.png +0 -0
  17. data/doc/rdoc/images/brick_link.png +0 -0
  18. data/doc/rdoc/images/bug.png +0 -0
  19. data/doc/rdoc/images/bullet_black.png +0 -0
  20. data/doc/rdoc/images/bullet_toggle_minus.png +0 -0
  21. data/doc/rdoc/images/bullet_toggle_plus.png +0 -0
  22. data/doc/rdoc/images/date.png +0 -0
  23. data/doc/rdoc/images/find.png +0 -0
  24. data/doc/rdoc/images/loadingAnimation.gif +0 -0
  25. data/doc/rdoc/images/macFFBgHack.png +0 -0
  26. data/doc/rdoc/images/package.png +0 -0
  27. data/doc/rdoc/images/page_green.png +0 -0
  28. data/doc/rdoc/images/page_white_text.png +0 -0
  29. data/doc/rdoc/images/page_white_width.png +0 -0
  30. data/doc/rdoc/images/plugin.png +0 -0
  31. data/doc/rdoc/images/ruby.png +0 -0
  32. data/doc/rdoc/images/tag_green.png +0 -0
  33. data/doc/rdoc/images/wrench.png +0 -0
  34. data/doc/rdoc/images/wrench_orange.png +0 -0
  35. data/doc/rdoc/images/zoom.png +0 -0
  36. data/doc/rdoc/index.html +0 -124
  37. data/doc/rdoc/js/darkfish.js +0 -116
  38. data/doc/rdoc/js/jquery.js +0 -32
  39. data/doc/rdoc/js/quicksearch.js +0 -114
  40. data/doc/rdoc/js/thickbox-compressed.js +0 -10
  41. data/doc/rdoc/lib/rbatch/cmd_rb.html +0 -56
  42. data/doc/rdoc/lib/rbatch/config_rb.html +0 -56
  43. data/doc/rdoc/lib/rbatch/log_rb.html +0 -58
  44. data/doc/rdoc/lib/rbatch_rb.html +0 -58
  45. data/doc/rdoc/rdoc.css +0 -706
  46. data/sample/bin/file_batch_copy.rb +0 -9
  47. data/sample/bin/openldap_backup.rb +0 -7
  48. data/sample/bin/test.rb +0 -12
  49. data/sample/config/file_batch_copy.yaml +0 -5
  50. data/sample/config/openldap_backup.yaml +0 -2
  51. data/sample/config/rbatch.yaml +0 -68
  52. data/sample/log/empty +0 -0
  53. data/test/cases/test_cmd.rb +0 -120
  54. data/test/cases/test_config.rb +0 -34
  55. data/test/cases/test_log.rb +0 -594
  56. data/test/config/rbatch.yaml +0 -0
  57. data/test/mocks/PrintArgs.exe +0 -0
  58. data/test/mocks/win_cmd.exe +0 -0
@@ -1,594 +0,0 @@
1
- require 'test/unit'
2
- require 'fileutils'
3
- require 'rbatch'
4
- class LoggerTest < Test::Unit::TestCase
5
- def setup
6
- @dir = File.join(File.dirname(RBatch.program_name), "..", "log")
7
- @dir2 = File.join(File.dirname(RBatch.program_name), "..", "log2")
8
- @dir3 = File.join(File.dirname(RBatch.program_name), "..", "log3")
9
- @config_dir = File.join(File.dirname(RBatch.program_name), "..", "config")
10
- Dir::mkdir(@dir)if ! Dir.exists? @dir
11
- Dir::mkdir(@dir2)if ! Dir.exists? @dir2
12
- Dir::mkdir(@config_dir) if ! Dir.exists? @config_dir
13
- # RBatch::Log.verbose = true
14
- # set STDOUT Logger stop
15
- confstr = "log_quiet: true\n"
16
- open( RBatch.common_config_path , "w" ){|f| f.write(confstr)}
17
-
18
- end
19
-
20
- def teardown
21
- File::delete(RBatch.common_config_path) if File.exists?(RBatch.common_config_path)
22
- if Dir.exists? @dir
23
- Dir::foreach(@dir) do |f|
24
- File::delete(File.join(@dir , f)) if ! (/\.+$/ =~ f)
25
- end
26
- Dir::rmdir(@dir)
27
- end
28
- if Dir.exists? @dir2
29
- Dir::foreach(@dir2) do |f|
30
- File::delete(File.join(@dir2 , f)) if ! (/\.+$/ =~ f)
31
- end
32
- Dir::rmdir(@dir2)
33
- end
34
- end
35
-
36
- def test_log
37
- RBatch::Log.new do | log |
38
- log.info("test_log")
39
- end
40
- Dir::foreach(@dir) do |f|
41
- if ! (/\.+$/ =~ f)
42
- File::open(File.join(@dir , f)) {|f|
43
- assert_match /test_log/, f.read
44
- }
45
- end
46
- end
47
- end
48
-
49
- def test_log_dir_doesnot_exist
50
- Dir::rmdir(@dir)
51
- assert_raise(Errno::ENOENT){
52
- RBatch::Log.new {|log|}
53
- }
54
- Dir::mkdir(@dir)
55
- end
56
-
57
- def test_change_name_by_opt
58
- RBatch::Log.new({:name => "name1.log" }) do | log |
59
- log.info("test_change_name_by_opt")
60
- end
61
- File::open(File.join(@dir , "name1.log")) {|f|
62
- assert_match /test_change_name_by_opt/, f.read
63
- }
64
- end
65
-
66
- def test_change_name_by_opt2
67
- RBatch::Log.new({:name => "<prog><date>name.log" }) do | log |
68
- log.info("test_change_name_by_opt2")
69
- end
70
- File::open(File.join(@dir , "test_log" + Time.now.strftime("%Y%m%d") + "name.log")) {|f|
71
- assert_match /test_change_name_by_opt2/, f.read
72
- }
73
- end
74
-
75
- def test_change_name_by_opt3
76
- RBatch::Log.new({:name => "<prog>-<date>-name.log" }) do | log |
77
- log.info("test_change_name_by_opt2")
78
- end
79
- File::open(File.join(@dir , "test_log-" + Time.now.strftime("%Y%m%d") + "-name.log")) {|f|
80
- assert_match /test_change_name_by_opt2/, f.read
81
- }
82
- end
83
-
84
-
85
- def test_change_name_by_config
86
- confstr = "log_name: name1"
87
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
88
- RBatch::Log.new({:name => "name1.log" }) do | log |
89
- log.info("test_change_name_by_config")
90
- end
91
- File::open(File.join(@dir , "name1.log")) {|f|
92
- assert_match /test_change_name_by_config/, f.read
93
- }
94
- end
95
-
96
-
97
- def test_change_log_dir_by_opt
98
- RBatch::Log.new({:output_dir=> @dir2 }) do | log |
99
- log.info("test_change_log_dir_by_opt")
100
- end
101
- Dir::foreach(@dir2) do |f|
102
- if ! (/\.+$/ =~ f)
103
- File::open(File.join(@dir2 , f)) {|f|
104
- assert_match /test_change_log_dir_by_opt/, f.read
105
- }
106
- end
107
- end
108
- end
109
-
110
- def test_change_log_dir_by_config
111
- confstr = "log_dir: " + @dir2
112
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
113
- RBatch::Log.new({:output_dir=> @dir2 }) do | log |
114
- log.info("test_change_log_dir_by_config")
115
- end
116
- Dir::foreach(@dir2) do |f|
117
- if ! (/\.+$/ =~ f)
118
- File::open(File.join(@dir2 , f)) {|f|
119
- assert_match /test_change_log_dir_by_config/, f.read
120
- }
121
- end
122
- end
123
- end
124
-
125
- def test_change_formatte
126
- RBatch::Log.new({:name => "file" , :formatter => proc { |severity, datetime, progname, msg| "test_change_formatte#{msg}\n" }}) do | log |
127
- log.info("bar")
128
- end
129
- File::open(File.join(@dir,"file")) {|f| assert_match /test_change_formatte/, f.read }
130
- end
131
-
132
- def test_nest_block
133
- RBatch::Log.new({:name => "name1" }) do | log |
134
- log.info("name1")
135
- RBatch::Log.new({:name => "name2" }) do | log |
136
- log.info("name2")
137
- end
138
- end
139
- File::open(File.join(@dir,"name1")) {|f| assert_match /name1/, f.read }
140
- File::open(File.join(@dir,"name2")) {|f| assert_match /name2/, f.read }
141
- end
142
-
143
- def test_opt_overwite_config
144
- confstr = "log_name: " + "name1"
145
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
146
- RBatch::Log.new({:name => "name2" }) do | log |
147
- log.info("test_opt_overwite_config")
148
- end
149
- File::open(File.join(@dir , "name2")) {|f|
150
- assert_match /test_opt_overwite_config/, f.read
151
- }
152
- end
153
-
154
- def test_append_by_opt
155
- RBatch::Log.new({:append => true, :name => "test_append" }) do | log |
156
- log.info("test_append1")
157
- end
158
- RBatch::Log.new({:append => true, :name => "test_append" }) do | log |
159
- log.info("test_append2")
160
- end
161
- File::open(File.join(@dir , "test_append")) {|f|
162
- str = f.read
163
- assert_match /test_append1/, str
164
- assert_match /test_append2/, str
165
- }
166
- end
167
-
168
- def test_no_append_by_opt
169
- RBatch::Log.new({:append => false, :name => "test_append" }) do | log |
170
- log.info("test_append1")
171
- end
172
- RBatch::Log.new({:append => false, :name => "test_append" }) do | log |
173
- log.info("test_append2")
174
- end
175
- File::open(File.join(@dir , "test_append")) {|f|
176
- str = f.read
177
- assert_no_match /test_append1/, str
178
- assert_match /test_append2/, str
179
- }
180
- end
181
-
182
-
183
- def test_append_by_conf
184
- confstr = "log_append: true"
185
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
186
-
187
- RBatch::Log.new({:name => "test_append" }) do | log |
188
- log.info("test_append1")
189
- end
190
- RBatch::Log.new({:name => "test_append" }) do | log |
191
- log.info("test_append2")
192
- end
193
- File::open(File.join(@dir , "test_append")) {|f|
194
- str = f.read
195
- assert_match /test_append1/, str
196
- assert_match /test_append2/, str
197
- }
198
- end
199
-
200
- def test_no_append_by_conf
201
- confstr = "log_append: false"
202
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
203
-
204
- RBatch::Log.new({ :name => "test_append" }) do | log |
205
- log.info("test_append1")
206
- end
207
- RBatch::Log.new({ :name => "test_append" }) do | log |
208
- log.info("test_append2")
209
- end
210
- File::open(File.join(@dir , "test_append")) {|f|
211
- str = f.read
212
- assert_no_match /test_append1/, str
213
- assert_match /test_append2/, str
214
- }
215
- end
216
-
217
- def test_log_level_default
218
- RBatch::Log.new({ :name => "test_level" }) do | log |
219
- log.debug("test_debug")
220
- log.info("test_info")
221
- log.warn("test_warn")
222
- log.error("test_error")
223
- log.fatal("test_fatal")
224
- end
225
- File::open(File.join(@dir , "test_level")) {|f|
226
- str = f.read
227
- assert_no_match /test_debug/, str
228
- assert_match /test_info/, str
229
- assert_match /test_warn/, str
230
- assert_match /test_error/, str
231
- assert_match /test_fatal/, str
232
- }
233
- end
234
-
235
- def test_log_level_debug_by_opt
236
- RBatch::Log.new({ :level => "debug",:name => "test_level" }) do | log |
237
- log.debug("test_debug")
238
- log.info("test_info")
239
- log.warn("test_warn")
240
- log.error("test_error")
241
- log.fatal("test_fatal")
242
- end
243
- File::open(File.join(@dir , "test_level")) {|f|
244
- str = f.read
245
- assert_match /test_debug/, str
246
- assert_match /test_info/, str
247
- assert_match /test_warn/, str
248
- assert_match /test_error/, str
249
- assert_match /test_fatal/, str
250
- }
251
- end
252
-
253
- def test_log_level_info_by_opt
254
- RBatch::Log.new({ :level => "info",:name => "test_level" }) do | log |
255
- log.debug("test_debug")
256
- log.info("test_info")
257
- log.warn("test_warn")
258
- log.error("test_error")
259
- log.fatal("test_fatal")
260
- end
261
- File::open(File.join(@dir , "test_level")) {|f|
262
- str = f.read
263
- assert_no_match /test_debug/, str
264
- assert_match /test_info/, str
265
- assert_match /test_warn/, str
266
- assert_match /test_error/, str
267
- assert_match /test_fatal/, str
268
- }
269
- end
270
-
271
- def test_log_level_warn_by_opt
272
- RBatch::Log.new({ :level => "warn",:name => "test_level" }) do | log |
273
- log.debug("test_debug")
274
- log.info("test_info")
275
- log.warn("test_warn")
276
- log.error("test_error")
277
- log.fatal("test_fatal")
278
- end
279
- File::open(File.join(@dir , "test_level")) {|f|
280
- str = f.read
281
- assert_no_match /test_debug/, str
282
- assert_no_match /test_info/, str
283
- assert_match /test_warn/, str
284
- assert_match /test_error/, str
285
- assert_match /test_fatal/, str
286
- }
287
- end
288
-
289
- def test_log_level_error_by_opt
290
- RBatch::Log.new({ :level => "error",:name => "test_level" }) do | log |
291
- log.debug("test_debug")
292
- log.info("test_info")
293
- log.warn("test_warn")
294
- log.error("test_error")
295
- log.fatal("test_fatal")
296
- end
297
- File::open(File.join(@dir , "test_level")) {|f|
298
- str = f.read
299
- assert_no_match /test_debug/, str
300
- assert_no_match /test_info/, str
301
- assert_no_match /test_warn/, str
302
- assert_match /test_error/, str
303
- assert_match /test_fatal/, str
304
- }
305
- end
306
-
307
- def test_log_level_fatal_by_opt
308
- RBatch::Log.new({ :level => "fatal",:name => "test_level" }) do | log |
309
- log.debug("test_debug")
310
- log.info("test_info")
311
- log.warn("test_warn")
312
- log.error("test_error")
313
- log.fatal("test_fatal")
314
- end
315
- File::open(File.join(@dir , "test_level")) {|f|
316
- str = f.read
317
- assert_no_match /test_debug/, str
318
- assert_no_match /test_info/, str
319
- assert_no_match /test_warn/, str
320
- assert_no_match /test_error/, str
321
- assert_match /test_fatal/, str
322
- }
323
- end
324
-
325
-
326
- def test_log_level_debug_by_conf
327
- confstr = "log_level: debug"
328
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
329
-
330
- RBatch::Log.new({ :name => "test_level" }) do | log |
331
- log.debug("test_debug")
332
- log.info("test_info")
333
- log.warn("test_warn")
334
- log.error("test_error")
335
- log.fatal("test_fatal")
336
- end
337
- File::open(File.join(@dir , "test_level")) {|f|
338
- str = f.read
339
- assert_match /test_debug/, str
340
- assert_match /test_info/, str
341
- assert_match /test_warn/, str
342
- assert_match /test_error/, str
343
- assert_match /test_fatal/, str
344
- }
345
- end
346
-
347
- def test_log_level_info_by_conf
348
- confstr = "log_level: info"
349
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
350
- RBatch::Log.new({ :name => "test_level" }) do | log |
351
- log.debug("test_debug")
352
- log.info("test_info")
353
- log.warn("test_warn")
354
- log.error("test_error")
355
- log.fatal("test_fatal")
356
- end
357
- File::open(File.join(@dir , "test_level")) {|f|
358
- str = f.read
359
- assert_no_match /test_debug/, str
360
- assert_match /test_info/, str
361
- assert_match /test_warn/, str
362
- assert_match /test_error/, str
363
- assert_match /test_fatal/, str
364
- }
365
- end
366
-
367
- def test_log_level_warn_by_conf
368
- confstr = "log_level: warn"
369
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
370
- RBatch::Log.new({ :name => "test_level" }) do | log |
371
- log.debug("test_debug")
372
- log.info("test_info")
373
- log.warn("test_warn")
374
- log.error("test_error")
375
- log.fatal("test_fatal")
376
- end
377
- File::open(File.join(@dir , "test_level")) {|f|
378
- str = f.read
379
- assert_no_match /test_debug/, str
380
- assert_no_match /test_info/, str
381
- assert_match /test_warn/, str
382
- assert_match /test_error/, str
383
- assert_match /test_fatal/, str
384
- }
385
- end
386
-
387
- def test_log_level_error_by_conf
388
- confstr = "log_level: error"
389
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
390
- RBatch::Log.new({ :name => "test_level" }) do | log |
391
- log.debug("test_debug")
392
- log.info("test_info")
393
- log.warn("test_warn")
394
- log.error("test_error")
395
- log.fatal("test_fatal")
396
- end
397
- File::open(File.join(@dir , "test_level")) {|f|
398
- str = f.read
399
- assert_no_match /test_debug/, str
400
- assert_no_match /test_info/, str
401
- assert_no_match /test_warn/, str
402
- assert_match /test_error/, str
403
- assert_match /test_fatal/, str
404
- }
405
- end
406
-
407
- def test_log_level_fatal_by_conf
408
- confstr = "log_level: fatal"
409
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
410
- RBatch::Log.new({ :name => "test_level" }) do | log |
411
- log.debug("test_debug")
412
- log.info("test_info")
413
- log.warn("test_warn")
414
- log.error("test_error")
415
- log.fatal("test_fatal")
416
- end
417
- File::open(File.join(@dir , "test_level")) {|f|
418
- str = f.read
419
- assert_no_match /test_debug/, str
420
- assert_no_match /test_info/, str
421
- assert_no_match /test_warn/, str
422
- assert_no_match /test_error/, str
423
- assert_match /test_fatal/, str
424
- }
425
- end
426
-
427
-
428
- def test_i_log
429
- log = RBatch::Log.new
430
- assert_not_nil log
431
- log.info("test_log")
432
- log.close
433
- Dir::foreach(@dir) do |f|
434
- if ! (/\.+$/ =~ f)
435
- File::open(File.join(@dir , f)) {|f|
436
- assert_match /test_log/, f.read
437
- }
438
- end
439
- end
440
- end
441
-
442
- def test_i_log_dir_doesnot_exist
443
- Dir::rmdir(@dir)
444
- assert_raise(Errno::ENOENT){
445
- log = RBatch::Log.new
446
- log.close
447
- }
448
- Dir::mkdir(@dir)
449
- end
450
-
451
- def test_i_change_name_by_opt
452
- log = RBatch::Log.new({:name => "name1.log" })
453
- log.info("test_change_name_by_opt")
454
- log.close
455
- File::open(File.join(@dir , "name1.log")) {|f|
456
- assert_match /test_change_name_by_opt/, f.read
457
- }
458
- end
459
-
460
- def test_i_change_name_by_opt2
461
- log = RBatch::Log.new({:name => "<prog><date>name.log" })
462
- log.info("test_change_name_by_opt2")
463
- log.close
464
- File::open(File.join(@dir , "test_log" + Time.now.strftime("%Y%m%d") + "name.log")) {|f|
465
- assert_match /test_change_name_by_opt2/, f.read
466
- }
467
- end
468
-
469
-
470
- def test_i_log_level_default
471
- log = RBatch::Log.new({ :name => "test_level" })
472
- log.debug("test_debug")
473
- log.info("test_info")
474
- log.warn("test_warn")
475
- log.error("test_error")
476
- log.fatal("test_fatal")
477
- log.close
478
-
479
- File::open(File.join(@dir , "test_level")) {|f|
480
- str = f.read
481
- assert_no_match /test_debug/, str
482
- assert_match /test_info/, str
483
- assert_match /test_warn/, str
484
- assert_match /test_error/, str
485
- assert_match /test_fatal/, str
486
- }
487
- end
488
-
489
- def test_i_log_level_debug_by_opt
490
- log = RBatch::Log.new({ :level => "debug",:name => "test_level" })
491
- log.debug("test_debug")
492
- log.info("test_info")
493
- log.warn("test_warn")
494
- log.error("test_error")
495
- log.fatal("test_fatal")
496
- log.close
497
- File::open(File.join(@dir , "test_level")) {|f|
498
- str = f.read
499
- assert_match /test_debug/, str
500
- assert_match /test_info/, str
501
- assert_match /test_warn/, str
502
- assert_match /test_error/, str
503
- assert_match /test_fatal/, str
504
- }
505
- end
506
-
507
-
508
- def test_i_log_level_debug_by_conf
509
- confstr = "log_level: debug"
510
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
511
-
512
- log = RBatch::Log.new({ :name => "test_level" })
513
- log.debug("test_debug")
514
- log.info("test_info")
515
- log.warn("test_warn")
516
- log.error("test_error")
517
- log.fatal("test_fatal")
518
- log.close
519
- File::open(File.join(@dir , "test_level")) {|f|
520
- str = f.read
521
- assert_match /test_debug/, str
522
- assert_match /test_info/, str
523
- assert_match /test_warn/, str
524
- assert_match /test_error/, str
525
- assert_match /test_fatal/, str
526
- }
527
- end
528
-
529
- def test_delete_old_log_by_opt
530
- loglist = [*0..20].map do |day|
531
- File.join(@dir , (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
532
- end
533
- FileUtils.touch(loglist)
534
- log = RBatch::Log.new({ :name => "<date>_test_delete.log",:delete_old_log => true})
535
- loglist[1..6].each do |filename|
536
- assert File.exists?(filename), "log file \"#{filename}\" should be exist"
537
- end
538
- loglist[7..20].each do |filename|
539
- assert ! File.exists?(filename), "log file \"#{filename}\" should NOT be exist"
540
- end
541
- end
542
- def test_delete_old_log_by_config
543
- confstr = "log_delete_old_log: true"
544
- open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
545
-
546
- loglist = [*0..20].map do |day|
547
- File.join(@dir , (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
548
- end
549
- FileUtils.touch(loglist)
550
- log = RBatch::Log.new({ :name => "<date>_test_delete.log"})
551
- loglist[1..6].each do |filename|
552
- assert File.exists?(filename), "log file \"#{filename}\" should be exist"
553
- end
554
- loglist[7..20].each do |filename|
555
- assert ! File.exists?(filename), "log file \"#{filename}\" should NOT be exist"
556
- end
557
- end
558
-
559
- def test_delete_old_log_file_format_change_with_time
560
- loglist = [*0..20].map do |day|
561
- File.join(@dir , "235959-" + (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
562
- end
563
- FileUtils.touch(loglist)
564
- log = RBatch::Log.new({ :name => "<time>-<date>_test_delete.log",:delete_old_log => true})
565
- loglist[1..6].each do |filename|
566
- assert File.exists?(filename), "log file \"#{filename}\" should be exist"
567
- end
568
- loglist[7..20].each do |filename|
569
- assert ! File.exists?(filename), "log file \"#{filename}\" should NOT be exist"
570
- end
571
- end
572
-
573
- def test_delete_old_log_file_format_change_no_date
574
- log = RBatch::Log.new({ :name => "test_delete.log",:delete_old_log => true})
575
- assert File.exists?(File.join(@dir,"test_delete.log")), "log file \"test_delete.log\" should be exist"
576
- end
577
-
578
- def test_delete_old_log_date
579
- loglist = [*0..20].map do |day|
580
- File.join(@dir , (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
581
- end
582
- FileUtils.touch(loglist)
583
- log = RBatch::Log.new({ :name => "<date>_test_delete.log",:delete_old_log => true,:delete_old_log_date => 5})
584
- loglist[1..4].each do |filename|
585
- assert File.exists?(filename), "log file \"#{filename}\" should be exist"
586
- end
587
- loglist[5..20].each do |filename|
588
- assert ! File.exists?(filename), "log file \"#{filename}\" should NOT be exist"
589
- end
590
- end
591
-
592
-
593
- end
594
-
File without changes
Binary file
Binary file