rbatch 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.ja.md +14 -5
- data/README.md +164 -154
- data/bin/rbatch-init +21 -13
- data/doc/RBatch/Cmd.html +300 -316
- data/doc/RBatch/CmdException.html +146 -141
- data/doc/RBatch/CmdResult.html +467 -470
- data/doc/RBatch/Config.html +392 -433
- data/doc/RBatch/Controller.html +374 -0
- data/doc/RBatch/DoubleRunCheckException.html +146 -141
- data/doc/RBatch/DoubleRunChecker.html +258 -256
- data/doc/RBatch/Journal.html +332 -0
- data/doc/RBatch/Log.html +636 -805
- data/doc/RBatch/LogException.html +164 -0
- data/doc/RBatch/RBatch/RBatch/ConfigException.html +164 -0
- data/doc/RBatch/RBatch/RBatch.html +163 -0
- data/doc/RBatch/RBatch/VariablesException.html +164 -0
- data/doc/RBatch/RBatch.html +165 -0
- data/doc/RBatch/RunConf/Exception.html +146 -141
- data/doc/RBatch/RunConf.html +478 -532
- data/doc/RBatch/Variables.html +437 -0
- data/doc/RBatch.html +388 -862
- data/doc/created.rid +11 -9
- data/doc/index.html +178 -184
- data/doc/js/darkfish.js +9 -7
- data/doc/lib/rbatch/cmd_rb.html +46 -44
- data/doc/lib/rbatch/config_rb.html +42 -42
- data/doc/lib/rbatch/controller_rb.html +66 -0
- data/doc/lib/rbatch/double_run_checker_rb.html +42 -42
- data/doc/lib/rbatch/journal_rb.html +52 -0
- data/doc/lib/rbatch/log_rb.html +46 -46
- data/doc/lib/rbatch/run_conf_rb.html +42 -42
- data/doc/lib/rbatch/variables_rb.html +54 -0
- data/doc/lib/rbatch/version_rb.html +38 -38
- data/doc/lib/rbatch_rb.html +40 -52
- data/doc/rdoc.css +365 -308
- data/lib/rbatch/cmd.rb +15 -58
- data/lib/rbatch/config.rb +7 -7
- data/lib/rbatch/controller.rb +37 -61
- data/lib/rbatch/double_run_checker.rb +0 -0
- data/lib/rbatch/journal.rb +40 -0
- data/lib/rbatch/log.rb +71 -129
- data/lib/rbatch/run_conf.rb +13 -24
- data/lib/rbatch/variables.rb +82 -0
- data/lib/rbatch/version.rb +1 -1
- data/lib/rbatch.rb +7 -36
- data/sample/.rbatchrc +41 -7
- data/spec/01_rbach_spec.rb +99 -0
- data/spec/{cmd_spec.rb → rbatch/cmd_spec.rb} +40 -43
- data/spec/rbatch/config_spec.rb +67 -0
- data/spec/rbatch/controller_spec.rb +18 -0
- data/spec/{double_run_checker_spec.rb → rbatch/double_run_checker_spec.rb} +3 -0
- data/spec/rbatch/journal_spec.rb +29 -0
- data/spec/rbatch/log_spec.rb +350 -0
- data/spec/{run_conf_spec.rb → rbatch/run_conf_spec.rb} +13 -5
- data/spec/rbatch/variables_spec.rb +68 -0
- data/spec/spec_helper.rb +4 -5
- metadata +33 -17
- data/lib/rbatch/common_config.rb +0 -0
- data/spec/common_config_spec.rb +0 -85
- data/spec/config_spec.rb +0 -79
- data/spec/log_spec.rb +0 -430
- data/spec/rbatch_spec.rb +0 -22
data/spec/config_spec.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join( File.dirname(__FILE__), 'spec_helper'))
|
2
|
-
|
3
|
-
require 'rbatch'
|
4
|
-
|
5
|
-
describe RBatch::Config do
|
6
|
-
before :all do
|
7
|
-
@config_dir=File.join(ENV["RB_HOME"],"conf")
|
8
|
-
@config_file = File.join(@config_dir , "rspec.yaml")
|
9
|
-
Dir::mkdir @config_dir if ! Dir.exists? @config_dir
|
10
|
-
end
|
11
|
-
|
12
|
-
before :each do
|
13
|
-
end
|
14
|
-
|
15
|
-
after :each do
|
16
|
-
FileUtils.rm @config_file if File.exists? @config_file
|
17
|
-
end
|
18
|
-
|
19
|
-
after :all do
|
20
|
-
end
|
21
|
-
|
22
|
-
it "read config" do
|
23
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
24
|
-
RBatch.init
|
25
|
-
expect(RBatch.config["key"]).to eq "value"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "read config. Key is Symbol" do
|
29
|
-
open( @config_file , "w" ){|f| f.write(":key: value")}
|
30
|
-
RBatch.init
|
31
|
-
expect(RBatch.config[:key]).to eq "value"
|
32
|
-
end
|
33
|
-
|
34
|
-
it "raise error when config does not exist" do
|
35
|
-
RBatch.init
|
36
|
-
expect {
|
37
|
-
RBatch.config["hoge"]
|
38
|
-
}.to raise_error(RBatch::Config::Exception)
|
39
|
-
expect {
|
40
|
-
RBatch.config.to_h
|
41
|
-
}.to raise_error(RBatch::Config::Exception)
|
42
|
-
expect {
|
43
|
-
RBatch.config.to_s
|
44
|
-
}.to raise_error(RBatch::Config::Exception)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "read config twice" do
|
48
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
49
|
-
RBatch.init
|
50
|
-
expect(RBatch.config["key"]).to eq "value"
|
51
|
-
expect(RBatch.config["key"]).to eq "value"
|
52
|
-
end
|
53
|
-
|
54
|
-
it "raise error when read value which key does not exist" do
|
55
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
56
|
-
RBatch.init
|
57
|
-
expect {
|
58
|
-
RBatch.config["not_exist"]
|
59
|
-
}.to raise_error(RBatch::Config::Exception)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "raise error when read value which key mistake String for Symbol" do
|
63
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
64
|
-
RBatch.init
|
65
|
-
expect {
|
66
|
-
RBatch.config[:key]
|
67
|
-
}.to raise_error(RBatch::Config::Exception)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "raise error when read value which key mistake Symbol for String" do
|
71
|
-
open( @config_file , "w" ){|f| f.write(":key: value")}
|
72
|
-
RBatch.init
|
73
|
-
expect {
|
74
|
-
RBatch.config["key"]
|
75
|
-
}.to raise_error(RBatch::Config::Exception)
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
end
|
data/spec/log_spec.rb
DELETED
@@ -1,430 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join( File.dirname(__FILE__), 'spec_helper'))
|
2
|
-
|
3
|
-
require 'rbatch'
|
4
|
-
|
5
|
-
describe RBatch::Log do
|
6
|
-
|
7
|
-
before :all do
|
8
|
-
@dir = File.join(ENV["RB_HOME"],"log")
|
9
|
-
Dir::mkdir(@dir)if ! Dir.exists? @dir
|
10
|
-
end
|
11
|
-
|
12
|
-
before :each do
|
13
|
-
open( RBatch.run_conf_path , "w" ){|f| f.write("")}
|
14
|
-
RBatch.run_conf.reload
|
15
|
-
end
|
16
|
-
|
17
|
-
after :each do
|
18
|
-
Dir::foreach(@dir) do |f|
|
19
|
-
File::delete(File.join(@dir , f)) if ! (/\.+$/ =~ f)
|
20
|
-
end
|
21
|
-
FileUtils.rm(RBatch.run_conf_path) if File.exist?(RBatch.run_conf_path)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "is run" do
|
25
|
-
RBatch::Log.new do | log |
|
26
|
-
log.info("test_log")
|
27
|
-
end
|
28
|
-
Dir::foreach(@dir) do |f|
|
29
|
-
if ! (/\.+$/ =~ f)
|
30
|
-
File::open(File.join(@dir , f)) {|f|
|
31
|
-
expect(f.read).to match /test_log/
|
32
|
-
}
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
it "raise error when log dir does not exist" do
|
38
|
-
Dir::rmdir(@dir)
|
39
|
-
expect{
|
40
|
-
RBatch::Log.new {|log|}
|
41
|
-
}.to raise_error(Errno::ENOENT)
|
42
|
-
Dir::mkdir(@dir)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "run when log block is nested" do
|
46
|
-
RBatch::Log.new({:name => "name1" }) do | log |
|
47
|
-
log.info("name1")
|
48
|
-
RBatch::Log.new({:name => "name2" }) do | log |
|
49
|
-
log.info("name2")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
File::open(File.join(@dir,"name1")) {|f| expect(f.read).to match /name1/ }
|
53
|
-
File::open(File.join(@dir,"name2")) {|f| expect(f.read).to match /name2/ }
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "option by argument" do
|
57
|
-
it "change log name" do
|
58
|
-
RBatch::Log.new({:name => "name1.log" }) do | log |
|
59
|
-
log.info("hoge")
|
60
|
-
end
|
61
|
-
File::open(File.join(@dir , "name1.log")) {|f|
|
62
|
-
expect(f.read).to match /hoge/
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
it "change log name 2" do
|
67
|
-
RBatch::Log.new({:name => "<prog><date>name.log" }) do | log |
|
68
|
-
log.info("hoge")
|
69
|
-
end
|
70
|
-
File::open(File.join(@dir , "rspec" + Time.now.strftime("%Y%m%d") + "name.log")) {|f|
|
71
|
-
expect(f.read).to match /hoge/
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
75
|
-
it "change log name 3" do
|
76
|
-
RBatch::Log.new({:name => "<prog>-<date>-name.log" }) do | log |
|
77
|
-
log.info("hoge")
|
78
|
-
end
|
79
|
-
File::open(File.join(@dir , "rspec-" + Time.now.strftime("%Y%m%d") + "-name.log")) {|f|
|
80
|
-
expect(f.read).to match /hoge/
|
81
|
-
}
|
82
|
-
end
|
83
|
-
|
84
|
-
it "change log dir" do
|
85
|
-
@tmp = File.join(ENV["RB_HOME"],"log3")
|
86
|
-
Dir.mkdir(@tmp)
|
87
|
-
RBatch::Log.new({:name => "c.log", :dir=> @tmp }) do | log |
|
88
|
-
log.info("hoge")
|
89
|
-
end
|
90
|
-
File::open(File.join(@tmp , "c.log")) {|f|
|
91
|
-
expect(f.read).to match /hoge/
|
92
|
-
}
|
93
|
-
end
|
94
|
-
|
95
|
-
it "is append mode" do
|
96
|
-
RBatch::Log.new({:append => true, :name => "a.log" }) do | log |
|
97
|
-
log.info("line1")
|
98
|
-
end
|
99
|
-
RBatch::Log.new({:append => true, :name => "a.log" }) do | log |
|
100
|
-
log.info("line2")
|
101
|
-
end
|
102
|
-
File::open(File.join(@dir , "a.log")) {|f|
|
103
|
-
str = f.read
|
104
|
-
expect(str).to match /line1/
|
105
|
-
expect(str).to match /line2/
|
106
|
-
}
|
107
|
-
end
|
108
|
-
|
109
|
-
it "is overwrite mode" do
|
110
|
-
RBatch::Log.new({:append => false, :name => "a.log" }) do | log |
|
111
|
-
log.info("line1")
|
112
|
-
end
|
113
|
-
RBatch::Log.new({:append => false, :name => "a.log" }) do | log |
|
114
|
-
log.info("line2")
|
115
|
-
end
|
116
|
-
File::open(File.join(@dir , "a.log")) {|f|
|
117
|
-
str = f.read
|
118
|
-
expect(str).to_not match /line1/
|
119
|
-
expect(str).to match /line2/
|
120
|
-
}
|
121
|
-
end
|
122
|
-
|
123
|
-
it "is debug level" do
|
124
|
-
RBatch::Log.new({ :level => "debug",:name => "a.log" }) do | log |
|
125
|
-
log.debug("test_debug")
|
126
|
-
log.info("test_info")
|
127
|
-
log.warn("test_warn")
|
128
|
-
log.error("test_error")
|
129
|
-
log.fatal("test_fatal")
|
130
|
-
end
|
131
|
-
File::open(File.join(@dir , "a.log")) {|f|
|
132
|
-
str = f.read
|
133
|
-
expect(str).to match /test_debug/
|
134
|
-
expect(str).to match /test_info/
|
135
|
-
expect(str).to match /test_warn/
|
136
|
-
expect(str).to match /test_error/
|
137
|
-
expect(str).to match /test_fatal/
|
138
|
-
}
|
139
|
-
end
|
140
|
-
|
141
|
-
it "is info level" do
|
142
|
-
RBatch::Log.new({ :level => "info",:name => "a.log" }) do | log |
|
143
|
-
log.debug("test_debug")
|
144
|
-
log.info("test_info")
|
145
|
-
log.warn("test_warn")
|
146
|
-
log.error("test_error")
|
147
|
-
log.fatal("test_fatal")
|
148
|
-
end
|
149
|
-
File::open(File.join(@dir , "a.log")) {|f|
|
150
|
-
str = f.read
|
151
|
-
expect(str).to_not match /test_debug/
|
152
|
-
expect(str).to match /test_info/
|
153
|
-
expect(str).to match /test_warn/
|
154
|
-
expect(str).to match /test_error/
|
155
|
-
expect(str).to match /test_fatal/
|
156
|
-
}
|
157
|
-
end
|
158
|
-
|
159
|
-
it "is warn level" do
|
160
|
-
RBatch::Log.new({ :level => "warn",:name => "a.log" }) do | log |
|
161
|
-
log.debug("test_debug")
|
162
|
-
log.info("test_info")
|
163
|
-
log.warn("test_warn")
|
164
|
-
log.error("test_error")
|
165
|
-
log.fatal("test_fatal")
|
166
|
-
end
|
167
|
-
File::open(File.join(@dir , "a.log")) {|f|
|
168
|
-
str = f.read
|
169
|
-
expect(str).to_not match /test_debug/
|
170
|
-
expect(str).to_not match /test_info/
|
171
|
-
expect(str).to match /test_warn/
|
172
|
-
expect(str).to match /test_error/
|
173
|
-
expect(str).to match /test_fatal/
|
174
|
-
}
|
175
|
-
end
|
176
|
-
|
177
|
-
it "is error level" do
|
178
|
-
RBatch::Log.new({ :level => "error",:name => "a.log" }) do | log |
|
179
|
-
log.debug("test_debug")
|
180
|
-
log.info("test_info")
|
181
|
-
log.warn("test_warn")
|
182
|
-
log.error("test_error")
|
183
|
-
log.fatal("test_fatal")
|
184
|
-
end
|
185
|
-
File::open(File.join(@dir , "a.log")) {|f|
|
186
|
-
str = f.read
|
187
|
-
expect(str).to_not match /test_debug/
|
188
|
-
expect(str).to_not match /test_info/
|
189
|
-
expect(str).to_not match /test_warn/
|
190
|
-
expect(str).to match /test_error/
|
191
|
-
expect(str).to match /test_fatal/
|
192
|
-
}
|
193
|
-
end
|
194
|
-
|
195
|
-
it "is fatal level" do
|
196
|
-
RBatch::Log.new({ :level => "fatal",:name => "a.log" }) do | log |
|
197
|
-
log.debug("test_debug")
|
198
|
-
log.info("test_info")
|
199
|
-
log.warn("test_warn")
|
200
|
-
log.error("test_error")
|
201
|
-
log.fatal("test_fatal")
|
202
|
-
end
|
203
|
-
File::open(File.join(@dir , "a.log")) {|f|
|
204
|
-
str = f.read
|
205
|
-
expect(str).to_not match /test_debug/
|
206
|
-
expect(str).to_not match /test_info/
|
207
|
-
expect(str).to_not match /test_warn/
|
208
|
-
expect(str).to_not match /test_error/
|
209
|
-
expect(str).to match /test_fatal/
|
210
|
-
}
|
211
|
-
end
|
212
|
-
|
213
|
-
it "is default level" do
|
214
|
-
RBatch::Log.new({ :name => "a.log" }) do | log |
|
215
|
-
log.debug("test_debug")
|
216
|
-
log.info("test_info")
|
217
|
-
log.warn("test_warn")
|
218
|
-
log.error("test_error")
|
219
|
-
log.fatal("test_fatal")
|
220
|
-
end
|
221
|
-
File::open(File.join(@dir , "a.log")) {|f|
|
222
|
-
str = f.read
|
223
|
-
expect(str).to_not match /test_debug/
|
224
|
-
expect(str).to match /test_info/
|
225
|
-
expect(str).to match /test_warn/
|
226
|
-
expect(str).to match /test_error/
|
227
|
-
expect(str).to match /test_fatal/
|
228
|
-
}
|
229
|
-
end
|
230
|
-
|
231
|
-
it "delete old log which name include <date>" do
|
232
|
-
loglist = [*0..20].map do |day|
|
233
|
-
File.join(@dir , (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
|
234
|
-
end
|
235
|
-
FileUtils.touch(loglist)
|
236
|
-
log = RBatch::Log.new({ :name => "<date>_test_delete.log",:delete_old_log => true})
|
237
|
-
log.close
|
238
|
-
loglist[1..6].each do |filename|
|
239
|
-
expect(File.exists?(filename)).to be true
|
240
|
-
end
|
241
|
-
loglist[7..20].each do |filename|
|
242
|
-
expect(File.exists?(filename)).to be false
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
it "delete old log which name include <date> even if <date> position is changed" do
|
247
|
-
loglist = [*0..20].map do |day|
|
248
|
-
File.join(@dir , "235959-" + (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
|
249
|
-
end
|
250
|
-
FileUtils.touch(loglist)
|
251
|
-
log = RBatch::Log.new({ :name => "<time>-<date>_test_delete.log",:delete_old_log => true})
|
252
|
-
log.close
|
253
|
-
loglist[1..6].each do |filename|
|
254
|
-
expect(File.exists?(filename)).to be true
|
255
|
-
end
|
256
|
-
loglist[7..20].each do |filename|
|
257
|
-
expect(File.exists?(filename)).to be false
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
it "does not delete old log which name does not include <date>" do
|
262
|
-
log = RBatch::Log.new({ :name => "test_delete.log",:delete_old_log => true})
|
263
|
-
log.close
|
264
|
-
expect(File.exists?(File.join(@dir,"test_delete.log"))).to be true
|
265
|
-
end
|
266
|
-
|
267
|
-
|
268
|
-
end
|
269
|
-
|
270
|
-
describe "option by config" do
|
271
|
-
it "change log name" do
|
272
|
-
confstr = "log_name: name1.log"
|
273
|
-
open( RBatch.run_conf_path , "a" ){|f| f.write(confstr)}
|
274
|
-
RBatch.run_conf.reload
|
275
|
-
RBatch::Log.new() do | log |
|
276
|
-
log.info("hoge")
|
277
|
-
end
|
278
|
-
File::open(File.join(@dir , "name1.log")) {|f|
|
279
|
-
expect(f.read).to match /hoge/
|
280
|
-
}
|
281
|
-
end
|
282
|
-
|
283
|
-
it "change log dir" do
|
284
|
-
@tmp = File.join(ENV["RB_HOME"],"log2")
|
285
|
-
Dir.mkdir(@tmp)
|
286
|
-
confstr = "log_name: c.log\nlog_dir: " + @tmp
|
287
|
-
open( RBatch.run_conf_path , "a" ){|f| f.write(confstr)}
|
288
|
-
RBatch.run_conf.reload
|
289
|
-
RBatch::Log.new({:name => "c.log", :dir=> @tmp }) do | log |
|
290
|
-
log.info("hoge")
|
291
|
-
end
|
292
|
-
File::open(File.join(@tmp , "c.log")) {|f|
|
293
|
-
expect(f.read).to match /hoge/
|
294
|
-
}
|
295
|
-
end
|
296
|
-
|
297
|
-
it "is append mode" do
|
298
|
-
confstr = "log_name: a.log\nlog_append: true"
|
299
|
-
open( RBatch.run_conf_path , "a" ){|f| f.write(confstr)}
|
300
|
-
RBatch.run_conf.reload
|
301
|
-
RBatch::Log.new() do | log |
|
302
|
-
log.info("line1")
|
303
|
-
end
|
304
|
-
RBatch::Log.new() do | log |
|
305
|
-
log.info("line2")
|
306
|
-
end
|
307
|
-
File::open(File.join(@dir , "a.log")) {|f|
|
308
|
-
str = f.read
|
309
|
-
expect(str).to match /line1/
|
310
|
-
expect(str).to match /line2/
|
311
|
-
}
|
312
|
-
end
|
313
|
-
|
314
|
-
it "is overwrite mode" do
|
315
|
-
confstr = "log_name: a.log\nlog_append: false"
|
316
|
-
open( RBatch.run_conf_path , "a" ){|f| f.write(confstr)}
|
317
|
-
RBatch.run_conf.reload
|
318
|
-
RBatch::Log.new() do | log |
|
319
|
-
log.info("line1")
|
320
|
-
end
|
321
|
-
RBatch::Log.new() do | log |
|
322
|
-
log.info("line2")
|
323
|
-
end
|
324
|
-
File::open(File.join(@dir , "a.log")) {|f|
|
325
|
-
str = f.read
|
326
|
-
expect(str).to_not match /line1/
|
327
|
-
expect(str).to match /line2/
|
328
|
-
}
|
329
|
-
end
|
330
|
-
|
331
|
-
it "is warn level" do
|
332
|
-
confstr = "log_name: a.log\nlog_level: warn"
|
333
|
-
open( RBatch.run_conf_path , "a" ){|f| f.write(confstr)}
|
334
|
-
RBatch.run_conf.reload
|
335
|
-
RBatch::Log.new() do | log |
|
336
|
-
log.debug("test_debug")
|
337
|
-
log.info("test_info")
|
338
|
-
log.warn("test_warn")
|
339
|
-
log.error("test_error")
|
340
|
-
log.fatal("test_fatal")
|
341
|
-
end
|
342
|
-
File::open(File.join(@dir , "a.log")) {|f|
|
343
|
-
str = f.read
|
344
|
-
expect(str).to_not match /test_debug/
|
345
|
-
expect(str).to_not match /test_info/
|
346
|
-
expect(str).to match /test_warn/
|
347
|
-
expect(str).to match /test_error/
|
348
|
-
expect(str).to match /test_fatal/
|
349
|
-
}
|
350
|
-
end
|
351
|
-
|
352
|
-
it "delete old log file which name include <date>" do
|
353
|
-
confstr = "log_delete_old_log: true"
|
354
|
-
open( RBatch.run_conf_path , "a" ){|f| f.write(confstr)}
|
355
|
-
RBatch.run_conf.reload
|
356
|
-
loglist = [*0..20].map do |day|
|
357
|
-
File.join(@dir , (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
|
358
|
-
end
|
359
|
-
FileUtils.touch(loglist)
|
360
|
-
log = RBatch::Log.new({ :name => "<date>_test_delete.log"})
|
361
|
-
log.close
|
362
|
-
loglist[1..6].each do |filename|
|
363
|
-
expect( File.exists?(filename)).to be true
|
364
|
-
end
|
365
|
-
loglist[7..20].each do |filename|
|
366
|
-
expect( File.exists?(filename)).to be false
|
367
|
-
end
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
describe "option by both argument and config" do
|
372
|
-
it "is prior to argument than config" do
|
373
|
-
confstr = "log_name: a.log"
|
374
|
-
open( RBatch.run_conf_path , "a" ){|f| f.write(confstr)}
|
375
|
-
RBatch.run_conf.reload
|
376
|
-
RBatch::Log.new({:name => "b.log"}) do | log |
|
377
|
-
log.info("hoge")
|
378
|
-
end
|
379
|
-
File::open(File.join(@dir , "b.log")) {|f|
|
380
|
-
expect(f.read).to match /hoge/
|
381
|
-
}
|
382
|
-
end
|
383
|
-
end
|
384
|
-
|
385
|
-
describe "instance" do
|
386
|
-
it "run" do
|
387
|
-
log = RBatch::Log.new
|
388
|
-
expect(log).to_not be_nil
|
389
|
-
log.info("test_log")
|
390
|
-
log.close
|
391
|
-
Dir::foreach(@dir) do |f|
|
392
|
-
if ! (/\.+$/ =~ f)
|
393
|
-
File::open(File.join(@dir , f)) {|f|
|
394
|
-
expect(f.read).to match /test_log/
|
395
|
-
}
|
396
|
-
end
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
it "raise error when log dir does not exist" do
|
401
|
-
Dir::rmdir(@dir)
|
402
|
-
expect{
|
403
|
-
RBatch::Log.new
|
404
|
-
}.to raise_error(Errno::ENOENT)
|
405
|
-
Dir::mkdir(@dir)
|
406
|
-
end
|
407
|
-
|
408
|
-
it "option by argument" do
|
409
|
-
log = RBatch::Log.new({:name => "d.log" })
|
410
|
-
log.info("hoge")
|
411
|
-
log.close
|
412
|
-
File::open(File.join(@dir , "d.log")) {|f|
|
413
|
-
expect(f.read).to match /hoge/
|
414
|
-
}
|
415
|
-
end
|
416
|
-
|
417
|
-
|
418
|
-
it "option by config" do
|
419
|
-
confstr = "log_name: e.log"
|
420
|
-
open( RBatch.run_conf_path , "a" ){|f| f.write(confstr)}
|
421
|
-
RBatch.run_conf.reload
|
422
|
-
log = RBatch::Log.new()
|
423
|
-
log.info("hoge")
|
424
|
-
log.close
|
425
|
-
File::open(File.join(@dir , "e.log")) {|f|
|
426
|
-
expect(f.read).to match /hoge/
|
427
|
-
}
|
428
|
-
end
|
429
|
-
end
|
430
|
-
end
|
data/spec/rbatch_spec.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join( File.dirname(__FILE__), 'spec_helper'))
|
2
|
-
|
3
|
-
describe "RBatch" do
|
4
|
-
before :all do
|
5
|
-
end
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
end
|
12
|
-
|
13
|
-
after :all do
|
14
|
-
end
|
15
|
-
|
16
|
-
it "RB_HOME should be home_dir" do
|
17
|
-
require 'rbatch'
|
18
|
-
expect(RBatch.ctrl.home_dir).to eq ENV["RB_HOME"]
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
end
|