scout-gear 7.1.0 → 7.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +65 -2
  3. data/VERSION +1 -1
  4. data/bin/scout +5 -1
  5. data/lib/rbbt-scout.rb +5 -0
  6. data/lib/scout/concurrent_stream.rb +13 -8
  7. data/lib/scout/config.rb +168 -0
  8. data/lib/scout/exceptions.rb +5 -3
  9. data/lib/scout/indiferent_hash/options.rb +1 -0
  10. data/lib/scout/indiferent_hash.rb +4 -2
  11. data/lib/scout/log/color.rb +3 -2
  12. data/lib/scout/log/progress/report.rb +1 -0
  13. data/lib/scout/log/progress/util.rb +66 -1
  14. data/lib/scout/log/progress.rb +5 -3
  15. data/lib/scout/log.rb +3 -2
  16. data/lib/scout/misc/helper.rb +31 -0
  17. data/lib/scout/misc/monitor.rb +4 -1
  18. data/lib/scout/misc/system.rb +15 -0
  19. data/lib/scout/misc.rb +2 -0
  20. data/lib/scout/named_array.rb +68 -0
  21. data/lib/scout/open/stream.rb +58 -33
  22. data/lib/scout/path/find.rb +27 -3
  23. data/lib/scout/path/util.rb +7 -4
  24. data/lib/scout/persist/serialize.rb +7 -14
  25. data/lib/scout/persist.rb +46 -12
  26. data/lib/scout/resource/produce.rb +7 -94
  27. data/lib/scout/resource/software.rb +176 -0
  28. data/lib/scout/semaphore.rb +8 -1
  29. data/lib/scout/tsv/dumper.rb +112 -0
  30. data/lib/scout/tsv/index.rb +161 -0
  31. data/lib/scout/tsv/open.rb +128 -0
  32. data/lib/scout/tsv/parser.rb +230 -30
  33. data/lib/scout/tsv/path.rb +13 -0
  34. data/lib/scout/tsv/persist/adapter.rb +367 -0
  35. data/lib/scout/tsv/persist/fix_width_table.rb +324 -0
  36. data/lib/scout/tsv/persist/serialize.rb +117 -0
  37. data/lib/scout/tsv/persist/tokyocabinet.rb +113 -0
  38. data/lib/scout/tsv/persist.rb +13 -0
  39. data/lib/scout/tsv/traverse.rb +143 -0
  40. data/lib/scout/tsv/util/filter.rb +303 -0
  41. data/lib/scout/tsv/util/process.rb +73 -0
  42. data/lib/scout/tsv/util/select.rb +220 -0
  43. data/lib/scout/tsv/util.rb +82 -0
  44. data/lib/scout/tsv.rb +16 -3
  45. data/lib/scout/work_queue/worker.rb +4 -4
  46. data/lib/scout/work_queue.rb +22 -7
  47. data/lib/scout/workflow/definition.rb +101 -4
  48. data/lib/scout/workflow/step/config.rb +18 -0
  49. data/lib/scout/workflow/step/dependencies.rb +40 -0
  50. data/lib/scout/workflow/step/file.rb +15 -0
  51. data/lib/scout/workflow/step/info.rb +35 -4
  52. data/lib/scout/workflow/step/progress.rb +14 -0
  53. data/lib/scout/workflow/step/provenance.rb +148 -0
  54. data/lib/scout/workflow/step.rb +71 -17
  55. data/lib/scout/workflow/task.rb +10 -5
  56. data/lib/scout/workflow/usage.rb +3 -1
  57. data/lib/scout/workflow.rb +11 -3
  58. data/lib/scout-gear.rb +1 -0
  59. data/lib/scout.rb +1 -0
  60. data/scout-gear.gemspec +64 -10
  61. data/scout_commands/find +1 -1
  62. data/scout_commands/workflow/task +16 -9
  63. data/scout_commands/workflow/task_old +2 -2
  64. data/share/software/install_helpers +523 -0
  65. data/test/scout/log/test_progress.rb +0 -2
  66. data/test/scout/misc/test_system.rb +21 -0
  67. data/test/scout/open/test_stream.rb +160 -1
  68. data/test/scout/path/test_find.rb +14 -7
  69. data/test/scout/resource/test_software.rb +24 -0
  70. data/test/scout/test_config.rb +66 -0
  71. data/test/scout/test_meta_extension.rb +10 -0
  72. data/test/scout/test_named_array.rb +19 -0
  73. data/test/scout/test_persist.rb +96 -0
  74. data/test/scout/test_tmpfile.rb +1 -1
  75. data/test/scout/test_tsv.rb +50 -1
  76. data/test/scout/test_work_queue.rb +41 -13
  77. data/test/scout/tsv/persist/test_adapter.rb +44 -0
  78. data/test/scout/tsv/persist/test_fix_width_table.rb +134 -0
  79. data/test/scout/tsv/persist/test_tokyocabinet.rb +92 -0
  80. data/test/scout/tsv/test_dumper.rb +44 -0
  81. data/test/scout/tsv/test_index.rb +156 -0
  82. data/test/scout/tsv/test_open.rb +9 -0
  83. data/test/scout/tsv/test_parser.rb +114 -3
  84. data/test/scout/tsv/test_persist.rb +43 -0
  85. data/test/scout/tsv/test_traverse.rb +116 -0
  86. data/test/scout/tsv/test_util.rb +23 -0
  87. data/test/scout/tsv/util/test_filter.rb +188 -0
  88. data/test/scout/tsv/util/test_process.rb +47 -0
  89. data/test/scout/tsv/util/test_select.rb +44 -0
  90. data/test/scout/work_queue/test_worker.rb +66 -9
  91. data/test/scout/workflow/step/test_dependencies.rb +25 -0
  92. data/test/scout/workflow/step/test_info.rb +15 -17
  93. data/test/scout/workflow/step/test_load.rb +19 -21
  94. data/test/scout/workflow/step/test_provenance.rb +25 -0
  95. data/test/scout/workflow/test_step.rb +206 -10
  96. data/test/scout/workflow/test_task.rb +0 -3
  97. data/test/test_helper.rb +9 -1
  98. metadata +50 -6
@@ -0,0 +1,116 @@
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/tsv'
5
+
6
+ class TestTSVTraverse < Test::Unit::TestCase
7
+ def test_tsv_traverse_double
8
+ content =<<-'EOF'
9
+ #: :sep=/\s+/#:type=:double
10
+ #Id ValueA ValueB OtherID
11
+ row1 a|aa|aaa b Id1|Id2
12
+ row2 A B Id3
13
+ row2 AA BB Id33
14
+ EOF
15
+
16
+ sss 0
17
+ tsv = TmpFile.with_file(content) do |filename|
18
+ TSV.open(filename, :persist => true)
19
+ end
20
+
21
+ res = {}
22
+ tsv.traverse :key, %w(OtherID ValueB) do |k,v|
23
+ res[k] = v
24
+ end
25
+ assert_equal [%w(Id3 Id33), %w(B BB)], res["row2"]
26
+
27
+ res = {}
28
+ tsv.traverse :key, %w(OtherID ValueB), type: :list do |k,v|
29
+ res[k] = v
30
+ end
31
+ assert_equal ["Id3", "B"], res["row2"]
32
+
33
+ res = {}
34
+ tsv.traverse "OtherID", %w(Id ValueB), one2one: true do |k,v|
35
+ res[k] = v
36
+ end
37
+ assert_equal [[nil], %w(BB)], res["Id33"]
38
+
39
+ res = {}
40
+ tsv.traverse "OtherID", %w(Id ValueB), one2one: true, type: :list do |k,v|
41
+ res[k] = v
42
+ end
43
+ assert_equal ["row2", "B"], res["Id3"]
44
+ assert_equal [nil, "BB"], res["Id33"]
45
+
46
+ tsv.traverse "OtherID", %w(Id ValueB), one2one: false, type: :list do |k,v|
47
+ res[k] = v
48
+ end
49
+ assert_equal ["row2", "B"], res["Id3"]
50
+ assert_equal [nil, "BB"], res["Id33"]
51
+
52
+ res = {}
53
+ key_name, field_names = tsv.traverse "OtherID" do |k,v|
54
+ res[k] = v
55
+ end
56
+ assert_equal "OtherID", key_name
57
+ assert_equal %w(Id ValueA ValueB), field_names
58
+ end
59
+
60
+ def test_tsv_traverse_list
61
+ content =<<-'EOF'
62
+ #: :sep=/\s+/#:type=:list
63
+ #Id ValueA ValueB OtherID
64
+ row1 a b Id1
65
+ row2 A B Id3
66
+ EOF
67
+
68
+ tsv = TmpFile.with_file(content) do |filename|
69
+ TSV.open(filename, :persist => true)
70
+ end
71
+
72
+ res = {}
73
+ tsv.traverse :key, %w(OtherID ValueB) do |k,v|
74
+ res[k] = v
75
+ end
76
+ assert_equal ["Id3", "B"], res["row2"]
77
+
78
+ res = {}
79
+ tsv.traverse :key, %w(OtherID ValueB), type: :double do |k,v|
80
+ res[k] = v
81
+ end
82
+ assert_equal [%w(Id3), %w(B)], res["row2"]
83
+
84
+ res = {}
85
+ tsv.traverse :key, %w(OtherID ValueB), type: :flat do |k,v|
86
+ res[k] = v
87
+ end
88
+ assert_equal %w(Id3 B), res["row2"]
89
+ end
90
+
91
+ def test_tsv_traverse_single
92
+ content =<<-'EOF'
93
+ #: :sep=/\s+/#:type=:single
94
+ #Id ValueA
95
+ row1 a
96
+ row2 A
97
+ EOF
98
+
99
+ tsv = TmpFile.with_file(content) do |filename|
100
+ TSV.open(filename, :persist => true)
101
+ end
102
+
103
+ res = {}
104
+ tsv.traverse "ValueA", %w(Id) do |k,v|
105
+ res[k] = v
106
+ end
107
+ assert_equal "row1", res["a"]
108
+
109
+ res = {}
110
+ tsv.traverse "ValueA", %w(Id), type: :double do |k,v|
111
+ res[k] = v
112
+ end
113
+ assert_equal [["row1"]], res["a"]
114
+ end
115
+ end
116
+
@@ -0,0 +1,23 @@
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/tsv'
5
+ class TestTSVUtil < Test::Unit::TestCase
6
+ def test_open_persist
7
+ content =<<-'EOF'
8
+ #: :sep=/\s+/#:type=:double#:merge=:concat
9
+ #Id ValueA ValueB OtherID
10
+ row1 a|aa|aaa b Id1|Id2
11
+ row2 A B Id3
12
+ row2 a a id3
13
+ EOF
14
+
15
+ tsv = TmpFile.with_file(content) do |filename|
16
+ TSV.open(filename, :sep => " " )
17
+ end
18
+ assert_equal %w(row1 row2), tsv.collect{|k,v| k }
19
+ assert NamedArray === tsv.collect{|k,v| v }.first
20
+ end
21
+
22
+ end
23
+
@@ -0,0 +1,188 @@
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/tsv'
5
+ class TestTSVFilters < Test::Unit::TestCase
6
+ def test_collect
7
+ content1 =<<-EOF
8
+ #: :sep=/\\s+/#:case_insensitive=false
9
+ #Id ValueA ValueB
10
+ row1 a|aa|aaa b
11
+ row2 A B
12
+ EOF
13
+
14
+ TmpFile.with_file(content1) do |filename|
15
+ tsv = TSV.open filename
16
+ assert_equal 2, tsv.collect.size
17
+ tsv.filter
18
+ tsv.add_filter "field:ValueA", ["A"]
19
+ assert_equal 1, tsv.collect.size
20
+ end
21
+ end
22
+
23
+ def test_through
24
+ content1 =<<-EOF
25
+ #: :sep=/\\s+/#:case_insensitive=false
26
+ #Id ValueA ValueB
27
+ row1 a|aa|aaa b
28
+ row2 A B
29
+ EOF
30
+
31
+ TmpFile.with_file(content1) do |filename|
32
+ tsv = TSV.open filename
33
+ tsv.filter
34
+ tsv.add_filter "field:ValueA", ["A"]
35
+ elem = []
36
+ tsv.through do |k,v| elem << k end
37
+ assert_equal 1, elem.size
38
+ end
39
+ end
40
+
41
+ def test_2_filters
42
+ content1 =<<-EOF
43
+ #: :sep=/\\s+/#:case_insensitive=false
44
+ #Id ValueA ValueB
45
+ row1 a|aa|aaa b
46
+ row2 A B
47
+ row3 A C
48
+ EOF
49
+
50
+ TmpFile.with_file(content1) do |filename|
51
+ tsv = TSV.open filename
52
+ tsv.filter
53
+ tsv.add_filter "field:ValueA", ["A"]
54
+
55
+ elem = []
56
+ tsv.through do |k,v| elem << k end
57
+ assert_equal 2, elem.size
58
+ assert_equal ["row2", "row3"], elem.sort
59
+
60
+ tsv.add_filter "field:ValueB", ["C"]
61
+
62
+ elem = []
63
+ tsv.through do |k,v| elem << k end
64
+ assert_equal 1, elem.size
65
+ end
66
+ end
67
+
68
+ def test_filter_persistence
69
+ content1 =<<-EOF
70
+ #: :sep=/\\s+/#:case_insensitive=false
71
+ #Id ValueA ValueB
72
+ row1 a|aa|aaa b
73
+ row2 A B
74
+ row3 A C
75
+ EOF
76
+
77
+ TmpFile.with_file(content1) do |filename|
78
+ tsv = TSV.open filename
79
+ tsv.filter
80
+ tsv.add_filter "field:ValueA", ["A"], tmpdir.fieldValueA.find(:user)
81
+
82
+ elem = []
83
+ tsv.through do |k,v| elem << k end
84
+ assert_equal 2, elem.size
85
+
86
+ tsv.add_filter "field:ValueB", ["C"]
87
+
88
+ elem = []
89
+ tsv.through do |k,v| elem << k end
90
+ assert_equal 1, elem.size
91
+
92
+ tsv = TSV.open filename
93
+ tsv.filter
94
+ tsv.add_filter "field:ValueA", ["A"], tmpdir.fieldValueA.find(:user)
95
+
96
+ elem = []
97
+ tsv.through do |k,v| elem << k end
98
+ assert_equal 2, elem.size
99
+ end
100
+ end
101
+
102
+ def __test_filter_persistence_update
103
+ content1 =<<-EOF
104
+ #: :sep=/\\s+/#:case_insensitive=false
105
+ #Id ValueA ValueB
106
+ row1 a|aa|aaa b
107
+ row2 A B
108
+ EOF
109
+
110
+ TmpFile.with_file(content1) do |filename|
111
+ tsv = TSV.open filename
112
+ tsv.filter
113
+ tsv.add_filter "field:ValueA", ["A"], Scout.tmp.test.Filter.fieldValueA.find(:user)
114
+
115
+ elem = []
116
+ tsv.through do |k,v| elem << k end
117
+ assert_equal 1, elem.size
118
+
119
+ tsv["row3"] = [["A"], ["C"]]
120
+
121
+ elem = []
122
+ tsv.through do |k,v| elem << k end
123
+ assert_equal 2, elem.size
124
+
125
+ tsv.add_filter "field:ValueB", ["C"]
126
+
127
+ elem = []
128
+ tsv.through do |k,v| elem << k end
129
+ assert_equal 1, elem.size
130
+
131
+ tsv = TSV.open filename
132
+ tsv.filter
133
+ tsv.add_filter "field:ValueA", ["A"], Scout.tmp.test.Filter.fieldValueA.find(:user)
134
+
135
+ elem = []
136
+ tsv.through do |k,v| elem << k end
137
+ assert_equal 1, elem.size
138
+ end
139
+ end
140
+
141
+ def test_delete
142
+ content =<<-EOF
143
+ #ID ValueA ValueB Comment
144
+ row1 a b c
145
+ row2 A B C
146
+ EOF
147
+
148
+ TmpFile.with_file(content) do |filename|
149
+ tsv = TSV.open(File.open(filename), type: :double, :sep => /\s/)
150
+ assert_equal 2, tsv.keys.length
151
+ tsv.delete "row2"
152
+ assert_equal 1, tsv.keys.length
153
+
154
+ tsv = TSV.open(File.open(filename), type: :double, :sep => /\s/)
155
+ tsv.filter
156
+ tsv.add_filter "field:ValueA", ["A"]
157
+
158
+ assert_equal 1, tsv.keys.length
159
+ assert_equal ["row2"], tsv.keys
160
+
161
+ tsv.delete "row2"
162
+ assert_equal 0, tsv.keys.length
163
+
164
+ tsv.pop_filter
165
+ assert_equal ["row1"], tsv.keys
166
+ end
167
+ end
168
+
169
+ def test_filename
170
+ content1 =<<-EOF
171
+ #: :sep=/\\s+/#:case_insensitive=false
172
+ #Id ValueA ValueB
173
+ row1 a|aa|aaa b
174
+ row2 A B
175
+ EOF
176
+
177
+ TmpFile.with_file(content1) do |filename|
178
+ tsv = TSV.open filename
179
+ tsv.filter
180
+ tsv.add_filter "field:ValueA", ["A"]
181
+ assert tsv.filename =~ /ValueA/
182
+ tsv.pop_filter
183
+ assert tsv.filename !~ /ValueA/
184
+ end
185
+
186
+ end
187
+ end
188
+
@@ -0,0 +1,47 @@
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/tsv'
5
+ class TestTSVProcess < Test::Unit::TestCase
6
+ def test_process
7
+ content =<<-'EOF'
8
+ #: :sep=/\s+/#:type=:double
9
+ #Id ValueA ValueB OtherID
10
+ row1 a|aa|aaa b Id1|Id2
11
+ row2 A B Id3
12
+ row2 AA BB Id33
13
+ EOF
14
+
15
+ tsv = TmpFile.with_file(content) do |filename|
16
+ TSV.open(filename)
17
+ end
18
+
19
+ tsv.process "ValueA" do |v|
20
+ v.collect{|e| e.upcase }
21
+ end
22
+
23
+ assert_equal %w(A AA AAA), tsv["row1"][0]
24
+ end
25
+
26
+ def test_add_field
27
+ content =<<-'EOF'
28
+ #: :sep=/\s+/#:type=:double
29
+ #Id ValueA ValueB OtherID
30
+ row1 a|aa|aaa b Id1|Id2
31
+ row2 A B Id3
32
+ row2 AA BB Id33
33
+ EOF
34
+
35
+ tsv = TmpFile.with_file(content) do |filename|
36
+ TSV.open(filename)
37
+ end
38
+
39
+ tsv.add_field "ValueC" do |k,v|
40
+ v[0].collect{|e| e.gsub("a", "c").gsub("A", "C") }
41
+ end
42
+
43
+ assert_equal %w(c cc ccc), tsv["row1"]["ValueC"]
44
+ assert_equal %w(C CC), tsv["row2"]["ValueC"]
45
+ end
46
+ end
47
+
@@ -0,0 +1,44 @@
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/tsv'
5
+ class TestTSVSelect < Test::Unit::TestCase
6
+ def test_select
7
+ content =<<-'EOF'
8
+ #: :sep=/\s+/#:type=:double
9
+ #Id ValueA ValueB OtherID
10
+ row1 a|aa|aaa b Id1|Id2
11
+ row2 A B Id3
12
+ row2 AA BB Id33
13
+ EOF
14
+
15
+ tsv = TmpFile.with_file(content) do |filename|
16
+ TSV.open(filename, :persist => true)
17
+ end
18
+
19
+ s = tsv.select do |k,v|
20
+ k.include? "2"
21
+ end
22
+
23
+ assert_equal ['row2'], s.keys
24
+ end
25
+
26
+ def test_reorder
27
+ content =<<-'EOF'
28
+ #: :sep=/\s+/#:type=:double
29
+ #Id ValueA ValueB OtherID
30
+ row1 a1|a2 b1|b2 Id1|Id2
31
+ row2 A1|A3 B1|B3 Id1|Id3
32
+ EOF
33
+
34
+ tsv = TmpFile.with_file(content) do |filename|
35
+ TSV.open(filename)
36
+ end
37
+
38
+ r = tsv.reorder "OtherID", %w(ValueB Id)
39
+
40
+ assert_equal %w(row1 row2), r["Id1"]["Id"]
41
+ assert_equal %w(row2), r["Id3"]["Id"]
42
+ end
43
+ end
44
+
@@ -16,34 +16,91 @@ class TestQueueWorker < Test::Unit::TestCase
16
16
  end
17
17
  end
18
18
 
19
- def test_semaphore
20
- ScoutSemaphore.with_semaphore 1 do |sem|
19
+ def test_semaphore_pipe
20
+
21
+ 2.times do
22
+ num_lines = 10
23
+ num_workers = 100
21
24
 
22
25
  TmpFile.with_file do |outfile|
23
- 2.times do
26
+ Open.rm(outfile)
27
+ ScoutSemaphore.with_semaphore 1 do |sem|
24
28
  sout = Open.open_pipe do |sin|
25
- workers = 100.times.collect{ WorkQueue::Worker.new }
29
+ workers = num_workers.times.collect{ WorkQueue::Worker.new }
26
30
  workers.each do |w|
27
31
  w.run do
28
32
  ScoutSemaphore.synchronize(sem) do
29
- 10.times do
30
- sin.puts Process.pid
33
+ sin.puts "Start - #{Process.pid}"
34
+ num_lines.times do |i|
35
+ sin.puts "line-#{i}-#{Process.pid}"
31
36
  end
37
+ sin.puts "End - #{Process.pid}"
32
38
  end
33
39
  end
34
40
  end
41
+ sin.close
35
42
 
36
43
  WorkQueue::Worker.join(workers)
37
44
  end
45
+
38
46
  Open.consume_stream(sout, false, outfile)
47
+ txt = Open.read(outfile)
48
+ pid_list = txt.split("\n")
49
+
50
+ assert_equal (num_lines + 2) * num_workers, pid_list.length
51
+
52
+ assert_nothing_raised do
53
+ seen = []
54
+ current = nil
55
+ pid_list.each do |pid|
56
+ if pid != current
57
+ raise "Out of order #{Log.fingerprint seen} #{ pid }" if seen.include? pid
58
+ end
59
+ current = pid
60
+ seen << pid
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ def test_semaphore
68
+
69
+ 2.times do
70
+ num_lines = 10
71
+ num_workers = 500
72
+
73
+ TmpFile.with_file do |outfile|
74
+ Open.rm(outfile)
75
+ ScoutSemaphore.with_semaphore 1 do |sem|
76
+ workers = num_workers.times.collect{ WorkQueue::Worker.new }
77
+ Open.touch(outfile)
78
+ workers.each do |w|
79
+ w.run do
80
+ ScoutSemaphore.synchronize(sem) do
81
+ sin = Open.open(outfile, :mode => 'a')
82
+ sin.puts "Start - #{Process.pid}"
83
+ num_lines.times do |i|
84
+ sin.puts "line-#{i}-#{Process.pid}"
85
+ end
86
+ sin.puts "End - #{Process.pid}"
87
+ sin.close
88
+ end
89
+ end
90
+ end
91
+
92
+ WorkQueue::Worker.join(workers)
93
+
94
+
39
95
  pid_list = Open.read(outfile).split("\n")
96
+ assert_equal (num_lines + 2) * num_workers, pid_list.length
40
97
 
41
98
  assert_nothing_raised do
42
99
  seen = []
43
100
  current = nil
44
101
  pid_list.each do |pid|
45
102
  if pid != current
46
- raise "Out of order" if seen.include? pid
103
+ raise "Out of order #{Log.fingerprint seen} #{ pid }" if seen.include? pid
47
104
  end
48
105
  current = pid
49
106
  seen << pid
@@ -113,7 +170,7 @@ class TestQueueWorker < Test::Unit::TestCase
113
170
  while obj = output.read
114
171
  if DoneProcessing === obj
115
172
  pid = obj.pid
116
- workers.delete_if{|w| w.pid = pid }
173
+ @worker_mutex.synchronize{ @workers.delete_if{|w| w.pid = pid } }
117
174
  break if workers.empty?
118
175
  end
119
176
  raise obj if Exception === obj
@@ -134,7 +191,7 @@ class TestQueueWorker < Test::Unit::TestCase
134
191
 
135
192
  write.join
136
193
 
137
- assert_raise ScoutException do
194
+ assert_raise WorkerException do
138
195
  read.join
139
196
  end
140
197
 
@@ -0,0 +1,25 @@
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/named_array'
5
+ class TestStepDependencies < Test::Unit::TestCase
6
+ def test_recursive_inputs
7
+ tmpfile = tmpdir.test_step
8
+ step1 = Step.new tmpfile.step1, NamedArray.setup(["12"], %w(input1)) do |s|
9
+ s.length
10
+ end
11
+
12
+ step2 = Step.new tmpfile.step2, NamedArray.setup([2], %w(input2)) do |times|
13
+ step1 = dependencies.first
14
+ (step1.inputs.first + " has " + step1.load.to_s + " characters") * times
15
+ end
16
+
17
+ step2.dependencies = [step1]
18
+
19
+ assert_equal 2, step2.inputs["input2"]
20
+ assert_equal "12", step2.recursive_inputs["input1"]
21
+ assert_equal 2, step2.inputs[:input2]
22
+ assert_equal "12", step2.recursive_inputs[:input1]
23
+ end
24
+ end
25
+
@@ -4,27 +4,25 @@ require 'scout/workflow'
4
4
 
5
5
  class TestStepInfo < Test::Unit::TestCase
6
6
  def test_dependency
7
- sss 0 do
8
- TmpFile.with_file do |tmpdir|
9
- Path.setup(tmpdir)
10
- tmpfile = tmpdir.test_step
11
- step1 = Step.new tmpfile.step1, ["12"] do |s|
12
- s.length
13
- end
7
+ TmpFile.with_file do |tmpdir|
8
+ Path.setup(tmpdir)
9
+ tmpfile = tmpdir.test_step
10
+ step1 = Step.new tmpfile.step1, ["12"] do |s|
11
+ s.length
12
+ end
14
13
 
15
- assert_equal 2, step1.exec
16
- assert_equal 2, step1.run
14
+ assert_equal 2, step1.exec
15
+ assert_equal 2, step1.run
17
16
 
18
- step2 = Step.new tmpfile.step2 do
19
- step1 = dependencies.first
20
- step1.inputs.first + " has " + step1.load.to_s + " characters"
21
- end
17
+ step2 = Step.new tmpfile.step2 do
18
+ step1 = dependencies.first
19
+ step1.inputs.first + " has " + step1.load.to_s + " characters"
20
+ end
22
21
 
23
- step2.dependencies = [step1]
22
+ step2.dependencies = [step1]
24
23
 
25
- assert_equal "12 has 2 characters", step2.run
26
- assert_equal "12 has 2 characters", step2.run
27
- end
24
+ assert_equal "12 has 2 characters", step2.run
25
+ assert_equal "12 has 2 characters", step2.run
28
26
  end
29
27
  end
30
28
  end
@@ -5,29 +5,27 @@ require 'scout/workflow/step'
5
5
 
6
6
  class TestStepLoad < Test::Unit::TestCase
7
7
  def test_dependency
8
- sss 0 do
9
- tmpfile = tmpdir.test_step
10
- step1 = Step.new tmpfile.step1, ["12"] do |s|
11
- s.length
12
- end
8
+ tmpfile = tmpdir.test_step
9
+ step1 = Step.new tmpfile.step1, ["12"] do |s|
10
+ s.length
11
+ end
13
12
 
14
- step2 = Step.new tmpfile.step2 do
15
- step1 = dependencies.first
16
- step1.inputs.first + " has " + step1.load.to_s + " characters"
17
- end
13
+ step2 = Step.new tmpfile.step2 do
14
+ step1 = dependencies.first
15
+ step1.inputs.first + " has " + step1.load.to_s + " characters"
16
+ end
18
17
 
19
- step2.dependencies = [step1]
18
+ step2.dependencies = [step1]
20
19
 
21
- step2.recursive_clean
22
- step2.run
20
+ step2.recursive_clean
21
+ step2.run
23
22
 
24
- new_step2 = Step.load(step2.path)
23
+ new_step2 = Step.load(step2.path)
25
24
 
26
- assert_equal "12 has 2 characters", new_step2.load
27
- assert_equal "12 has 2 characters", new_step2.run
28
- assert_equal 2, new_step2.dependencies.first.run
29
- assert_equal "12", new_step2.dependencies.first.inputs.first
30
- end
25
+ assert_equal "12 has 2 characters", new_step2.load
26
+ assert_equal "12 has 2 characters", new_step2.run
27
+ assert_equal 2, new_step2.dependencies.first.run
28
+ assert_equal "12", new_step2.dependencies.first.inputs.first
31
29
  end
32
30
 
33
31
  def test_relocate
@@ -43,7 +41,7 @@ class TestStepLoad < Test::Unit::TestCase
43
41
  end
44
42
  end
45
43
 
46
- step2 = wf.job(:step2, :input1 => "TEST")
44
+ step2 = wf.job(:step2, nil, :input1 => "TEST_STRING")
47
45
  step1 = step2.step(:step1)
48
46
 
49
47
  step2.run
@@ -55,8 +53,8 @@ class TestStepLoad < Test::Unit::TestCase
55
53
  Open.mv step1.info_file, dir.var.jobs.RelocateWorkflow.step1[File.basename(step1.info_file)]
56
54
 
57
55
  new_step2 = Step.load(step2.path)
58
- assert_equal "TEST".reverse, new_step2.load
59
- assert_equal "TEST", new_step2.dependencies.first.load
56
+ assert_equal "TEST_STRING".reverse, new_step2.load
57
+ assert_equal "TEST_STRING", new_step2.dependencies.first.load
60
58
  end
61
59
  end
62
60
 
@@ -0,0 +1,25 @@
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/workflow'
5
+ class TestStepProvenance < Test::Unit::TestCase
6
+ def test_true
7
+ tmpfile = tmpdir.test_step
8
+ step1 = Step.new tmpfile.step1, ["12"] do |s|
9
+ s.length
10
+ end
11
+
12
+ step2 = Step.new tmpfile.step2 do
13
+ step1 = dependencies.first
14
+ step1.inputs.first + " has " + step1.load.to_s + " characters"
15
+ end
16
+
17
+ step2.dependencies = [step1]
18
+
19
+ step2.run
20
+
21
+ assert_include Step.prov_report(step2), 'step1'
22
+ assert_include Step.prov_report(step2), 'step2'
23
+ end
24
+ end
25
+