scout-gear 9.0.0 → 10.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +3 -3
  3. data/Rakefile +1 -2
  4. data/VERSION +1 -1
  5. data/bin/scout +0 -1
  6. data/lib/rbbt-scout.rb +2 -1
  7. data/lib/scout/offsite/exceptions.rb +9 -0
  8. data/lib/scout/offsite/ssh.rb +1 -0
  9. data/lib/scout/semaphore.rb +2 -0
  10. data/lib/scout/tsv/dumper.rb +1 -0
  11. data/lib/scout/tsv/open.rb +8 -2
  12. data/lib/scout/tsv/parser.rb +1 -1
  13. data/lib/scout/tsv/persist/adapter.rb +2 -2
  14. data/lib/scout/tsv/persist.rb +1 -0
  15. data/lib/scout/tsv/util.rb +1 -1
  16. data/lib/scout/tsv.rb +1 -1
  17. data/lib/scout/work_queue/exceptions.rb +18 -0
  18. data/lib/scout/work_queue.rb +1 -0
  19. data/lib/scout/workflow/definition.rb +1 -1
  20. data/lib/scout/workflow/step/config.rb +1 -1
  21. data/lib/scout/workflow/step/dependencies.rb +3 -2
  22. data/lib/scout/workflow/step/file.rb +5 -1
  23. data/lib/scout/workflow/step/info.rb +8 -2
  24. data/lib/scout/workflow/step/provenance.rb +28 -10
  25. data/lib/scout/workflow/step/status.rb +4 -0
  26. data/lib/scout/workflow/step.rb +18 -6
  27. data/lib/scout/workflow/task/dependencies.rb +1 -0
  28. data/lib/scout/workflow/task/inputs.rb +6 -1
  29. data/lib/scout/workflow/task.rb +22 -3
  30. data/lib/scout/workflow/usage.rb +1 -0
  31. data/lib/scout/workflow.rb +13 -4
  32. data/lib/scout-gear.rb +1 -10
  33. data/scout-gear.gemspec +8 -98
  34. data/scout_commands/workflow/task +2 -3
  35. data/test/scout/workflow/step/test_provenance.rb +24 -1
  36. data/test/scout/workflow/task/test_inputs.rb +0 -4
  37. metadata +7 -110
  38. data/lib/scout/cmd.rb +0 -347
  39. data/lib/scout/concurrent_stream.rb +0 -284
  40. data/lib/scout/config.rb +0 -168
  41. data/lib/scout/exceptions.rb +0 -151
  42. data/lib/scout/indiferent_hash/case_insensitive.rb +0 -30
  43. data/lib/scout/indiferent_hash/options.rb +0 -115
  44. data/lib/scout/indiferent_hash.rb +0 -96
  45. data/lib/scout/log/color.rb +0 -224
  46. data/lib/scout/log/color_class.rb +0 -269
  47. data/lib/scout/log/fingerprint.rb +0 -69
  48. data/lib/scout/log/progress/report.rb +0 -244
  49. data/lib/scout/log/progress/util.rb +0 -173
  50. data/lib/scout/log/progress.rb +0 -106
  51. data/lib/scout/log/trap.rb +0 -107
  52. data/lib/scout/log.rb +0 -441
  53. data/lib/scout/meta_extension.rb +0 -100
  54. data/lib/scout/misc/digest.rb +0 -63
  55. data/lib/scout/misc/filesystem.rb +0 -25
  56. data/lib/scout/misc/format.rb +0 -255
  57. data/lib/scout/misc/helper.rb +0 -31
  58. data/lib/scout/misc/insist.rb +0 -56
  59. data/lib/scout/misc/monitor.rb +0 -66
  60. data/lib/scout/misc/system.rb +0 -73
  61. data/lib/scout/misc.rb +0 -10
  62. data/lib/scout/named_array.rb +0 -138
  63. data/lib/scout/open/lock/lockfile.rb +0 -587
  64. data/lib/scout/open/lock.rb +0 -68
  65. data/lib/scout/open/remote.rb +0 -135
  66. data/lib/scout/open/stream.rb +0 -491
  67. data/lib/scout/open/util.rb +0 -244
  68. data/lib/scout/open.rb +0 -170
  69. data/lib/scout/path/find.rb +0 -204
  70. data/lib/scout/path/tmpfile.rb +0 -8
  71. data/lib/scout/path/util.rb +0 -107
  72. data/lib/scout/path.rb +0 -51
  73. data/lib/scout/persist/open.rb +0 -17
  74. data/lib/scout/persist/path.rb +0 -15
  75. data/lib/scout/persist/serialize.rb +0 -157
  76. data/lib/scout/persist.rb +0 -104
  77. data/lib/scout/resource/open.rb +0 -8
  78. data/lib/scout/resource/path.rb +0 -80
  79. data/lib/scout/resource/produce/rake.rb +0 -69
  80. data/lib/scout/resource/produce.rb +0 -151
  81. data/lib/scout/resource/scout.rb +0 -3
  82. data/lib/scout/resource/software.rb +0 -178
  83. data/lib/scout/resource/util.rb +0 -55
  84. data/lib/scout/resource.rb +0 -41
  85. data/lib/scout/simple_opt/accessor.rb +0 -54
  86. data/lib/scout/simple_opt/doc.rb +0 -126
  87. data/lib/scout/simple_opt/get.rb +0 -57
  88. data/lib/scout/simple_opt/parse.rb +0 -67
  89. data/lib/scout/simple_opt/setup.rb +0 -26
  90. data/lib/scout/simple_opt.rb +0 -5
  91. data/lib/scout/tmpfile.rb +0 -129
  92. data/test/scout/indiferent_hash/test_case_insensitive.rb +0 -16
  93. data/test/scout/indiferent_hash/test_options.rb +0 -46
  94. data/test/scout/log/test_progress.rb +0 -108
  95. data/test/scout/misc/test_digest.rb +0 -30
  96. data/test/scout/misc/test_filesystem.rb +0 -30
  97. data/test/scout/misc/test_insist.rb +0 -13
  98. data/test/scout/misc/test_system.rb +0 -21
  99. data/test/scout/open/test_lock.rb +0 -52
  100. data/test/scout/open/test_remote.rb +0 -25
  101. data/test/scout/open/test_stream.rb +0 -676
  102. data/test/scout/open/test_util.rb +0 -73
  103. data/test/scout/path/test_find.rb +0 -119
  104. data/test/scout/path/test_util.rb +0 -22
  105. data/test/scout/persist/test_open.rb +0 -37
  106. data/test/scout/persist/test_path.rb +0 -37
  107. data/test/scout/persist/test_serialize.rb +0 -114
  108. data/test/scout/resource/test_path.rb +0 -46
  109. data/test/scout/resource/test_produce.rb +0 -77
  110. data/test/scout/resource/test_software.rb +0 -24
  111. data/test/scout/resource/test_util.rb +0 -27
  112. data/test/scout/simple_opt/test_doc.rb +0 -16
  113. data/test/scout/simple_opt/test_get.rb +0 -11
  114. data/test/scout/simple_opt/test_parse.rb +0 -10
  115. data/test/scout/simple_opt/test_setup.rb +0 -77
  116. data/test/scout/test_cmd.rb +0 -85
  117. data/test/scout/test_concurrent_stream.rb +0 -29
  118. data/test/scout/test_config.rb +0 -66
  119. data/test/scout/test_indiferent_hash.rb +0 -26
  120. data/test/scout/test_log.rb +0 -32
  121. data/test/scout/test_meta_extension.rb +0 -80
  122. data/test/scout/test_misc.rb +0 -6
  123. data/test/scout/test_named_array.rb +0 -43
  124. data/test/scout/test_open.rb +0 -146
  125. data/test/scout/test_path.rb +0 -54
  126. data/test/scout/test_persist.rb +0 -186
  127. data/test/scout/test_resource.rb +0 -26
  128. data/test/scout/test_tmpfile.rb +0 -53
  129. /data/test/scout/{log/test_color.rb → test_offsite.rb} +0 -0
@@ -1,676 +0,0 @@
1
- require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
- require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
-
4
- require 'scout/path'
5
- require 'scout/open'
6
-
7
- class TestOpenStream < Test::Unit::TestCase
8
- def test_stream
9
- content =<<-EOF
10
- 1
11
- 2
12
- 3
13
- 4
14
- EOF
15
- TmpFile.with_file(content) do |file|
16
- TmpFile.with_file do |target|
17
- f = File.open(file)
18
- Open.consume_stream(f, false, target)
19
- assert_equal content, File.open(target).read
20
- end
21
- end
22
- end
23
-
24
- def test_sensible_write
25
- content =<<-EOF
26
- 1
27
- 2
28
- 3
29
- 4
30
- EOF
31
- TmpFile.with_file(content) do |file|
32
- TmpFile.with_file do |target|
33
- f = File.open(file)
34
- Open.sensible_write(target, f)
35
- assert_equal content, File.open(target).read
36
- end
37
- end
38
- end
39
-
40
- def test_open_pipe
41
- sout = Open.open_pipe do |sin|
42
- 10.times do |i|
43
- sin.puts "line #{i}"
44
- end
45
- end
46
-
47
- TmpFile.with_file do |tmp|
48
- Open.consume_stream(sout, false, tmp)
49
- assert_equal 10, Open.read(tmp).split("\n").length
50
- end
51
- end
52
-
53
- def test_open_pipe_and_close
54
-
55
- 10000.times do
56
- sout = Open.open_pipe do |sin|
57
- sin.puts "hola"
58
- end
59
- sout.read
60
- sout.close
61
- end
62
- end
63
-
64
-
65
- def test_open_pipe_error
66
- sout = Open.open_pipe do |sin|
67
- 10.times do |i|
68
- sin.puts "line #{i}"
69
- end
70
- raise ScoutException
71
- end
72
-
73
- TmpFile.with_file do |tmp|
74
- assert_raise ScoutException do
75
- Open.consume_stream(sout, false, tmp)
76
- end
77
- end
78
- end
79
-
80
- def test_tee_stream
81
- num = 2000
82
- sout = Open.open_pipe do |sin|
83
- num.times do |i|
84
- sin.puts "line #{i} - #{rand(100000).to_s * 100}"
85
- end
86
- end
87
-
88
- TmpFile.with_file do |tmp|
89
- Path.setup tmp
90
-
91
- s1, s2 = Open.tee_stream_thread sout
92
-
93
- t1 = Open.consume_stream(s1, true, tmp.file1)
94
- t2 = Open.consume_stream(s2, true, tmp.file2)
95
- t1.join
96
- t2.join
97
- assert_equal num, Open.read(tmp.file1).split("\n").length
98
- assert_equal num, Open.read(tmp.file2).split("\n").length
99
- end
100
- end
101
-
102
- def test_tee_stream_multiple
103
- num = 2000
104
- sout = Open.open_pipe do |sin|
105
- num.times do |i|
106
- sin.puts "line #{i} - #{rand(100000).to_s * 100}"
107
- end
108
- end
109
-
110
- TmpFile.with_file do |tmp|
111
- Path.setup tmp
112
-
113
- s1, s2, s3 = Open.tee_stream_thread_multiple sout, 3
114
-
115
- t1 = Open.consume_stream(s1, true, tmp.file1)
116
- t2 = Open.consume_stream(s2, true, tmp.file2)
117
- t3 = Open.consume_stream(s3, true, tmp.file3)
118
- t1.join
119
- t2.join
120
- t3.join
121
- assert_equal num, Open.read(tmp.file1).split("\n").length
122
- assert_equal num, Open.read(tmp.file2).split("\n").length
123
- assert_equal num, Open.read(tmp.file3).split("\n").length
124
- end
125
- end
126
-
127
-
128
- def test_tee_stream_source_error
129
- 5.times do |i|
130
- num = 2000
131
- sout = Open.open_pipe do |sin|
132
- num.times do |i|
133
- sin.puts "line #{i} - #{rand(100000).to_s * 100}"
134
- end
135
- raise ScoutException
136
- end
137
-
138
- TmpFile.with_file do |tmp|
139
- Path.setup tmp
140
-
141
- s1, s2 = Open.tee_stream_thread sout
142
-
143
- t1 = Open.consume_stream(s1, true, tmp.file1)
144
- t2 = Open.consume_stream(s2, true, tmp.file2)
145
- assert_raise ScoutException do
146
- begin
147
- t1.join
148
- t2.join
149
- rescue
150
- raise
151
- ensure
152
- [t1, t2].each do |t|
153
- begin
154
- t.join if t.alive?
155
- rescue ScoutException
156
- end
157
- end
158
- end
159
- end
160
- refute Open.exist?(tmp.file1)
161
- refute Open.exist?(tmp.file2)
162
- end
163
- end
164
- end
165
-
166
- def test_tee_stream_source_error_multiple
167
- 5.times do |i|
168
- num = 2000
169
- sout = Open.open_pipe do |sin|
170
- num.times do |i|
171
- sin.puts "line #{i} - #{rand(100000).to_s * 100}"
172
- end
173
- raise ScoutException
174
- end
175
-
176
- TmpFile.with_file do |tmp|
177
- Path.setup tmp
178
-
179
- s1, s2, s3 = Open.tee_stream_thread_multiple sout, 3
180
-
181
- t1 = Open.consume_stream(s1, true, tmp.file1)
182
- t2 = Open.consume_stream(s2, true, tmp.file2)
183
- t3 = Open.consume_stream(s3, true, tmp.file3)
184
- assert_raise ScoutException do
185
- begin
186
- t1.join
187
- t2.join
188
- t3.join
189
- rescue
190
- raise
191
- ensure
192
- [t1, t2, t2].each do |t|
193
- begin
194
- t.join if t.alive?
195
- rescue ScoutException
196
- end
197
- end
198
- end
199
- end
200
- refute Open.exist?(tmp.file1)
201
- refute Open.exist?(tmp.file2)
202
- refute Open.exist?(tmp.file3)
203
- end
204
- end
205
- end
206
-
207
- def test_tee_stream_save_error
208
- Log.with_severity 6 do
209
- 50.times do |i|
210
- TmpFile.with_file do |tmp|
211
- Path.setup tmp
212
- assert_raise ScoutException do
213
- num = 2000
214
- begin
215
- sout = Open.open_pipe do |sin|
216
- num.times do |i|
217
- sin.puts "line #{i} - #{rand(100000).to_s * 100}"
218
- end
219
- end
220
-
221
- begin
222
- s1, s2 = Open.tee_stream_thread sout
223
-
224
- s2.abort ScoutException.new
225
- t = Open.consume_stream(s1, true, tmp.file)
226
-
227
- t.join
228
- ensure
229
- s1.close if s1.respond_to?(:close) && ! s1.closed?
230
- s1.join if s1.respond_to?(:join) && ! s1.joined?
231
- s2.close if s2.respond_to?(:close) && ! s2.closed?
232
- s2.join if s2.respond_to?(:join) && ! s2.joined?
233
- end
234
- ensure
235
- sout.close if sout.respond_to?(:close) && ! sout.closed?
236
- sout.join if sout.respond_to?(:join) && ! sout.joined?
237
- end
238
- end
239
- refute Open.exist?(tmp.file)
240
- end
241
- end
242
- end
243
- end
244
-
245
- def test_tee_stream_save_error_multiple
246
- Log.with_severity 6 do
247
- 50.times do |i|
248
- TmpFile.with_file do |tmp|
249
- Path.setup tmp
250
- assert_raise ScoutException do
251
- num = 2000
252
- begin
253
- sout = Open.open_pipe do |sin|
254
- num.times do |i|
255
- sin.puts "line #{i} - #{rand(100000).to_s * 100}"
256
- end
257
- end
258
-
259
- begin
260
- s1, s2, s3 = Open.tee_stream_thread_multiple sout, 3
261
-
262
- s2.abort ScoutException.new
263
- t1 = Open.consume_stream(s1, true, tmp.file1)
264
- t2 = Open.consume_stream(s2, true, tmp.file2)
265
-
266
- t1.join
267
- t2.join
268
- ensure
269
- s1.close if s1.respond_to?(:close) && ! s1.closed?
270
- s1.join if s1.respond_to?(:join) && ! s1.joined?
271
- s2.close if s2.respond_to?(:close) && ! s2.closed?
272
- s2.join if s2.respond_to?(:join) && ! s2.joined?
273
- s3.close if s3.respond_to?(:close) && ! s3.closed?
274
- s3.join if s3.respond_to?(:join) && ! s3.joined?
275
- end
276
- ensure
277
- sout.close if sout.respond_to?(:close) && ! sout.closed?
278
- sout.join if sout.respond_to?(:join) && ! sout.joined?
279
- end
280
- end
281
- refute Open.exist?(tmp.file1)
282
- refute Open.exist?(tmp.file2)
283
- end
284
- end
285
- end
286
- end
287
-
288
- def test_sort_stream
289
- text =<<-EOF
290
- ##
291
- ##
292
- ##
293
- #Row LabelA LabelB LabelC
294
- row2 AA BB CC
295
- row3 AAA BBB CCC
296
- row1 A B C
297
- EOF
298
- s = StringIO.new text
299
- sorted = Open.sort_stream(s)
300
- assert_equal %w(## ## ## #Row row2 row3 row1), text.split("\n").collect{|l| l.split(" ").first}
301
- assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
302
- end
303
-
304
- def test_sort_long_stream
305
- text =<<-EOF
306
- ##
307
- ##
308
- ##
309
- #Row LabelA LabelB LabelC
310
- row2 AA BB CC
311
- row3 AAA BBB CCC
312
- row1 A B C
313
- EOF
314
-
315
- s = StringIO.new text + (text.split("\n")[-3..-1] * "\n" + "\n") * 10000
316
- sorted = Open.sort_stream(s)
317
- assert_equal %w(## ## ## #Row row2 row3 row1), text.split("\n").collect{|l| l.split(" ").first}
318
- assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
319
- end
320
-
321
- def test_sort_stream2
322
- text =<<-EOF
323
- ##
324
- ##
325
- ##
326
- #Row LabelA LabelB LabelC
327
- row2 AA BB CC
328
- row3 AAA BBB CCC
329
- row1 A B C
330
- EOF
331
- s = StringIO.new text
332
- sorted = Open.sort_stream(Open.sort_stream(s))
333
- assert_equal %w(## ## ## #Row row2 row3 row1), text.split("\n").collect{|l| l.split(" ").first}
334
- assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
335
- end
336
-
337
- def test_collapse_stream
338
- text=<<-EOF
339
- row1 A B C
340
- row1 a b c
341
- row2 AA BB CC
342
- row2 aa bb cc
343
- EOF
344
-
345
- s = StringIO.new text
346
- stream = Open.collapse_stream(s, sep: " ")
347
- txt = stream.read
348
- assert_include txt, "A|a"
349
- assert_include txt, "B|b"
350
- assert_include txt, "C|c"
351
- end
352
-
353
-
354
- def test_collapse_sum
355
- text=<<-EOF
356
- row1 12
357
- row1 4
358
- row2 10
359
- row2 6
360
- EOF
361
-
362
- s = StringIO.new text
363
- stream = Open.collapse_stream(s, sep: " ") do |parts|
364
- next nil if parts.empty?
365
- parts.first.split("|").collect{|p| p.to_f}.inject(0){|acc,e| acc += e}.to_s
366
- end
367
- assert_include stream.read, "row1 16"
368
- end
369
-
370
-
371
- def test_collapse_stream_gap
372
- text=<<-EOF
373
- row2 AA BB
374
- row2 aa bb cc
375
- EOF
376
-
377
- s = StringIO.new text
378
- assert Open.collapse_stream(s, sep: " ").read =~ /\|cc$/
379
-
380
- text=<<-EOF
381
- row2 aa bb cc
382
- row2 AA BB
383
- EOF
384
-
385
- s = StringIO.new text
386
- assert Open.collapse_stream(s, sep: " ").read =~ /cc\|$/
387
-
388
- text=<<-EOF
389
- row2 AA BB
390
- row2 aa bb cc
391
- EOF
392
-
393
- s = StringIO.new text
394
- assert Open.collapse_stream(s, sep: " ").read =~ /\|cc$/
395
- end
396
- #
397
- #
398
- # def test_paste_stream
399
- # text1=<<-EOF
400
- #row1 A B C
401
- #row2 AA BB CC
402
- #row3 AAA BBB CCC
403
- # EOF
404
- #
405
- # text2=<<-EOF
406
- #row1 a b
407
- #row2 aa bb
408
- # EOF
409
- #
410
- # text3=<<-EOF
411
- #row1 c
412
- #row2 cc
413
- #row3 ccc
414
- # EOF
415
- #
416
- # s1 = StringIO.new text1
417
- # s2 = StringIO.new text2
418
- # s3 = StringIO.new text3
419
- # tsv = TSV.open Misc.paste_streams([s1,s2,s3], nil, " "), :sep => " ", :type => :list
420
- # assert_equal ["A", "B", "C", "a", "b", "c"], tsv["row1"]
421
- # assert_equal ["AA", "BB", "CC", "aa", "bb", "cc"], tsv["row2"]
422
- # assert_equal ["AAA", "BBB", "CCC", "", "", "ccc"], tsv["row3"]
423
- # end
424
- #
425
- # def test_sort_stream
426
- # text =<<-EOF
427
- ###
428
- ###
429
- ###
430
- ##Row LabelA LabelB LabelC
431
- #row2 AA BB CC
432
- #row3 AAA BBB CCC
433
- #row1 A B C
434
- # EOF
435
- # s = StringIO.new text
436
- # sorted = Misc.sort_stream(s)
437
- # assert_equal %w(## ## ## #Row row2 row3 row1), text.split("\n").collect{|l| l.split(" ").first}
438
- # assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
439
- # end
440
- #
441
- # def test_sort_long_stream
442
- # text =<<-EOF
443
- ###
444
- ###
445
- ###
446
- ##Row LabelA LabelB LabelC
447
- #row2 AA BB CC
448
- #row3 AAA BBB CCC
449
- #row1 A B C
450
- # EOF
451
- #
452
- # s = StringIO.new text + (text.split("\n")[-3..-1] * "\n" + "\n") * 10000
453
- # sorted = Misc.sort_stream(s)
454
- # assert_equal %w(## ## ## #Row row2 row3 row1), text.split("\n").collect{|l| l.split(" ").first}
455
- # assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
456
- # end
457
- #
458
- # def test_sort_stream2
459
- # text =<<-EOF
460
- ###
461
- ###
462
- ###
463
- ##Row LabelA LabelB LabelC
464
- #row2 AA BB CC
465
- #row3 AAA BBB CCC
466
- #row1 A B C
467
- # EOF
468
- # s = StringIO.new text
469
- # sorted = Misc.sort_stream(Misc.sort_stream(s))
470
- # assert_equal %w(## ## ## #Row row2 row3 row1), text.split("\n").collect{|l| l.split(" ").first}
471
- # assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
472
- # end
473
- #
474
- # def test_dup_stream
475
- # text =<<-EOF
476
- ##: :sep=" "
477
- ##Row LabelA LabelB LabelC
478
- #row2 AA BB CC
479
- #row3 AAA BBB CCC
480
- #row1 A B C
481
- # EOF
482
- #
483
- # text = text * 10000
484
- # TmpFile.with_file(text) do |tmp|
485
- # io = Open.open(tmp)
486
- # dup = Misc.dup_stream(io)
487
- # new_text = StringIO.new ""
488
- # Misc.consume_stream dup, true, new_text
489
- # Misc.consume_stream io, false
490
- # new_text.rewind
491
- # assert_equal text, new_text.read
492
- # end
493
- #
494
- #
495
- # TmpFile.with_file(text) do |tmp|
496
- # io = Open.open(tmp)
497
- # dup = Misc.dup_stream(io)
498
- # Misc.consume_stream dup, true
499
- # assert_equal text, io.read
500
- # end
501
- # end
502
- #
503
- # def test_dup_stream_multiple
504
- # text =<<-EOF
505
- #row2 AA BB CC
506
- #row3 AAA BBB CCC
507
- #row1 A B C
508
- # EOF
509
- #
510
- # text = text * 10000
511
- # num = 5
512
- # str_io = StringIO.new
513
- # strs = []
514
- # num.times{ strs << StringIO.new }
515
- # TmpFile.with_file(text) do |tmp|
516
- # io = Open.open(tmp)
517
- # copies = Misc.dup_stream_multiple(io, num)
518
- #
519
- #
520
- # copies.each_with_index do |cio,i|
521
- # cio.add_callback do
522
- # str = strs[i]
523
- # str.rewind
524
- # assert_equal text, str.read
525
- # end
526
- # Misc.consume_stream cio, true, strs[i], false
527
- # end
528
- #
529
- #
530
- # Misc.consume_stream io, false, str_io, false
531
- # str_io.rewind
532
- # assert_equal text, str_io.read
533
- #
534
- # end
535
- # end
536
- #
537
- # def test_remove_lines
538
- # text1 =<<-EOF
539
- #line1
540
- #line2
541
- #line3
542
- #line4
543
- # EOF
544
- # text2 =<<-EOF
545
- #line3
546
- #line1
547
- # EOF
548
- #
549
- # TmpFile.with_file(text1) do |file1|
550
- # TmpFile.with_file(text2) do |file2|
551
- # assert ! Misc.remove_lines(file1, file2, true).read.split("\n").include?("line1")
552
- # assert Misc.remove_lines(file1, file2, true).read.split("\n").include?("line2")
553
- # end
554
- # end
555
- # end
556
- #
557
- #
558
- #
559
- # def test_select_lines
560
- # text1 =<<-EOF
561
- #line1
562
- #line2
563
- #line3
564
- #line4
565
- # EOF
566
- # text2 =<<-EOF
567
- #line3
568
- #line1
569
- #line5
570
- # EOF
571
- #
572
- # TmpFile.with_file(text1) do |file1|
573
- # TmpFile.with_file(text2) do |file2|
574
- # assert Misc.select_lines(file1, file2, true).read.split("\n").include?("line1")
575
- # assert ! Misc.select_lines(file1, file2, true).read.split("\n").include?("line2")
576
- # end
577
- # end
578
- # end
579
- #
580
- # def test_consume_into_string_io
581
- # text =<<-EOF
582
- #line1
583
- #line2
584
- #line3
585
- #line4
586
- # EOF
587
- #
588
- # TmpFile.with_file(text) do |file|
589
- # out = StringIO.new
590
- # io = Open.open(file)
591
- # Misc.consume_stream(io, false, out, false)
592
- # out.rewind
593
- # assert_equal text, out.read
594
- # end
595
- # end
596
- #
597
- # def test_monitor
598
- # text =<<-EOF
599
- #line1
600
- #line2
601
- #line3
602
- #line4
603
- # EOF
604
- #
605
- # TmpFile.with_file(text) do |file|
606
- # io = Open.open(file)
607
- # lines = Set.new
608
- # io2 = Misc.line_monitor_stream io do |line|
609
- # lines << line
610
- # end
611
- # Misc.consume_stream(io2, false)
612
- # assert_equal text, lines.to_a * ""
613
- # end
614
- # end
615
- #
616
- # def test_sort
617
- # assert_raise RbbtException do
618
- # io = Misc.open_pipe do |sin|
619
- # sin.puts "#START"
620
- # 20.times do
621
- # sin.puts rand(1000).to_s
622
- # sleep 0.1
623
- # end
624
- # raise RbbtException
625
- # end
626
- #
627
- # sio = Misc.sort_stream(io)
628
- # begin
629
- # Misc.consume_stream(sio, false, STDOUT)
630
- # rescue
631
- # raise $!
632
- # end
633
- # end
634
- # end
635
- #
636
- # def test_gz_pipe
637
- # text =<<-EOF
638
- #line1
639
- #line2
640
- #line3
641
- #line4
642
- # EOF
643
- #
644
- # TmpFile.with_file nil, :extension => 'txt.gz' do |file|
645
- # sout = Misc.open_gz_pipe do |sin|
646
- # text.split("\n").each do |line|
647
- # sin.puts line
648
- # end
649
- # end
650
- #
651
- # Open.mkdir File.basename(file)
652
- # thr1 = Misc.consume_stream(sout, true, file)
653
- # thr1.join
654
- # assert Open.gzip?(file)
655
- # assert_equal text, Open.read(file)
656
- # end
657
- # end
658
- #
659
- # def test_open_pipe_error
660
- # sout = Misc.open_pipe do |sin|
661
- # 10.times do |i|
662
- # sin.puts "line #{i}"
663
- # end
664
- # raise
665
- # end
666
- #
667
- # TmpFile.with_file do |tmp|
668
- # #Misc.consume_stream(sout, false, tmp)
669
- # assert_raise do
670
- # Open.write(tmp, sout)
671
- # end
672
- # end
673
- # end
674
- #end
675
- end
676
-