rbatch 1.13.1 → 2.0.0

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