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,67 +0,0 @@
1
- module SOPT
2
- def self.fix_shortcut(short, long)
3
- return short unless short and shortcuts.include?(short)
4
-
5
- current = shortcuts.select{|s,l| l == long}.collect{|s,l| s }.first
6
- return current if current
7
-
8
- chars = long.chars.to_a
9
- current = [chars.shift]
10
- short = current * ""
11
-
12
- if (shortcuts.include?(short) and not shortcuts[short] == long)
13
- if long.index "-" or long.index "_"
14
- parts = long.split(/[_-]/)
15
- acc = parts.collect{|s| s[0] } * ""
16
- return acc unless shortcuts.include? acc
17
- elsif m = long.match(/(\d+)/)
18
- n = m[0]
19
- acc = long[0] + n
20
- return acc unless shortcuts.include? acc
21
- end
22
- end
23
-
24
- while shortcuts.include?(short) && shortcuts[short] != long
25
- next_letter = chars.shift
26
- next_letter = chars.shift while %w(. - _).include?(next_letter)
27
- return nil if next_letter.nil?
28
- current << next_letter
29
- short = current * ""
30
- end
31
-
32
- return nil if shortcuts.include? short
33
-
34
- short
35
- end
36
-
37
- def self.register(short, long, asterisk, description)
38
- short = fix_shortcut(short, long)
39
- shortcuts[short] = long if short
40
- inputs << long
41
- input_shortcuts[long] = short
42
- input_descriptions[long] = description
43
- input_types[long] = asterisk ? :string : :boolean
44
- end
45
-
46
- def self.parse(opt_str)
47
- inputs = []
48
-
49
- if opt_str.include? "\n"
50
- re = /\n+/
51
- else
52
- re = /:/
53
- end
54
-
55
- opt_str.split(re).each do |entry|
56
- entry.strip!
57
- next if entry.empty?
58
- names, _sep, description = entry.partition(/\s+/)
59
- short, long, asterisk = names.match(/\s*(?:-(.+))?(?:--(.+?))([*])?$/).values_at 1,2,3
60
-
61
- inputs << long
62
- register short, long, asterisk, description
63
- end
64
-
65
- inputs
66
- end
67
- end
@@ -1,26 +0,0 @@
1
- module SOPT
2
-
3
- def self.setup(str)
4
- parts = str.split(/\n\n+/)
5
-
6
- summary = parts.shift unless parts.first =~ /^\s*\$-/
7
- synopsys = parts.shift if parts.first =~ /^\s*\$/
8
-
9
- description = []
10
- while parts.first and parts.first !~ /^\s*-/
11
- description << parts.shift
12
- end
13
- description = description * "\n\n"
14
-
15
- options = parts.collect{|part| part.split("\n").select{|l| l=~ /^\s*-/ } }.flatten.compact * "\n"
16
-
17
- synopsys.sub!(/^\$\s+/,'') if synopsys
18
-
19
- SOPT.summary = summary.strip if summary
20
- SOPT.synopsys = synopsys.strip if synopsys
21
- SOPT.description = description.strip if description
22
- SOPT.parse options if options
23
-
24
- SOPT.consume
25
- end
26
- end
@@ -1,5 +0,0 @@
1
- require_relative 'simple_opt/accessor'
2
- require_relative 'simple_opt/parse'
3
- require_relative 'simple_opt/doc'
4
- require_relative 'simple_opt/get'
5
- require_relative 'simple_opt/setup'
data/lib/scout/tmpfile.rb DELETED
@@ -1,129 +0,0 @@
1
- require_relative 'misc'
2
- require_relative 'log'
3
- require 'fileutils'
4
-
5
- module TmpFile
6
- MAX_FILE_LENGTH = 150
7
-
8
- def self.user_tmp(subdir = nil)
9
- if subdir
10
- File.join(ENV["HOME"],"/tmp/scout", subdir)
11
- else
12
- File.join(ENV["HOME"],"/tmp/scout")
13
- end
14
- end
15
-
16
- def self.tmpdir=(tmpdir)
17
- @tmpdir = tmpdir
18
- end
19
-
20
- def self.tmpdir
21
- @tmpdir ||= self.user_tmp('tmpfiles')
22
- end
23
-
24
- # Creates a random file name, with the given suffix and a random number
25
- # up to +max+
26
- def self.random_name(prefix = 'tmp-', max = 1_000_000_000)
27
- n = rand(max)
28
- prefix + n.to_s
29
- end
30
-
31
- # Creates a random filename in the temporary directory
32
- def self.tmp_file(prefix = 'tmp-', max = 1_000_000_000, dir = nil)
33
- dir ||= TmpFile.tmpdir
34
- File.expand_path(File.join(dir, random_name(prefix, max)))
35
- end
36
-
37
- def self.with_file(content = nil, erase = true, options = {})
38
- if content.is_a?(Hash)
39
- options = content
40
- content = nil
41
- erase = true
42
- end
43
- if erase.is_a?(Hash)
44
- options = erase
45
- erase = true
46
- end
47
-
48
- prefix = options[:prefix] || 'tmp-'
49
- tmpdir = options[:tmpdir] || TmpFile.tmpdir
50
- max = options[:max] || 1_000_000_000
51
- tmpfile = tmp_file prefix, max, tmpdir
52
- tmpfile += ".#{options[:extension]}" if options[:extension]
53
-
54
- FileUtils.mkdir_p tmpdir
55
- if IO === content
56
- File.open(tmpfile, 'wb') do |f|
57
- begin
58
- while c = content.readpartial(1024)
59
- f << c
60
- end
61
- rescue EOFError
62
- end
63
- end
64
- elsif !content.nil?
65
- File.open(tmpfile, 'w') { |f| f.write content }
66
- end
67
-
68
- result = yield(tmpfile)
69
-
70
- FileUtils.rm_rf tmpfile if File.exist?(tmpfile) && erase
71
-
72
- result
73
- end
74
-
75
- def self.with_dir(erase = true, options = {})
76
- prefix = options[:prefix] || 'tmpdir-'
77
- tmpdir = tmp_file prefix
78
-
79
- FileUtils.mkdir_p tmpdir
80
-
81
- result = yield(tmpdir)
82
-
83
- FileUtils.rm_rf tmpdir if File.exist?(tmpdir) && erase
84
-
85
- result
86
- end
87
-
88
- def self.in_dir(*args)
89
- with_dir(*args) do |dir|
90
- Misc.in_dir dir do
91
- yield dir
92
- end
93
- end
94
- end
95
-
96
- SLASH_REPLACE = '·'
97
- def self.tmp_for_file(file, tmp_options = {}, other_options = {})
98
- tmp_for_file, prefix, key, persistence_dir = IndiferentHash.process_options tmp_options, :file, :prefix, :key, :dir
99
- return tmp_for_file unless tmp_for_file.nil?
100
-
101
- if prefix.nil?
102
- perfile = file.to_s.sub(/\.b?gz$/,'')
103
- else
104
- perfile = prefix.to_s + ":" + file.to_s.sub(/\.b?gz$/,'')
105
- end
106
-
107
- perfile += "[#{ key }]" if key
108
-
109
- if other_options.include? :filters
110
- other_options[:filters].each do |match,value|
111
- perfile = perfile + "&F[#{match}=#{Misc.digest(value)}]"
112
- end
113
- end
114
-
115
- persistence_dir = TmpFile.tmpdir if persistence_dir.nil?
116
- Path.setup(persistence_dir) unless Path === persistence_dir
117
-
118
- filename = perfile.gsub(/\s/,'_').gsub('/', SLASH_REPLACE)
119
- clean_options = other_options.dup
120
- clean_options.delete :unnamed
121
- clean_options.delete "unnamed"
122
-
123
- filename = filename[0..MAX_FILE_LENGTH] << Misc.digest(filename[MAX_FILE_LENGTH+1..-1]) if filename.length > MAX_FILE_LENGTH + 10
124
-
125
- filename += ":" << Misc.digest(clean_options) unless clean_options.empty?
126
-
127
- persistence_dir[filename]
128
- end
129
- end
@@ -1,16 +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 TestCaseInsensitiveHash < Test::Unit::TestCase
5
- def test_case_insensitive_hash
6
- a = {:a => 1, "b" => 2}
7
- a.extend CaseInsensitiveHash
8
-
9
- assert_equal 1, a[:a]
10
- assert_equal 1, a["A"]
11
- assert_equal 1, a[:A]
12
- assert_equal 2, a["B"]
13
- assert_equal 2, a[:b]
14
- end
15
- end
16
-
@@ -1,46 +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 TestOptions < Test::Unit::TestCase
5
-
6
-
7
- def test_add_defaults
8
- options = {:a => 1, "b" => 2}
9
- assert_equal 2, IndiferentHash.add_defaults(options, :b => 3)["b"]
10
- assert_equal 2, IndiferentHash.add_defaults(options, "b" => 3)["b"]
11
- assert_equal 3, IndiferentHash.add_defaults(options, :c => 3)["c"]
12
- assert_equal 3, IndiferentHash.add_defaults(options, "c" => 4)[:c]
13
- assert_equal 3, IndiferentHash.add_defaults(options, "c" => 4)["c"]
14
- end
15
-
16
- def test_positions2hash
17
- inputs = IndiferentHash.positional2hash([:one, :two, :three], 1, :two => 2, :four => 4)
18
- assert_equal 1, inputs[:one]
19
- assert_equal 2, inputs[:two]
20
- assert_equal nil, inputs[:three]
21
- assert_equal nil, inputs[:four]
22
- end
23
-
24
- def test_process_to_hash
25
- list = [1,2,3,4]
26
- assert_equal 4, IndiferentHash.process_to_hash(list){|l| l.collect{|e| e * 2 } }[2]
27
- end
28
-
29
- def test_hash2string
30
- hash = {}
31
- assert_equal hash, IndiferentHash.string2hash(IndiferentHash.hash2string(hash))
32
-
33
- hash = {:a => 1}
34
- assert_equal hash, IndiferentHash.string2hash(IndiferentHash.hash2string(hash))
35
-
36
- hash = {:a => true}
37
- assert_equal hash, IndiferentHash.string2hash(IndiferentHash.hash2string(hash))
38
-
39
- hash = {:a => :b}
40
- assert_equal hash, IndiferentHash.string2hash(IndiferentHash.hash2string(hash))
41
-
42
- hash = {:a => /test/}
43
- assert_equal({}, IndiferentHash.string2hash(IndiferentHash.hash2string(hash)))
44
- end
45
- end
46
-
@@ -1,108 +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 TestProgress < Test::Unit::TestCase
5
- SLEEP_TIME=0.0001
6
- def test_bar
7
- t1 = Thread.new do
8
- Log::ProgressBar.with_bar(20, :desc => "Bar 1") do |bar|
9
- 20.times do
10
- bar.tick
11
- sleep SLEEP_TIME
12
- end
13
- Log.debug "Done progress"
14
- assert_equal 100, bar.percent
15
- end
16
- end
17
-
18
- t2 = Thread.new do
19
- Log::ProgressBar.with_bar(20, :desc => "Bar 2") do |bar|
20
- 20.times do
21
- bar.tick
22
- sleep SLEEP_TIME
23
- end
24
- Log.debug "Done progress"
25
- assert_equal 100, bar.percent
26
- end
27
- end
28
- t1.join
29
- t2.join
30
- end
31
-
32
- def test_bar_no_size
33
- t1 = Thread.new do
34
- Log::ProgressBar.with_bar(nil, :desc => "Bar 1", :frequency => 0) do |bar|
35
- 20.times do
36
- bar.tick
37
- sleep SLEEP_TIME
38
- end
39
- assert bar.history.length > 0
40
- end
41
- end
42
-
43
- t2 = Thread.new do
44
- Log::ProgressBar.with_bar(nil, :desc => "Bar 2", :frequency => 0) do |bar|
45
- 20.times do
46
- bar.tick
47
- sleep SLEEP_TIME
48
- end
49
- assert bar.history.length > 0
50
- end
51
- end
52
- t1.join
53
- t2.join
54
- end
55
-
56
- def test_bar_nested
57
- Log::ProgressBar.with_bar(20, :desc => "Bar 1") do |bar|
58
- bar.init
59
- 20.times do
60
- Log::ProgressBar.with_bar(5, :desc => "Bar 2") do |bar|
61
- 5.times do
62
- bar.tick
63
- sleep SLEEP_TIME
64
- end
65
- end
66
- bar.tick
67
- sleep SLEEP_TIME
68
- end
69
- end
70
- end
71
-
72
- def test_pos
73
- size = 10000
74
-
75
- Log::ProgressBar.with_bar(size, :desc => "Bar 1") do |bar|
76
- bar.init
77
- nums = []
78
- 100.times do
79
- nums << rand(size)
80
- end
81
- nums.sort.each do |num|
82
- bar.pos num
83
- sleep SLEEP_TIME
84
- end
85
- bar.tick
86
- end
87
- end
88
-
89
- def test_file
90
- size = 10000
91
-
92
- TmpFile.with_file do |file|
93
-
94
- Log::ProgressBar.with_bar(size, :desc => "Bar 1", :file => file) do |bar|
95
- bar.init
96
- nums = []
97
- 100.times do
98
- nums << rand(size)
99
- end
100
- nums.sort.each do |num|
101
- bar.pos num
102
- sleep SLEEP_TIME
103
- end
104
- bar.tick
105
- end
106
- end
107
- end
108
- end
@@ -1,30 +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 TestMiscDigest < Test::Unit::TestCase
5
- def test_digest_str
6
- o = {:a => [1,2,3], :b => [1.1, 0.00001, 'hola']}
7
- assert Misc.digest_str(o).include? "hola"
8
- end
9
-
10
- def test_digest_stream_located
11
- TmpFile.with_file("TEST") do |filename|
12
- Open.open(filename) do |f|
13
- assert_equal 32, Misc.digest_str(f).length
14
- end
15
- end
16
- end
17
-
18
- def test_digest_stream_unlocated
19
- TmpFile.with_file do |directory|
20
- Path.setup(directory)
21
- Open.write(directory.share.file, "TEST")
22
- Misc.in_dir directory do
23
- Open.open(Path.setup('share/file')) do |f|
24
- assert_equal '\'share/file\'', Misc.digest_str(Path.setup('share/file'))
25
- end
26
- end
27
- end
28
- end
29
- end
30
-
@@ -1,30 +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 TestFilesystem < Test::Unit::TestCase
5
- def test_in_dir
6
- TmpFile.with_file do |tmpdir|
7
- Misc.in_dir tmpdir do
8
- assert_equal tmpdir, FileUtils.pwd
9
- end
10
- end
11
- end
12
-
13
- def test_relative
14
- assert_equal 'bar', Misc.path_relative_to("/tmp/foo", "/tmp/foo/bar")
15
- assert_equal 'bar/other', Misc.path_relative_to("/tmp/foo", "/tmp/foo/bar/other")
16
-
17
- refute Misc.path_relative_to("/tmp/bar", "/tmp/foo/bar/other")
18
- refute Misc.path_relative_to("/tmp/foo", "tmp/foo/bar/other")
19
-
20
- TmpFile.with_file do |tmpdir|
21
- Misc.in_dir tmpdir do
22
- assert Misc.path_relative_to(tmpdir, "foo")
23
- assert Misc.path_relative_to(tmpdir, File.join(tmpdir, "foo"))
24
- end
25
- assert Misc.path_relative_to(tmpdir, File.join(tmpdir, "foo"))
26
- assert Misc.path_relative_to(File.dirname(tmpdir), File.join(tmpdir, "foo"))
27
- end
28
- end
29
- end
30
-
@@ -1,13 +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 TestMiscInsist < Test::Unit::TestCase
5
- def test_insist
6
- i = 0
7
- Misc.insist do
8
- i += 1
9
- raise "Not yet" if i < 3
10
- end
11
- end
12
- end
13
-
@@ -1,21 +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 TestMiscSystem < Test::Unit::TestCase
5
- setup do
6
- ENV.delete "TEST_VAR"
7
- end
8
-
9
- def test_env_add
10
- Misc.env_add "TEST_VAR", "test_value1"
11
- Misc.env_add "TEST_VAR", "test_value2"
12
- assert_equal "test_value2:test_value1", ENV["TEST_VAR"]
13
- end
14
-
15
- def test_env_add_prepend
16
- Misc.env_add "TEST_VAR", "test_value1", ":", false
17
- Misc.env_add "TEST_VAR", "test_value2", ":", false
18
- assert_equal "test_value1:test_value2", ENV["TEST_VAR"]
19
- end
20
- end
21
-
@@ -1,52 +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/tmpfile'
5
-
6
- class TestLock < Test::Unit::TestCase
7
- def test_locks
8
- num = 10
9
- TmpFile.with_file do |lockfile|
10
- TmpFile.with_file do |output|
11
- f = File.open(output, 'w')
12
- thrs = num.times.collect do
13
- Thread.new do
14
- Open.lock lockfile, true, min_sleep: 0.01, max_sleep: 0.05, sleep_inc: 0.001 do
15
- f.write "["
16
- sleep 0.01
17
- f.write "]"
18
- end
19
- end
20
- end
21
- thrs.each{|t| t.join }
22
- f.close
23
- assert_equal "[]" * num, File.open(output).read
24
- end
25
- end
26
- end
27
-
28
- def test_keep_locked
29
- num = 10
30
- TmpFile.with_file do |lockfile|
31
- TmpFile.with_file do |output|
32
- f = File.open(output, 'w')
33
- thrs = num.times.collect do
34
- Thread.new do
35
- lock = Lockfile.new(lockfile, min_sleep: 0.01, max_sleep: 0.05, sleep_inc: 0.001)
36
- res = Open.lock lock do
37
- f.write "["
38
- raise KeepLocked, "1"
39
- end
40
- f.write res
41
- f.write "]"
42
- lock.unlock
43
- end
44
- end
45
- thrs.each{|t| t.join }
46
- f.close
47
- assert_equal "[1]" * num, File.open(output).read
48
- end
49
- end
50
- end
51
- end
52
-
@@ -1,25 +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/open'
5
-
6
- class TestOpenRemote < Test::Unit::TestCase
7
- def test_wget
8
- teardown
9
- 5.times do
10
- assert(Misc.fixutf8(Open.wget('http://google.com', :quiet => true, :nocache => true).read) =~ /html/)
11
- assert(Misc.fixutf8(Open.wget('http://google.com', :quiet => true).read) =~ /html/)
12
- end
13
- end
14
-
15
- def test_ssh
16
- TmpFile.with_file("TEST") do |f|
17
- begin
18
- assert_equal "TEST", Open.ssh("ssh://localhost:#{f}").read
19
- rescue ConcurrentStreamProcessFailed
20
- raise $! unless $!.message.include? "Connection refused"
21
- end
22
- end if false
23
- end
24
- end
25
-