scout-gear 5.1.1 → 6.0.0
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.
- checksums.yaml +4 -4
- data/.vimproject +24 -12
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/bin/scout +2 -0
- data/lib/scout/exceptions.rb +14 -2
- data/lib/scout/log/color.rb +34 -10
- data/lib/scout/log/progress/report.rb +5 -4
- data/lib/scout/meta_extension.rb +4 -2
- data/lib/scout/misc/format.rb +16 -4
- data/lib/scout/misc/monitor.rb +41 -0
- data/lib/scout/misc.rb +1 -0
- data/lib/scout/open/stream.rb +31 -0
- data/lib/scout/path/find.rb +2 -1
- data/lib/scout/path.rb +1 -1
- data/lib/scout/persist/serialize.rb +15 -4
- data/lib/scout/resource/path.rb +5 -0
- data/lib/scout/resource/util.rb +48 -0
- data/lib/scout/resource.rb +2 -0
- data/lib/scout/semaphore.rb +148 -0
- data/lib/scout/simple_opt/doc.rb +26 -2
- data/lib/scout/work_queue/socket.rb +119 -0
- data/lib/scout/work_queue/worker.rb +54 -0
- data/lib/scout/work_queue.rb +86 -0
- data/lib/scout/workflow/definition.rb +8 -2
- data/lib/scout/workflow/documentation.rb +32 -26
- data/lib/scout/workflow/step/info.rb +13 -13
- data/lib/scout/workflow/step/load.rb +18 -0
- data/lib/scout/workflow/step.rb +40 -4
- data/lib/scout/workflow/task/inputs.rb +4 -2
- data/lib/scout/workflow/task.rb +15 -1
- data/lib/scout/workflow/usage.rb +96 -76
- data/lib/scout/workflow.rb +1 -0
- data/scout-gear.gemspec +25 -3
- data/scout_commands/workflow/info +29 -0
- data/scout_commands/workflow/list +27 -0
- data/scout_commands/workflow/task +32 -681
- data/scout_commands/workflow/task_old +706 -0
- data/share/color/color_names +507 -0
- data/share/color/diverging_colors.hex +12 -0
- data/test/scout/log/test_color.rb +0 -0
- data/test/scout/resource/test_util.rb +27 -0
- data/test/scout/simple_opt/test_doc.rb +16 -0
- data/test/scout/test_meta_extension.rb +9 -0
- data/test/scout/test_semaphore.rb +17 -0
- data/test/scout/test_work_queue.rb +93 -0
- data/test/scout/work_queue/test_socket.rb +46 -0
- data/test/scout/work_queue/test_worker.rb +99 -0
- data/test/scout/workflow/step/test_info.rb +17 -15
- data/test/scout/workflow/step/test_load.rb +65 -0
- data/test/scout/workflow/test_definition.rb +0 -0
- data/test/scout/workflow/test_documentation.rb +30 -0
- data/test/scout/workflow/test_task.rb +1 -0
- data/test/scout/workflow/test_usage.rb +12 -3
- metadata +24 -2
@@ -0,0 +1,46 @@
|
|
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
|
+
class TestSocket < Test::Unit::TestCase
|
5
|
+
def test_simple
|
6
|
+
socket = WorkQueue::Socket.new
|
7
|
+
|
8
|
+
socket.write 1
|
9
|
+
socket.write 2
|
10
|
+
socket.write "STRING"
|
11
|
+
socket.write :string
|
12
|
+
|
13
|
+
assert_equal 1, socket.read
|
14
|
+
assert_equal 2, socket.read
|
15
|
+
assert_equal "STRING", socket.read
|
16
|
+
assert_equal :string, socket.read
|
17
|
+
|
18
|
+
socket.close_write
|
19
|
+
assert_raise ClosedStream do
|
20
|
+
socket.read
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def __test_speed
|
25
|
+
sss 0
|
26
|
+
socket = WorkQueue::Socket.new
|
27
|
+
|
28
|
+
num = 10_000
|
29
|
+
|
30
|
+
Thread.new do
|
31
|
+
num.times do |i|
|
32
|
+
socket.write nil
|
33
|
+
end
|
34
|
+
socket.write DoneProcessing.new
|
35
|
+
end
|
36
|
+
|
37
|
+
bar = Log::ProgressBar.new num
|
38
|
+
while true
|
39
|
+
i = socket.read
|
40
|
+
bar.tick
|
41
|
+
break if DoneProcessing === i
|
42
|
+
end
|
43
|
+
bar.done
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,99 @@
|
|
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/semaphore'
|
5
|
+
require 'scout/work_queue/socket'
|
6
|
+
class TestQueueWorker < Test::Unit::TestCase
|
7
|
+
def test_simple
|
8
|
+
worker = WorkQueue::Worker.new
|
9
|
+
TmpFile.with_file do |file|
|
10
|
+
worker.run do
|
11
|
+
Open.write file, "TEST"
|
12
|
+
end
|
13
|
+
worker.join
|
14
|
+
|
15
|
+
assert_equal "TEST", Open.read(file)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_semaphore
|
20
|
+
ScoutSemaphore.with_semaphore 1 do |sem|
|
21
|
+
|
22
|
+
TmpFile.with_file do |outfile|
|
23
|
+
2.times do
|
24
|
+
sout = Open.open_pipe do |sin|
|
25
|
+
workers = 100.times.collect{ WorkQueue::Worker.new }
|
26
|
+
workers.each do |w|
|
27
|
+
w.run do
|
28
|
+
ScoutSemaphore.synchronize(sem) do
|
29
|
+
10.times do
|
30
|
+
sin.puts Process.pid
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
WorkQueue::Worker.join(workers)
|
37
|
+
end
|
38
|
+
Open.consume_stream(sout, false, outfile)
|
39
|
+
pid_list = Open.read(outfile).split("\n")
|
40
|
+
|
41
|
+
assert_nothing_raised do
|
42
|
+
seen = []
|
43
|
+
current = nil
|
44
|
+
pid_list.each do |pid|
|
45
|
+
if pid != current
|
46
|
+
raise "Out of order" if seen.include? pid
|
47
|
+
end
|
48
|
+
current = pid
|
49
|
+
seen << pid
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_process
|
58
|
+
input = WorkQueue::Socket.new
|
59
|
+
output = WorkQueue::Socket.new
|
60
|
+
|
61
|
+
workers = 10.times.collect{ WorkQueue::Worker.new }
|
62
|
+
workers.each do |w|
|
63
|
+
w.process(input, output) do |obj|
|
64
|
+
[Process.pid, obj.inspect] * " "
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
read = Thread.new do
|
69
|
+
begin
|
70
|
+
while obj = output.read
|
71
|
+
if DoneProcessing === obj
|
72
|
+
pid = obj.pid
|
73
|
+
workers.delete_if{|w| w.pid = pid }
|
74
|
+
break if workers.empty?
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
write = Thread.new do
|
81
|
+
100.times do |i|
|
82
|
+
input.write i
|
83
|
+
end
|
84
|
+
10.times do
|
85
|
+
input.write DoneProcessing.new
|
86
|
+
end
|
87
|
+
input.close_write
|
88
|
+
end
|
89
|
+
|
90
|
+
write.join
|
91
|
+
read.join
|
92
|
+
|
93
|
+
WorkQueue::Worker.join workers
|
94
|
+
input.clean
|
95
|
+
output.clean
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
@@ -4,25 +4,27 @@ require 'scout/workflow'
|
|
4
4
|
|
5
5
|
class TestStepInfo < Test::Unit::TestCase
|
6
6
|
def test_dependency
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
assert_equal 2, step1.exec
|
16
|
+
assert_equal 2, step1.run
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
step2 = Step.new tmpfile.step2 do
|
19
|
+
step1 = dependencies.first
|
20
|
+
step1.inputs.first + " has " + step1.load.to_s + " characters"
|
21
|
+
end
|
20
22
|
|
21
|
-
|
23
|
+
step2.dependencies = [step1]
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
+
assert_equal "12 has 2 characters", step2.run
|
26
|
+
assert_equal "12 has 2 characters", step2.run
|
27
|
+
end
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
28
|
-
|
@@ -0,0 +1,65 @@
|
|
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/step'
|
5
|
+
|
6
|
+
class TestStepLoad < Test::Unit::TestCase
|
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
|
13
|
+
|
14
|
+
step2 = Step.new tmpfile.step2 do
|
15
|
+
step1 = dependencies.first
|
16
|
+
step1.inputs.first + " has " + step1.load.to_s + " characters"
|
17
|
+
end
|
18
|
+
|
19
|
+
step2.dependencies = [step1]
|
20
|
+
|
21
|
+
step2.recursive_clean
|
22
|
+
step2.run
|
23
|
+
|
24
|
+
new_step2 = Step.load(step2.path)
|
25
|
+
|
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
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_relocate
|
34
|
+
wf = Workflow.annonymous_workflow "RelocateWorkflow" do
|
35
|
+
input :input1, :string
|
36
|
+
task :step1 => :string do |input1|
|
37
|
+
input1
|
38
|
+
end
|
39
|
+
|
40
|
+
dep :step1
|
41
|
+
task :step2 => :string do
|
42
|
+
step(:step1).load.reverse
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
step2 = wf.job(:step2, :input1 => "TEST")
|
47
|
+
step1 = step2.step(:step1)
|
48
|
+
|
49
|
+
step2.run
|
50
|
+
new_step2 = Step.load(step2.path)
|
51
|
+
TmpFile.with_file do |dir|
|
52
|
+
Misc.in_dir dir do
|
53
|
+
Path.setup(dir)
|
54
|
+
Open.mv step1.path, dir.var.jobs.RelocateWorkflow.step1[File.basename(step1.path)]
|
55
|
+
Open.mv step1.info_file, dir.var.jobs.RelocateWorkflow.step1[File.basename(step1.info_file)]
|
56
|
+
|
57
|
+
new_step2 = Step.load(step2.path)
|
58
|
+
assert_equal "TEST".reverse, new_step2.load
|
59
|
+
assert_equal "TEST", new_step2.dependencies.first.load
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
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
|
+
class TestWorkflowDocumentation < Test::Unit::TestCase
|
5
|
+
module UsageWorkflow
|
6
|
+
extend Workflow
|
7
|
+
|
8
|
+
self.name = "UsageWorkflow"
|
9
|
+
|
10
|
+
self.title = "Workflow to test documentation"
|
11
|
+
self.description = "Use this workflow to test if the documentation is correctly presented"
|
12
|
+
|
13
|
+
desc "Desc"
|
14
|
+
input :array, :array, "Array"
|
15
|
+
task :step1 => :string do
|
16
|
+
end
|
17
|
+
|
18
|
+
dep :step1
|
19
|
+
desc "Desc2"
|
20
|
+
input :float, :float, "Float"
|
21
|
+
task :step2 => :string do
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_usage
|
26
|
+
assert_match 'test', UsageWorkflow.documentation[:title]
|
27
|
+
assert_match 'presented', UsageWorkflow.documentation[:description]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -5,6 +5,11 @@ require 'scout/workflow'
|
|
5
5
|
class TestWorkflowUsage < Test::Unit::TestCase
|
6
6
|
module UsageWorkflow
|
7
7
|
extend Workflow
|
8
|
+
|
9
|
+
self.name = "UsageWorkflow"
|
10
|
+
|
11
|
+
self.title = "Workflow to test documentation"
|
12
|
+
self.description = "Use this workflow to test if the documentation is correctly presented."
|
8
13
|
|
9
14
|
desc "Desc"
|
10
15
|
input :array, :array, "Array"
|
@@ -18,9 +23,13 @@ class TestWorkflowUsage < Test::Unit::TestCase
|
|
18
23
|
end
|
19
24
|
end
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
UsageWorkflow.
|
26
|
+
|
27
|
+
def test_workflow_usage
|
28
|
+
assert_match "test if the documentation", UsageWorkflow.usage
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_task_usage
|
32
|
+
assert_match "Desc2", UsageWorkflow.tasks[:step2].usage
|
24
33
|
end
|
25
34
|
end
|
26
35
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout-gear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/scout/misc/filesystem.rb
|
119
119
|
- lib/scout/misc/format.rb
|
120
120
|
- lib/scout/misc/insist.rb
|
121
|
+
- lib/scout/misc/monitor.rb
|
121
122
|
- lib/scout/open.rb
|
122
123
|
- lib/scout/open/lock.rb
|
123
124
|
- lib/scout/open/remote.rb
|
@@ -136,6 +137,8 @@ files:
|
|
136
137
|
- lib/scout/resource/produce.rb
|
137
138
|
- lib/scout/resource/produce/rake.rb
|
138
139
|
- lib/scout/resource/scout.rb
|
140
|
+
- lib/scout/resource/util.rb
|
141
|
+
- lib/scout/semaphore.rb
|
139
142
|
- lib/scout/simple_opt.rb
|
140
143
|
- lib/scout/simple_opt/accessor.rb
|
141
144
|
- lib/scout/simple_opt/doc.rb
|
@@ -143,11 +146,15 @@ files:
|
|
143
146
|
- lib/scout/simple_opt/parse.rb
|
144
147
|
- lib/scout/simple_opt/setup.rb
|
145
148
|
- lib/scout/tmpfile.rb
|
149
|
+
- lib/scout/work_queue.rb
|
150
|
+
- lib/scout/work_queue/socket.rb
|
151
|
+
- lib/scout/work_queue/worker.rb
|
146
152
|
- lib/scout/workflow.rb
|
147
153
|
- lib/scout/workflow/definition.rb
|
148
154
|
- lib/scout/workflow/documentation.rb
|
149
155
|
- lib/scout/workflow/step.rb
|
150
156
|
- lib/scout/workflow/step/info.rb
|
157
|
+
- lib/scout/workflow/step/load.rb
|
151
158
|
- lib/scout/workflow/task.rb
|
152
159
|
- lib/scout/workflow/task/inputs.rb
|
153
160
|
- lib/scout/workflow/usage.rb
|
@@ -158,9 +165,15 @@ files:
|
|
158
165
|
- scout_commands/find
|
159
166
|
- scout_commands/glob
|
160
167
|
- scout_commands/rbbt
|
168
|
+
- scout_commands/workflow/info
|
169
|
+
- scout_commands/workflow/list
|
161
170
|
- scout_commands/workflow/task
|
171
|
+
- scout_commands/workflow/task_old
|
172
|
+
- share/color/color_names
|
173
|
+
- share/color/diverging_colors.hex
|
162
174
|
- test/scout/indiferent_hash/test_case_insensitive.rb
|
163
175
|
- test/scout/indiferent_hash/test_options.rb
|
176
|
+
- test/scout/log/test_color.rb
|
164
177
|
- test/scout/log/test_progress.rb
|
165
178
|
- test/scout/misc/test_digest.rb
|
166
179
|
- test/scout/misc/test_filesystem.rb
|
@@ -176,6 +189,8 @@ files:
|
|
176
189
|
- test/scout/persist/test_serialize.rb
|
177
190
|
- test/scout/resource/test_path.rb
|
178
191
|
- test/scout/resource/test_produce.rb
|
192
|
+
- test/scout/resource/test_util.rb
|
193
|
+
- test/scout/simple_opt/test_doc.rb
|
179
194
|
- test/scout/simple_opt/test_get.rb
|
180
195
|
- test/scout/simple_opt/test_parse.rb
|
181
196
|
- test/scout/simple_opt/test_setup.rb
|
@@ -189,10 +204,17 @@ files:
|
|
189
204
|
- test/scout/test_path.rb
|
190
205
|
- test/scout/test_persist.rb
|
191
206
|
- test/scout/test_resource.rb
|
207
|
+
- test/scout/test_semaphore.rb
|
192
208
|
- test/scout/test_tmpfile.rb
|
209
|
+
- test/scout/test_work_queue.rb
|
193
210
|
- test/scout/test_workflow.rb
|
211
|
+
- test/scout/work_queue/test_socket.rb
|
212
|
+
- test/scout/work_queue/test_worker.rb
|
194
213
|
- test/scout/workflow/step/test_info.rb
|
214
|
+
- test/scout/workflow/step/test_load.rb
|
195
215
|
- test/scout/workflow/task/test_inputs.rb
|
216
|
+
- test/scout/workflow/test_definition.rb
|
217
|
+
- test/scout/workflow/test_documentation.rb
|
196
218
|
- test/scout/workflow/test_step.rb
|
197
219
|
- test/scout/workflow/test_task.rb
|
198
220
|
- test/scout/workflow/test_usage.rb
|