rbbt-util 5.13.31 → 5.13.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -130,7 +130,9 @@ class Step
130
130
  exec
131
131
  end
132
132
 
133
- def clean
133
+ def self.clean(path)
134
+ info_file = Step.info_file path
135
+ files_dir = Step.files_dir path
134
136
  if Open.exists?(path) or Open.exists?(info_file)
135
137
  begin
136
138
  self.abort if self.running?
@@ -148,6 +150,10 @@ class Step
148
150
  Open.rm_rf files_dir if Open.exists? files_dir
149
151
  end
150
152
  end
153
+ end
154
+
155
+ def clean
156
+ Step.clean(path)
151
157
  self
152
158
  end
153
159
 
data/lib/rbbt/workflow.rb CHANGED
@@ -233,22 +233,28 @@ module Workflow
233
233
  end
234
234
  end
235
235
 
236
+ def step_module
237
+ @_m ||= begin
238
+ m = Module.new
239
+
240
+ helpers.each do |name,block|
241
+ m.class.send(:define_method, name, &block)
242
+ end
243
+
244
+ m
245
+ end
246
+ @_m
247
+ end
248
+
236
249
  def get_job_step(step_path, task = nil, input_values = nil, dependencies = nil)
237
250
  step_path = step_path.call if Proc === step_path
238
251
  persist = input_values.nil? ? false : true
239
252
  persist = false
240
253
  key = Path === step_path ? step_path.find : step_path
241
- step = Persist.memory("Step", :key => key, :repo => step_cache, :persist => persist) do
242
254
  step = Step.new step_path, task, input_values, dependencies
243
255
 
244
- helpers.each do |name, block|
245
- (class << step; self; end).instance_eval do
246
- define_method name, &block
247
- end
248
- end
249
256
 
250
- step
251
- end
257
+ step.extend step_module
252
258
 
253
259
  step.task ||= task
254
260
  step.inputs ||= input_values
@@ -268,12 +274,13 @@ module Workflow
268
274
 
269
275
  Workflow.resolve_locals(inputs)
270
276
 
271
- dependencies = real_dependencies(task, jobname, inputs, task_dependencies[taskname] || [])
272
-
273
- real_inputs = {}
274
277
  task_inputs = task_info(taskname)[:inputs]
275
278
  defaults = task_info(taskname)[:input_defaults]
276
279
 
280
+ dependencies = real_dependencies(task, jobname, defaults.merge(inputs), task_dependencies[taskname] || [])
281
+
282
+ real_inputs = {}
283
+
277
284
  inputs.each do |k,v|
278
285
  real_inputs[k] = v if (task_inputs.include?(k.to_sym) or task_inputs.include?(k.to_s)) and (defaults[k].to_s != v.to_s and not (FalseClass === v and defaults[k].nil?))
279
286
  end
@@ -9,88 +9,87 @@ $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_c
9
9
 
10
10
  options = SOPT.setup <<EOF
11
11
 
12
- Clean failed jobs, lock files, etc
12
+ Clean orphaned files
13
13
 
14
- $ rbbt system clean
14
+ $ rbbt system clean <workflow> <task>
15
15
 
16
+ -a--all Print all jobs, not only uncompleted
17
+ -f--force Remove regardless of been active
16
18
  -h--help Print this help
17
19
  EOF
18
20
  rbbt_usage and exit 0 if options[:help]
19
21
 
20
- locks = Rbbt.locks
22
+ workflow, task = ARGV
23
+
24
+ workflow = workflow.split "," if workflow
25
+ task = task.split "," if task
26
+
27
+ all = options.delete :all
28
+ force = options.delete :force
21
29
 
22
30
  puts Log.color(:magenta, "# System clean")
23
- puts
31
+
32
+ locks = Rbbt.lock_info
24
33
  if locks.any?
25
- puts Log.color(:magenta, "Locks: #{locks.length}")
26
- locks.each do |lock|
27
- pid, ppid, time = Rbbt.load_lock(lock)
28
- if File.exists?(lock) and not Misc.pid_exists? pid
29
- puts " Removing #{ lock }"
30
- FileUtils.rm lock #if File.exists? lock
34
+ puts
35
+ puts Log.color(:magenta, "Locks:")
36
+ locks.each do |file,info|
37
+ if force or (info[:pid] and Misc.pid_exists? info[:pid])
38
+ puts " Removing #{ file }"
39
+ File.unlink file
31
40
  end
32
41
  end
33
- puts
34
42
  end
35
43
 
36
- persists = Rbbt.persists
44
+ persists = Rbbt.persist_info
37
45
  if persists.any?
38
- puts Log.color(:magenta, "Persist: #{persists.length}")
39
- persists.each do |persist|
40
- lf = persist + '.lock'
41
- pid, ppid, time = Rbbt.load_lock(lf)
42
- if not Misc.pid_exists? pid
43
- puts " Removing #{ persist }"
44
- FileUtils.rm persists if File.exists? persists
45
- FileUtils.rm lf if File.exists? lf
46
+ puts
47
+ puts Log.color(:magenta, "Persist:")
48
+ persists.each do |file,info|
49
+ if force or (info[:pid] and Misc.pid_exists? info[:pid])
50
+ puts " Removing #{ file }"
51
+ File.unlink file
46
52
  end
47
53
  end
48
- puts
49
54
  end
50
55
 
51
- sensiblewrites = Rbbt.sensiblewrites
56
+ sensiblewrites = Rbbt.sensiblewrite_info
52
57
  if sensiblewrites.any?
53
- puts Log.color(:magenta, "Writing: #{sensiblewrites.length}")
54
- sensiblewrites.each do |sensiblewrite|
55
- lf = sensiblewrite + '.lock'
56
- pid, ppid, time = Rbbt.load_lock(lf)
57
- if not Misc.pid_exists? pid
58
- puts " Removing #{ sensiblewrite }"
59
- FileUtils.rm sensiblewrite if File.exists? sensiblewrite
60
- FileUtils.rm lf if File.exists? lf
58
+ puts
59
+ puts Log.color(:magenta, "Writes:")
60
+ sensiblewrites.each do |file,info|
61
+ if force or (info[:pid] and Misc.pid_exists? info[:pid])
62
+ puts " Removing #{ file }"
63
+ File.unlink file
61
64
  end
62
65
  end
63
- puts
64
66
  end
65
67
 
66
- jobs = Rbbt.jobs
67
-
68
+ puts
68
69
  puts Log.color(:magenta, "# Workflow clean")
69
70
  puts
70
- jobs.each do |workflow, tasks|
71
- tasks.each do |task, jobs|
72
- done = []
73
- other = {}
74
- jobs.each do |file,h|
75
- #puts "* " << Log.color(:magenta, workflow) << "#" << Log.color(:yellow, task) << ": #{jobs.length}"
76
- status = h[:status]
77
- if h[:status] == :done
78
- done << file
79
- else
80
- other[status||"missing"] ||= []
81
- other[status||"missing"] << [file, h[:pid]]
82
- end
83
- end
84
- other.each do |status, list|
85
- list.each do |f,p|
86
- if not Misc.pid_exists?(p) or status.to_s =~ /error|aborted|missing/
87
- puts " Removing #{ f }"
88
- FileUtils.rm_rf f if File.exists? f
89
- FileUtils.rm_rf f + '.info' if File.exists? f + '.info'
90
- FileUtils.rm_rf f + '.files' if File.exists? f + '.files'
91
- end
92
- end
93
- end
94
- end
71
+
72
+ jobs = Rbbt.job_info workflow, task
73
+ workflows = {}
74
+
75
+ jobs.each do |file,i|
76
+ next if i[:done]
77
+ info = begin
78
+ Open.open(i[:info_file]) do |f|
79
+ Marshal.load(f)
80
+ end
81
+ rescue
82
+ {:status => :noinfo}
83
+ end
84
+
85
+ pid = info[:pid]
86
+
87
+ status = info[:status]
88
+ status = :missing if status == :done and not File.exists? file
89
+ status = :dead if status != "done" and pid and not Misc.pid_exists?(pid)
90
+
91
+ status = status.to_s
92
+ puts " Removing #{ file } - #{status}"
93
+ Step.clean(file) if status =~ /\berror$/ or status =~ /\bmissing$/ or status =~ /\baborted$/ or status =~ /\bdead$/ or status == ""
95
94
  end
96
95
 
@@ -11,13 +11,18 @@ options = SOPT.setup <<EOF
11
11
 
12
12
  Report the status of the system
13
13
 
14
- $ rbbt system status
14
+ $ rbbt system status <workflow> <task>
15
15
 
16
16
  -a--all Print all jobs, not only uncompleted
17
17
  -h--help Print this help
18
18
  EOF
19
19
  rbbt_usage and exit 0 if options[:help]
20
20
 
21
+ workflow, task = ARGV
22
+
23
+ workflow = workflow.split "," if workflow
24
+ task = task.split "," if task
25
+
21
26
  all = options.delete :all
22
27
 
23
28
  def pid_msg(pid)
@@ -27,15 +32,15 @@ def pid_msg(pid)
27
32
  :red
28
33
  end
29
34
  if pid.nil?
30
- Log.color(:yellow, "missing")
35
+ ""
31
36
  else
32
37
  Log.color(color, pid)
33
38
  end
34
39
  end
35
40
 
36
41
  def status_msg(status)
37
- color = case status
38
- when :error, :aborted, :missing
42
+ color = case status.to_sym
43
+ when :error, :aborted, :missing, :dead
39
44
  :red
40
45
  when :streaming, :started
41
46
  :yellow
@@ -54,37 +59,33 @@ end
54
59
  puts Log.color(:magenta, "# System report")
55
60
  puts
56
61
 
57
- locks = Rbbt.locks
62
+ locks = Rbbt.lock_info
58
63
  if locks.any?
59
64
  puts Log.color(:magenta, "Locks:")
60
- locks.sort_by{|f| File.exists?(f) ? File.ctime(f) : Time.now}.each do |lock|
61
- next unless File.exists?(lock)
62
- pid, ppid, time = Rbbt.load_lock(lock)
63
- time = File.exists?(lock) ? File.ctime(lock) : Time.now
64
- puts " " << lock + Log.color(:blue, " -- time: #{Misc.format_seconds(Time.now - time)}; ppid: #{ppid}; pid: #{pid_msg pid}")
65
+ locks.sort_by{|f,i| i[:ctime] }.each do |file,info|
66
+ elapsed, pid, ppid = info.values_at :elapsed, :pid, :ppid
67
+ puts " " << file + Log.color(:blue, " -- time: #{Misc.format_seconds elapsed}; ppid: #{ppid}; pid: #{pid_msg pid}")
65
68
  end
66
69
  puts
67
70
  end
68
71
 
69
- persists = Rbbt.persists
72
+
73
+ persists = Rbbt.persist_info
70
74
  if persists.any?
71
75
  puts Log.color(:magenta, "Persist:")
72
- persists.sort_by{|f| File.exists?(f) ? File.ctime(f) : Time.now}.each do |persist|
73
- next unless File.exists?(persist)
74
- time = File.exists?(persist) ? File.ctime(persist) : Time.now
75
- puts " " << persist + Log.color(:blue, " -- time: #{Misc.format_seconds(Time.now - time)})")
76
+ persists.sort_by{|f,i| i[:ctime] }.each do |file,info|
77
+ elapsed = info[:elapsed]
78
+ puts " " << file + Log.color(:blue, " -- time: #{Misc.format_seconds elapsed}")
76
79
  end
77
80
  puts
78
81
  end
79
82
 
80
- sensiblewrites = Rbbt.sensiblewrites
83
+ sensiblewrites = Rbbt.sensiblewrite_info
81
84
  if sensiblewrites.any?
82
85
  puts Log.color(:magenta, "Writing:")
83
- sensiblewrites.sort_by{|f| File.exists?(f) ? File.ctime(f) : Time.now}.each do |sensiblewrite|
84
- next unless File.exists?(sensiblewrite)
85
- pid, ppid, time = Rbbt.load_lock(sensiblewrite + '.lock')
86
- time = File.exists?(sensiblewrite) ? File.ctime(sensiblewrite) : Time.now
87
- puts " " << sensiblewrite + Log.color(:blue, " -- time: #{Misc.format_seconds(Time.now - time)}; ppid: #{ppid}; pid: #{pid_msg pid}")
86
+ sensiblewrites.sort_by{|f,i| i[:ctime] }.each do |file,info|
87
+ elapsed = info[:elapsed]
88
+ puts " " << file + Log.color(:blue, " -- time: #{Misc.format_seconds elapsed}")
88
89
  end
89
90
  puts
90
91
  end
@@ -92,26 +93,44 @@ end
92
93
 
93
94
  puts Log.color(:magenta, "# Workflows")
94
95
 
95
- jobs = Rbbt.jobs
96
- jobs.each do |workflow, tasks|
97
- tasks.each do |task, jobs|
98
- done = []
99
- other = {}
100
- jobs.each do |file,h|
101
- status = h[:status]
102
- if h[:status] == :done
103
- done << file
104
- else
105
- other[status||"missing"] ||= []
106
- other[status||"missing"] << [file, h[:pid]]
107
- end
96
+ jobs = Rbbt.job_info workflow, task
97
+ workflows = {}
98
+
99
+ jobs.each do |file,info|
100
+ next unless all or not info[:done]
101
+ workflow = info[:workflow]
102
+ task = info[:task]
103
+ workflows[workflow] ||= {}
104
+ workflows[workflow][task] ||= {}
105
+ workflows[workflow][task][file] ||= info
106
+ end
107
+
108
+ workflows.sort.each do |workflow,tasks|
109
+ tasks.sort.each do |task,jobs|
110
+ puts "* " << Log.color(:magenta, workflow) << "#" << Log.color(:yellow, task) << ": " << Log.color(:blue, jobs.length.to_s)
111
+
112
+ files_txt = jobs.collect do |file, i|
113
+ info = begin
114
+ Open.open(i[:info_file]) do |f|
115
+ Marshal.load(f)
116
+ end
117
+ rescue
118
+ Log.exception $!
119
+ {:status => :noinfo}
120
+ end
121
+
122
+ pid = info[:pid]
123
+ status = info[:status]
124
+ status = :missing if status == :done and not File.exists? file
125
+ status = status.to_s
126
+ status << Log.color(:red, " (dead)") if status != "done" and pid and not Misc.pid_exists?(pid)
127
+ str = file.dup
128
+ str << " #{ status_msg status }"
129
+ str << "; #{pid_msg pid}" unless status == "done"
130
+ str
108
131
  end
109
- next if not all and other.empty?
110
- puts "* " << Log.color(:magenta, workflow) << "#" << Log.color(:cyan, task) << ": " << Log.color(:blue, done.length.to_s) << " done"
111
- other.each do |status, list|
112
- files_txt = list.collect{|f,p| p.nil? ? f : (f + " (#{pid_msg p})") }
113
- puts " " << status_msg(status) << ": " << (files_txt * ", ")
132
+ files_txt.each do |f|
133
+ puts " " << f
114
134
  end
115
135
  end
116
136
  end
117
-
@@ -53,7 +53,7 @@ else
53
53
  puts " - #{Log.color :cyan, i + 1}: " << Log.color(:yellow, f)
54
54
  end
55
55
  end
56
- puts "Rows: #{Log.color :blue, `wc -l #{ file }|cut -f 1 -d' '`}" unless Open.remote? file
56
+ puts "Rows: #{Log.color :blue, `wc -l '#{ file }'|cut -f 1 -d' '`}" unless Open.remote? file
57
57
  parts = []
58
58
  header.first_line.split(header.sep).each_with_index{|p,i| parts << (Log.color(:cyan, "(#{i}) ") << p.strip) }
59
59
  puts parts * "\t"
@@ -0,0 +1,13 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'test_helper.rb')
2
+ require 'rbbt/monitor'
3
+
4
+ class TestMonitor < Test::Unit::TestCase
5
+ def _test_locks
6
+ end
7
+ end
8
+
9
+ if __FILE__ == $0
10
+ jobs = Rbbt.jobs("Structure", "annotate")
11
+
12
+ end
13
+
@@ -6,7 +6,7 @@ class StopException < StandardError; end
6
6
 
7
7
  class TestTSVParallelThrough < Test::Unit::TestCase
8
8
 
9
- def test_traverse_tsv
9
+ def _test_traverse_tsv
10
10
  require 'rbbt/sources/organism'
11
11
 
12
12
  head = 100
@@ -25,7 +25,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
25
25
  assert_equal head, res.keys.compact.sort.length
26
26
  end
27
27
 
28
- def test_traverse_tsv_cpus
28
+ def _test_traverse_tsv_cpus
29
29
  require 'rbbt/sources/organism'
30
30
 
31
31
  head = 100
@@ -47,7 +47,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
47
47
  assert res.values.compact.flatten.uniq.length > 0
48
48
  end
49
49
 
50
- def test_traverse_stream
50
+ def _test_traverse_stream
51
51
  require 'rbbt/sources/organism'
52
52
 
53
53
  head = 1000
@@ -61,7 +61,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
61
61
  assert_equal head, res.keys.compact.sort.length
62
62
  end
63
63
 
64
- def test_traverse_stream_cpus
64
+ def _test_traverse_stream_cpus
65
65
  require 'rbbt/sources/organism'
66
66
 
67
67
  head = 1000
@@ -75,7 +75,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
75
75
  assert_equal head, res.keys.compact.sort.length
76
76
  end
77
77
 
78
- def test_traverse_stream_keys
78
+ def _test_traverse_stream_keys
79
79
  require 'rbbt/sources/organism'
80
80
 
81
81
  head = 1000
@@ -99,7 +99,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
99
99
  assert_equal res.sort, Organism.identifiers("Hsa").tsv(:head => head).keys.sort
100
100
  end
101
101
 
102
- def test_traverse_array
102
+ def _test_traverse_array
103
103
  require 'rbbt/sources/organism'
104
104
 
105
105
  array = []
@@ -121,7 +121,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
121
121
  assert_equal array, res
122
122
  end
123
123
 
124
- def test_traverse_array_threads
124
+ def _test_traverse_array_threads
125
125
  require 'rbbt/sources/organism'
126
126
 
127
127
  array = []
@@ -142,7 +142,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
142
142
  assert_equal array.sort, res.sort
143
143
  end
144
144
 
145
- def test_traverse_array_cpus
145
+ def _test_traverse_array_cpus
146
146
  require 'rbbt/sources/organism'
147
147
 
148
148
  array = []
@@ -157,7 +157,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
157
157
  assert_equal array.sort, res.sort
158
158
  end
159
159
 
160
- def test_traverse_benchmark
160
+ def _test_traverse_benchmark
161
161
  require 'rbbt/sources/organism'
162
162
 
163
163
  head = 2_000
@@ -179,7 +179,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
179
179
  end
180
180
  end
181
181
 
182
- def test_traverse_into_dumper
182
+ def _test_traverse_into_dumper
183
183
  require 'rbbt/sources/organism'
184
184
 
185
185
  head = 2_000
@@ -197,7 +197,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
197
197
  assert_equal head, res.size
198
198
  end
199
199
 
200
- def test_traverse_into_dumper_threads
200
+ def _test_traverse_into_dumper_threads
201
201
  require 'rbbt/sources/organism'
202
202
 
203
203
  head = 2_000
@@ -217,7 +217,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
217
217
  assert_equal head, res.size
218
218
  end
219
219
 
220
- def test_traverse_into_dumper_cpus
220
+ def _test_traverse_into_dumper_cpus
221
221
  require 'rbbt/sources/organism'
222
222
 
223
223
  head = 2_000
@@ -238,7 +238,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
238
238
 
239
239
  #{{{ TRAVERSE DUMPER
240
240
 
241
- def test_traverse_dumper
241
+ def _test_traverse_dumper
242
242
  require 'rbbt/sources/organism'
243
243
 
244
244
  head = 2_000
@@ -259,14 +259,16 @@ class TestTSVParallelThrough < Test::Unit::TestCase
259
259
  assert_equal head, res.size
260
260
  end
261
261
 
262
- def test_traverse_dumper_threads
262
+ def _test_traverse_dumper_threads
263
263
  require 'rbbt/sources/organism'
264
264
 
265
265
  head = 2_000
266
266
  threads = 3
267
267
 
268
268
  tsv = TSV::Parser.new Organism.identifiers("Hsa").open, :head => head
269
+
269
270
  dumper = TSV::Dumper.new tsv.options
271
+ dumper.init
270
272
 
271
273
  TSV.traverse tsv, :head => head, :threads => threads, :into => dumper do |k,v|
272
274
  k = k.first
@@ -281,7 +283,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
281
283
  assert_equal head, res.size
282
284
  end
283
285
 
284
- def test_traverse_dumper_cpus
286
+ def _test_traverse_dumper_cpus
285
287
  require 'rbbt/sources/organism'
286
288
 
287
289
  head = 10_000
@@ -303,6 +305,26 @@ class TestTSVParallelThrough < Test::Unit::TestCase
303
305
  assert_equal head, res.size
304
306
  end
305
307
 
308
+ def _test_traverse_dumper_exception
309
+ require 'rbbt/sources/organism'
310
+
311
+ head = 2_000
312
+
313
+ Log.info Log.color :red, "TRAVERSE EXCEPTION"
314
+ stream = Organism.identifiers("Hsa/jun2011").open
315
+ dumper = TSV::Dumper.new Organism.identifiers("Hsa/jun2011").tsv_options
316
+ dumper.init
317
+
318
+ assert_raise StopException do
319
+ TSV.traverse stream, :head => head, :into => dumper do |k,v|
320
+ k = k.first
321
+ raise StopException if rand(100) < 20
322
+ [k,v]
323
+ end
324
+ dumper.stream.join
325
+ end
326
+ end
327
+
306
328
  def test_traverse_dumper_cpus_exception
307
329
  require 'rbbt/sources/organism'
308
330
 
@@ -314,17 +336,17 @@ class TestTSVParallelThrough < Test::Unit::TestCase
314
336
  dumper = TSV::Dumper.new Organism.identifiers("Hsa/jun2011").tsv_options
315
337
  dumper.init
316
338
 
317
- assert_raise StopException do
318
- TSV.traverse stream, :head => head, :_cpus => cpus, :into => dumper do |k,v|
339
+ assert_raise ProcessFailed do
340
+ TSV.traverse stream, :head => head, :cpus => cpus, :into => dumper do |k,v|
319
341
  k = k.first
320
- raise StopException if rand(100) < 1
342
+ raise StopException if rand(100) < 20
321
343
  [k,v]
322
344
  end
323
- Misc.consume_stream dumper.stream
345
+ dumper.stream.join
324
346
  end
325
347
  end
326
348
 
327
- def test_traverse_into_stream
349
+ def _test_traverse_into_stream
328
350
  size = 100
329
351
  array = (1..size).to_a.collect{|n| n.to_s}
330
352
  stream = TSV.traverse array, :into => :stream do |e|
@@ -333,7 +355,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
333
355
  assert_equal size, stream.read.split("\n").length
334
356
  end
335
357
 
336
- def test_traverse_progress
358
+ def _test_traverse_progress
337
359
  size = 1000
338
360
  array = (1..size).to_a.collect{|n| n.to_s}
339
361
  stream = TSV.traverse array, :bar => {:max => size, :desc => "Array"}, :cpus => 5, :into => :stream do |e|
@@ -367,7 +389,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
367
389
  assert_equal size, stream.read.split("\n").length
368
390
  end
369
391
 
370
- def test_store_multiple
392
+ def _test_store_multiple
371
393
  size = 1000
372
394
  array = (1..size).to_a.collect{|n| n.to_s}
373
395
  stream = TSV.traverse array, :bar => {:max => size, :desc => "Array"}, :cpus => 5, :into => :stream do |e|
@@ -6,6 +6,16 @@ require 'rbbt/entity'
6
6
 
7
7
  class TestMisc < Test::Unit::TestCase
8
8
 
9
+ def test_object_delta
10
+ a = []
11
+ b = nil
12
+ d = Misc.object_delta(String) do
13
+ a << rand.to_s
14
+ end
15
+ assert_equal 1, a.length
16
+ assert_match /^0\.\d+$/, a.first
17
+ end
18
+
9
19
  def test_format_seconds
10
20
  t = 61.3232
11
21
  assert_equal "00:01:01", Misc.format_seconds(t)
@@ -132,5 +132,21 @@ class TestOpen < Test::Unit::TestCase
132
132
  end
133
133
  end
134
134
 
135
+ def test_repo_dir
136
+ TmpFile.with_file do |tmpdir|
137
+ tmpdir = "/home/mvazquezg/tmp/repo_dir"
138
+ repo = File.join(tmpdir, 'repo')
139
+
140
+ Open.repository_dirs.push(repo)
141
+
142
+ obj = { :a => "???a"}
143
+ filename = "file" << (rand * 100).to_i.to_s
144
+ Open.write(File.join(repo, filename), Marshal.dump(obj))
145
+ dump = Open.read(File.join(repo, filename))
146
+ obj_cp = Marshal.load(dump)
147
+ assert_equal obj, obj_cp
148
+ end
149
+ end
150
+
135
151
  end
136
152