rbbt-util 5.43.0 → 5.44.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/etc/app.d/base.rb +1 -1
- data/lib/rbbt/association/util.rb +1 -1
- data/lib/rbbt/hpc/batch.rb +19 -17
- data/lib/rbbt/persist/tsv/sharder.rb +1 -1
- data/lib/rbbt/tsv/accessor.rb +6 -11
- data/lib/rbbt/tsv/dumper.rb +21 -10
- data/lib/rbbt/tsv/index.rb +2 -1
- data/lib/rbbt/util/misc/math.rb +0 -1
- data/lib/rbbt/util/misc/omics.rb +2 -1
- data/lib/rbbt/util/misc/ssw.rb +298 -0
- data/lib/rbbt/util/open.rb +1 -1
- data/lib/rbbt/workflow/step/info.rb +3 -2
- data/lib/rbbt/workflow/step.rb +2 -1
- data/python/rbbt/__init__.py +2 -2
- data/share/rbbt_commands/workflow/server +6 -1
- data/share/rbbt_commands/workflow/task +1 -1
- metadata +5 -220
- data/test/rbbt/annotations/test_util.rb +0 -43
- data/test/rbbt/association/test_database.rb +0 -87
- data/test/rbbt/association/test_index.rb +0 -127
- data/test/rbbt/association/test_item.rb +0 -15
- data/test/rbbt/association/test_open.rb +0 -63
- data/test/rbbt/association/test_util.rb +0 -108
- data/test/rbbt/entity/test_identifiers.rb +0 -34
- data/test/rbbt/hpc/orchestrate/test_batches.rb +0 -70
- data/test/rbbt/hpc/orchestrate/test_chains.rb +0 -108
- data/test/rbbt/hpc/orchestrate/test_rules.rb +0 -59
- data/test/rbbt/hpc/test_batch.rb +0 -64
- data/test/rbbt/hpc/test_hpc_test_workflows.rb +0 -0
- data/test/rbbt/hpc/test_orchestrate.rb +0 -144
- data/test/rbbt/hpc/test_pbs.rb +0 -43
- data/test/rbbt/hpc/test_slurm.rb +0 -28
- data/test/rbbt/knowledge_base/test_enrichment.rb +0 -50
- data/test/rbbt/knowledge_base/test_entity.rb +0 -62
- data/test/rbbt/knowledge_base/test_query.rb +0 -46
- data/test/rbbt/knowledge_base/test_registry.rb +0 -74
- data/test/rbbt/knowledge_base/test_syndicate.rb +0 -48
- data/test/rbbt/knowledge_base/test_traverse.rb +0 -133
- data/test/rbbt/persist/test_tsv.rb +0 -88
- data/test/rbbt/persist/tsv/test_cdb.rb +0 -18
- data/test/rbbt/persist/tsv/test_kyotocabinet.rb +0 -27
- data/test/rbbt/persist/tsv/test_leveldb.rb +0 -18
- data/test/rbbt/persist/tsv/test_lmdb.rb +0 -20
- data/test/rbbt/persist/tsv/test_sharder.rb +0 -164
- data/test/rbbt/persist/tsv/test_tokyocabinet.rb +0 -262
- data/test/rbbt/resource/test_path.rb +0 -49
- data/test/rbbt/test_annotations.rb +0 -167
- data/test/rbbt/test_association.rb +0 -103
- data/test/rbbt/test_entity.rb +0 -252
- data/test/rbbt/test_fix_width_table.rb +0 -135
- data/test/rbbt/test_knowledge_base.rb +0 -226
- data/test/rbbt/test_monitor.rb +0 -11
- data/test/rbbt/test_packed_index.rb +0 -68
- data/test/rbbt/test_persist.rb +0 -85
- data/test/rbbt/test_resource.rb +0 -110
- data/test/rbbt/test_tsv.rb +0 -669
- data/test/rbbt/test_workflow.rb +0 -609
- data/test/rbbt/tsv/parallel/test_through.rb +0 -40
- data/test/rbbt/tsv/parallel/test_traverse.rb +0 -456
- data/test/rbbt/tsv/test_accessor.rb +0 -319
- data/test/rbbt/tsv/test_attach.rb +0 -715
- data/test/rbbt/tsv/test_change_id.rb +0 -61
- data/test/rbbt/tsv/test_csv.rb +0 -49
- data/test/rbbt/tsv/test_excel.rb +0 -171
- data/test/rbbt/tsv/test_field_index.rb +0 -19
- data/test/rbbt/tsv/test_filter.rb +0 -187
- data/test/rbbt/tsv/test_index.rb +0 -308
- data/test/rbbt/tsv/test_manipulate.rb +0 -334
- data/test/rbbt/tsv/test_marshal.rb +0 -24
- data/test/rbbt/tsv/test_matrix.rb +0 -20
- data/test/rbbt/tsv/test_parallel.rb +0 -7
- data/test/rbbt/tsv/test_parser.rb +0 -101
- data/test/rbbt/tsv/test_stream.rb +0 -253
- data/test/rbbt/tsv/test_util.rb +0 -52
- data/test/rbbt/util/R/test_eval.rb +0 -43
- data/test/rbbt/util/R/test_model.rb +0 -128
- data/test/rbbt/util/R/test_plot.rb +0 -38
- data/test/rbbt/util/concurrency/processes/test_socket.rb +0 -70
- data/test/rbbt/util/concurrency/test_processes.rb +0 -192
- data/test/rbbt/util/concurrency/test_threads.rb +0 -40
- data/test/rbbt/util/log/test_progress.rb +0 -111
- data/test/rbbt/util/misc/test_bgzf.rb +0 -48
- data/test/rbbt/util/misc/test_communication.rb +0 -13
- data/test/rbbt/util/misc/test_development.rb +0 -26
- data/test/rbbt/util/misc/test_format.rb +0 -10
- data/test/rbbt/util/misc/test_indiferent_hash.rb +0 -14
- data/test/rbbt/util/misc/test_lock.rb +0 -77
- data/test/rbbt/util/misc/test_multipart_payload.rb +0 -202
- data/test/rbbt/util/misc/test_omics.rb +0 -116
- data/test/rbbt/util/misc/test_pipes.rb +0 -343
- data/test/rbbt/util/misc/test_serialize.rb +0 -24
- data/test/rbbt/util/python/test_util.rb +0 -25
- data/test/rbbt/util/simpleopt/test_get.rb +0 -12
- data/test/rbbt/util/simpleopt/test_parse.rb +0 -10
- data/test/rbbt/util/simpleopt/test_setup.rb +0 -76
- data/test/rbbt/util/test_R.rb +0 -37
- data/test/rbbt/util/test_chain_methods.rb +0 -22
- data/test/rbbt/util/test_cmd.rb +0 -87
- data/test/rbbt/util/test_colorize.rb +0 -22
- data/test/rbbt/util/test_concurrency.rb +0 -6
- data/test/rbbt/util/test_config.rb +0 -69
- data/test/rbbt/util/test_excel2tsv.rb +0 -10
- data/test/rbbt/util/test_filecache.rb +0 -36
- data/test/rbbt/util/test_log.rb +0 -52
- data/test/rbbt/util/test_migrate.rb +0 -34
- data/test/rbbt/util/test_misc.rb +0 -728
- data/test/rbbt/util/test_open.rb +0 -200
- data/test/rbbt/util/test_procpath.rb +0 -23
- data/test/rbbt/util/test_python.rb +0 -144
- data/test/rbbt/util/test_semaphore.rb +0 -36
- data/test/rbbt/util/test_simpleDSL.rb +0 -55
- data/test/rbbt/util/test_simpleopt.rb +0 -11
- data/test/rbbt/util/test_ssh.rb +0 -10
- data/test/rbbt/util/test_tmpfile.rb +0 -32
- data/test/rbbt/workflow/step/test_dependencies.rb +0 -295
- data/test/rbbt/workflow/step/test_save_load_inputs.rb +0 -136
- data/test/rbbt/workflow/test_doc.rb +0 -30
- data/test/rbbt/workflow/test_remote_workflow.rb +0 -99
- data/test/rbbt/workflow/test_schedule.rb +0 -0
- data/test/rbbt/workflow/test_step.rb +0 -231
- data/test/rbbt/workflow/test_task.rb +0 -85
- data/test/rbbt/workflow/util/test_archive.rb +0 -27
- data/test/rbbt/workflow/util/test_data.rb +0 -67
- data/test/rbbt/workflow/util/test_orchestrator.rb +0 -263
- data/test/test_helper.rb +0 -114
data/test/rbbt/util/test_open.rb
DELETED
@@ -1,200 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
-
require 'rbbt/util/open'
|
3
|
-
require 'rbbt/util/tmpfile'
|
4
|
-
require 'rbbt/persist'
|
5
|
-
require 'test/unit'
|
6
|
-
|
7
|
-
|
8
|
-
class TestOpen < Test::Unit::TestCase
|
9
|
-
|
10
|
-
def test_wget
|
11
|
-
assert(Misc.fixutf8(Open.wget('http://google.com', :quiet => true).read) =~ /html/)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_nice
|
15
|
-
nice = 0.5
|
16
|
-
|
17
|
-
t = Time.now
|
18
|
-
Open.wget('http://google.com', :quiet => true, :nice => nice).read
|
19
|
-
assert(Time.now - t + 0.5 >= nice)
|
20
|
-
|
21
|
-
Open.wget('http://google.com', :quiet => true, :nice => nice, :nice_key => 1).read
|
22
|
-
t = Time.now
|
23
|
-
Open.wget('http://google.com', :quiet => true, :nice => nice, :nice_key => 1).read
|
24
|
-
assert(Time.now - t + 0.5 >= nice)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_remote?
|
28
|
-
assert(Open.remote?('http://google.com'))
|
29
|
-
assert(! Open.remote?('~/.bashrc'))
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_open
|
33
|
-
assert(Open.read('http://google.com', :quiet => true, :nocache => :update) =~ /html/)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_read
|
37
|
-
content =<<-EOF
|
38
|
-
1
|
39
|
-
2
|
40
|
-
3
|
41
|
-
4
|
42
|
-
EOF
|
43
|
-
TmpFile.with_file(content) do |file|
|
44
|
-
sum = 0
|
45
|
-
Open.read file do |line| sum += line.to_i end
|
46
|
-
assert_equal(1 + 2 + 3 + 4, sum)
|
47
|
-
assert_equal(content, Open.read(file))
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_read_grep
|
52
|
-
content =<<-EOF
|
53
|
-
1
|
54
|
-
2
|
55
|
-
3
|
56
|
-
4
|
57
|
-
EOF
|
58
|
-
TmpFile.with_file(content) do |file|
|
59
|
-
sum = 0
|
60
|
-
Open.read(file, :grep => '^1\|3') do |line| sum += line.to_i end
|
61
|
-
assert_equal(1 + 3, sum)
|
62
|
-
end
|
63
|
-
|
64
|
-
TmpFile.with_file(content) do |file|
|
65
|
-
sum = 0
|
66
|
-
Open.read(file, :grep => ["1","3"]) do |line| sum += line.to_i end
|
67
|
-
assert_equal(1 + 3, sum)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_read_grep_invert
|
72
|
-
content =<<-EOF
|
73
|
-
1
|
74
|
-
2
|
75
|
-
3
|
76
|
-
4
|
77
|
-
EOF
|
78
|
-
TmpFile.with_file(content) do |file|
|
79
|
-
sum = 0
|
80
|
-
Open.read(file, :grep => '^1\|3', :invert_grep => true) do |line| sum += line.to_i end
|
81
|
-
assert_equal(2 + 4, sum)
|
82
|
-
end
|
83
|
-
|
84
|
-
TmpFile.with_file(content) do |file|
|
85
|
-
sum = 0
|
86
|
-
Open.read(file, :grep => ["1","3"]) do |line| sum += line.to_i end
|
87
|
-
assert_equal(1 + 3, sum)
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
def test_gzip
|
94
|
-
content =<<-EOF
|
95
|
-
1
|
96
|
-
2
|
97
|
-
3
|
98
|
-
4
|
99
|
-
EOF
|
100
|
-
TmpFile.with_file(content) do |file|
|
101
|
-
`gzip #{file}`
|
102
|
-
assert_equal(content, Open.read(file + '.gz'))
|
103
|
-
puts content
|
104
|
-
FileUtils.rm file + '.gz'
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_repo_dir
|
109
|
-
file1 = "TEST"
|
110
|
-
file2 = "TEST" * 1000
|
111
|
-
TmpFile.with_file do |tmpdir|
|
112
|
-
tmpdir = Rbbt.tmp.repo_dir.find
|
113
|
-
normal = File.join(tmpdir, 'normal')
|
114
|
-
repo = File.join(tmpdir, 'repo')
|
115
|
-
|
116
|
-
Open.repository_dirs.push(repo)
|
117
|
-
|
118
|
-
Misc.benchmark(100) do
|
119
|
-
filename = "file" << (rand * 100).to_i.to_s
|
120
|
-
Open.write(File.join(normal, filename), file2)
|
121
|
-
100.times do
|
122
|
-
Open.read(File.join(normal, filename))
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
Misc.benchmark(100) do
|
127
|
-
filename = "file" << (rand * 100).to_i.to_s
|
128
|
-
Open.write(File.join(repo, filename), file2)
|
129
|
-
100.times do
|
130
|
-
Open.read(File.join(repo, filename))
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_repo_dir2
|
137
|
-
TmpFile.with_file do |tmpdir|
|
138
|
-
tmpdir = Rbbt.tmp.repo_dir.find
|
139
|
-
repo = File.join(tmpdir, 'repo')
|
140
|
-
|
141
|
-
Open.repository_dirs.push(repo)
|
142
|
-
|
143
|
-
obj = { :a => "???a"}
|
144
|
-
filename = "file" << (rand * 100).to_i.to_s
|
145
|
-
Open.write(File.join(repo, filename), Marshal.dump(obj))
|
146
|
-
dump = Open.read(File.join(repo, filename))
|
147
|
-
obj_cp = Marshal.load(dump)
|
148
|
-
assert_equal obj, obj_cp
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def test_repo_marshal
|
153
|
-
TmpFile.with_file do |tmpdir|
|
154
|
-
tmpdir = Rbbt.tmp.repo_dir.find
|
155
|
-
repo = File.join(tmpdir, 'repo')
|
156
|
-
|
157
|
-
filename = 'file'
|
158
|
-
Open.repository_dirs.push(repo)
|
159
|
-
|
160
|
-
obj = {:a => "string", :pid => nil, :num => 1000, :p => Rbbt.tmp.foo}
|
161
|
-
Open.write(File.join(repo, filename), Marshal.dump(obj))
|
162
|
-
new =Open.open(File.join(repo, filename)) do |f|
|
163
|
-
Marshal.load(f)
|
164
|
-
end
|
165
|
-
|
166
|
-
assert_equal new, obj
|
167
|
-
end
|
168
|
-
|
169
|
-
end
|
170
|
-
|
171
|
-
def test_write_stream_repo
|
172
|
-
TmpFile.with_file do |tmpdir|
|
173
|
-
tmpdir = Rbbt.tmp.repo_dir.find
|
174
|
-
repo = File.join(tmpdir, 'repo')
|
175
|
-
|
176
|
-
file = File.join(repo, 'file')
|
177
|
-
Open.repository_dirs.push(repo)
|
178
|
-
|
179
|
-
text = (["text"] * 5) * "\n"
|
180
|
-
|
181
|
-
Misc.consume_stream(StringIO.new(text), false, file)
|
182
|
-
|
183
|
-
assert_equal text, Open.read(file)
|
184
|
-
assert Open.exists?(file)
|
185
|
-
refute File.exist?(file)
|
186
|
-
end
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
def test_download_fails
|
191
|
-
TmpFile.with_file do |tmp|
|
192
|
-
assert_raise do
|
193
|
-
Open.download("http:fake-host/some_path", tmp)
|
194
|
-
end
|
195
|
-
refute Open.exists?(tmp)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
end
|
200
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
|
2
|
-
require 'rbbt/util/procpath'
|
3
|
-
|
4
|
-
class TestProcPath < Test::Unit::TestCase
|
5
|
-
def test_record_and_plot
|
6
|
-
keyword_test :procpath do
|
7
|
-
pid = Process.fork do
|
8
|
-
a = ""
|
9
|
-
(0..1000).each do
|
10
|
-
a << (0..rand(10000).to_i).to_a.collect{|i| "TEST #{i}" } * " "
|
11
|
-
sleep 0.1
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
TmpFile.with_file(nil, false) do |db|
|
16
|
-
|
17
|
-
ProcPath.record(pid, db, :interval => '1', "recnum" => 100)
|
18
|
-
ProcPath.plot(db, db + '.svg', "moving-average-window" => 1 )
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
@@ -1,144 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
|
2
|
-
require 'rbbt/util/python'
|
3
|
-
|
4
|
-
class TestPython < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def test_python
|
7
|
-
TmpFile.with_file do |tmpdir|
|
8
|
-
code =<<-EOF
|
9
|
-
def python_test(a, b):
|
10
|
-
c = a + b
|
11
|
-
return c
|
12
|
-
EOF
|
13
|
-
Open.write(File.join(tmpdir, 'file1.py'), code)
|
14
|
-
Open.write(File.join(tmpdir, 'file2.py'), code)
|
15
|
-
Open.write(File.join(tmpdir, 'file3.py'), code)
|
16
|
-
Open.write(File.join(tmpdir, 'file4.py'), code)
|
17
|
-
RbbtPython.add_path tmpdir
|
18
|
-
|
19
|
-
res = nil
|
20
|
-
|
21
|
-
RbbtPython.run 'file2', :python_test do
|
22
|
-
res = python_test(1, 3)
|
23
|
-
end
|
24
|
-
assert_equal 4, res
|
25
|
-
|
26
|
-
RbbtPython.run do
|
27
|
-
pyfrom :file3, :import => :python_test
|
28
|
-
res = python_test(1, 4)
|
29
|
-
end
|
30
|
-
assert_equal 5, res
|
31
|
-
|
32
|
-
RbbtPython.run do
|
33
|
-
pyimport :file4
|
34
|
-
res = file4.python_test(1, 4)
|
35
|
-
end
|
36
|
-
assert_equal 5, res
|
37
|
-
|
38
|
-
RbbtPython.run 'file1' do
|
39
|
-
res = file1.python_test(1, 2)
|
40
|
-
end
|
41
|
-
assert_equal 3, res
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_run_log
|
46
|
-
TmpFile.with_file do |tmpdir|
|
47
|
-
code =<<-EOF
|
48
|
-
import sys
|
49
|
-
def python_print():
|
50
|
-
print("Test STDERR", file=sys.stderr)
|
51
|
-
print("Test STDOUT")
|
52
|
-
EOF
|
53
|
-
Open.write(File.join(tmpdir, 'file_print.py'), code)
|
54
|
-
RbbtPython.add_path tmpdir
|
55
|
-
|
56
|
-
RbbtPython.run_log 'file_print' do
|
57
|
-
file_print.python_print
|
58
|
-
end
|
59
|
-
RbbtPython.run_log_stderr 'file_print' do
|
60
|
-
file_print.python_print
|
61
|
-
end
|
62
|
-
|
63
|
-
RbbtPython.run_log 'file_print' do
|
64
|
-
file_print.python_print
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_keras
|
70
|
-
keyword_test :tensorflow do
|
71
|
-
defined = RbbtPython.run do
|
72
|
-
pyimport "tensorflow.keras.models", as: :km
|
73
|
-
defined?(km.Sequential)
|
74
|
-
end
|
75
|
-
assert defined
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_keras_import
|
80
|
-
keyword_test :tensorflow do
|
81
|
-
defined = RbbtPython.run do
|
82
|
-
pyfrom "tensorflow.keras.models", import: :Sequential
|
83
|
-
defined?(self::Sequential)
|
84
|
-
end
|
85
|
-
assert defined
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_iterate
|
90
|
-
a2, b2 = nil, nil
|
91
|
-
RbbtPython.run :numpy, as: :np do
|
92
|
-
a = np.array([1,2])
|
93
|
-
a2 = RbbtPython.collect a do |e|
|
94
|
-
e * 2
|
95
|
-
end
|
96
|
-
b = PyCall.tuple([1,2])
|
97
|
-
b2 = RbbtPython.collect b do |e|
|
98
|
-
e * 2
|
99
|
-
end
|
100
|
-
end
|
101
|
-
assert_equal [2,4], a2
|
102
|
-
assert_equal [2,4], b2
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_lambda
|
106
|
-
l = PyCall.eval "lambda e: e + 2"
|
107
|
-
assert_equal 5, l.(3)
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_binding
|
111
|
-
raised = false
|
112
|
-
RbbtPython.binding_run do
|
113
|
-
pyimport :torch
|
114
|
-
pyfrom :torch, import: ["nn"]
|
115
|
-
begin
|
116
|
-
torch
|
117
|
-
rescue
|
118
|
-
raised = true
|
119
|
-
end
|
120
|
-
end
|
121
|
-
assert ! raised
|
122
|
-
|
123
|
-
raised = false
|
124
|
-
RbbtPython.binding_run do
|
125
|
-
begin
|
126
|
-
torch
|
127
|
-
rescue
|
128
|
-
raised = true
|
129
|
-
end
|
130
|
-
end
|
131
|
-
assert raised
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_import_method
|
135
|
-
random = RbbtPython.import_method :torch, :rand, :random
|
136
|
-
assert random.call(1).numpy.to_f > 0
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_class_new_obj
|
140
|
-
obj = RbbtPython.class_new_obj("torch.nn", "Module")
|
141
|
-
assert_equal "Module()", obj.to_s
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
|
2
|
-
require 'rbbt/util/semaphore'
|
3
|
-
|
4
|
-
class TestRbbtSemaphore < Test::Unit::TestCase
|
5
|
-
def test_process
|
6
|
-
RbbtSemaphore.with_semaphore(10) do |s|
|
7
|
-
pids = []
|
8
|
-
100.times do
|
9
|
-
pids << Process.fork do
|
10
|
-
100.times do
|
11
|
-
RbbtSemaphore.wait_semaphore(s)
|
12
|
-
sleep 0.001
|
13
|
-
RbbtSemaphore.post_semaphore(s)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
pids.each do |pid|
|
18
|
-
Process.waitpid pid
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def _test_thread
|
24
|
-
times = 50
|
25
|
-
TmpFile.with_file do |dir|
|
26
|
-
Path.setup(dir)
|
27
|
-
FileUtils.mkdir_p dir
|
28
|
-
RbbtSemaphore.thread_each_on_semaphore((1..times).to_a, 25){|elem|
|
29
|
-
sleep rand
|
30
|
-
Open.write(dir[elem], "test")
|
31
|
-
}
|
32
|
-
assert_equal times, dir.glob.length
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
-
require 'rbbt/util/simpleDSL'
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
class TestSimpleDSLClass
|
6
|
-
include SimpleDSL
|
7
|
-
|
8
|
-
def action(name, *args, &block)
|
9
|
-
@actions ||= {}
|
10
|
-
@actions[name] = args.first
|
11
|
-
end
|
12
|
-
|
13
|
-
def actions
|
14
|
-
@actions
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
class TestDSL < Test::Unit::TestCase
|
20
|
-
def setup
|
21
|
-
@parser = TestSimpleDSLClass.new
|
22
|
-
@parser.load_config(:action) do
|
23
|
-
action1 "Hello"
|
24
|
-
action2 "Good bye"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_actions
|
29
|
-
assert_equal({:action1=>"Hello", :action2=>"Good bye"}, @parser.actions)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_method_missing
|
33
|
-
assert_raise(NoMethodError){@parser.cues}
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_config
|
37
|
-
config = <<-EOC
|
38
|
-
action1 "Hello"
|
39
|
-
action2 "Good bye"
|
40
|
-
EOC
|
41
|
-
|
42
|
-
begin
|
43
|
-
assert_equal config.split("\n").collect{|l| l.strip}, @parser.config(:action).split("\n").collect{|l| l.strip}
|
44
|
-
rescue SimpleDSL::NoRuby2Ruby
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_parse
|
49
|
-
@parser.parse :action do
|
50
|
-
action3 "Back again"
|
51
|
-
end
|
52
|
-
|
53
|
-
assert_equal({:action1 =>"Hello", :action2 =>"Good bye", :action3 =>"Back again"}, @parser.actions)
|
54
|
-
end
|
55
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
-
require 'rbbt/util/simpleopt'
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
class TestSOPT < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def test_cmd_option_string
|
8
|
-
SOPT.parse("-h--help:-to--tsv-options")
|
9
|
-
assert_equal "tsv-options", SOPT.shortcuts["to"]
|
10
|
-
end
|
11
|
-
end
|
data/test/rbbt/util/test_ssh.rb
DELETED
@@ -1,10 +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
|
-
class TestSSH < Test::Unit::TestCase
|
5
|
-
def test_marshal
|
6
|
-
|
7
|
-
assert TrueClass === SSHLine.rbbt('turbo', 'true')
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
-
require 'rbbt/util/tmpfile'
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
class TestTmpFile < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def test_tmp_file
|
8
|
-
assert(TmpFile.tmp_file("test") =~ /(tmpfiles|tmp)\/test\d+$/)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_do_tmp_file
|
12
|
-
content = "Hello World!"
|
13
|
-
TmpFile.with_file(content) do |file|
|
14
|
-
assert_equal content, File.open(file).read
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_extension
|
19
|
-
TmpFile.with_file(nil, true, :extension => 'txt') do |file|
|
20
|
-
assert file =~ /\.txt$/
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_tmpdir
|
25
|
-
TmpFile.with_file(nil, true, :tmpdir => 'TMPDIR') do |file|
|
26
|
-
assert file =~ /TMPDIR/
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
|