scout-gear 9.1.0 → 10.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +3 -3
  3. data/Rakefile +1 -2
  4. data/VERSION +1 -1
  5. data/lib/scout/offsite/exceptions.rb +9 -0
  6. data/lib/scout/offsite/ssh.rb +1 -0
  7. data/lib/scout/semaphore.rb +2 -0
  8. data/lib/scout/tsv/open.rb +1 -1
  9. data/lib/scout/tsv/parser.rb +1 -1
  10. data/lib/scout/tsv/persist/adapter.rb +2 -2
  11. data/lib/scout/tsv/persist.rb +1 -0
  12. data/lib/scout/tsv.rb +1 -1
  13. data/lib/scout/work_queue/exceptions.rb +18 -0
  14. data/lib/scout/work_queue.rb +1 -0
  15. data/lib/scout/workflow/definition.rb +1 -1
  16. data/lib/scout/workflow/step/config.rb +1 -1
  17. data/lib/scout/workflow/step.rb +2 -2
  18. data/lib/scout/workflow/task/inputs.rb +1 -1
  19. data/lib/scout/workflow/task.rb +2 -2
  20. data/lib/scout/workflow.rb +2 -2
  21. data/lib/scout-gear.rb +1 -10
  22. data/scout-gear.gemspec +8 -98
  23. data/test/scout/workflow/task/test_inputs.rb +0 -4
  24. metadata +7 -110
  25. data/lib/scout/cmd.rb +0 -347
  26. data/lib/scout/concurrent_stream.rb +0 -284
  27. data/lib/scout/config.rb +0 -168
  28. data/lib/scout/exceptions.rb +0 -151
  29. data/lib/scout/indiferent_hash/case_insensitive.rb +0 -30
  30. data/lib/scout/indiferent_hash/options.rb +0 -115
  31. data/lib/scout/indiferent_hash.rb +0 -96
  32. data/lib/scout/log/color.rb +0 -224
  33. data/lib/scout/log/color_class.rb +0 -269
  34. data/lib/scout/log/fingerprint.rb +0 -69
  35. data/lib/scout/log/progress/report.rb +0 -244
  36. data/lib/scout/log/progress/util.rb +0 -173
  37. data/lib/scout/log/progress.rb +0 -106
  38. data/lib/scout/log/trap.rb +0 -107
  39. data/lib/scout/log.rb +0 -441
  40. data/lib/scout/meta_extension.rb +0 -100
  41. data/lib/scout/misc/digest.rb +0 -63
  42. data/lib/scout/misc/filesystem.rb +0 -25
  43. data/lib/scout/misc/format.rb +0 -255
  44. data/lib/scout/misc/helper.rb +0 -31
  45. data/lib/scout/misc/insist.rb +0 -56
  46. data/lib/scout/misc/monitor.rb +0 -66
  47. data/lib/scout/misc/system.rb +0 -73
  48. data/lib/scout/misc.rb +0 -10
  49. data/lib/scout/named_array.rb +0 -138
  50. data/lib/scout/open/lock/lockfile.rb +0 -587
  51. data/lib/scout/open/lock.rb +0 -68
  52. data/lib/scout/open/remote.rb +0 -135
  53. data/lib/scout/open/stream.rb +0 -491
  54. data/lib/scout/open/util.rb +0 -244
  55. data/lib/scout/open.rb +0 -170
  56. data/lib/scout/path/find.rb +0 -204
  57. data/lib/scout/path/tmpfile.rb +0 -8
  58. data/lib/scout/path/util.rb +0 -127
  59. data/lib/scout/path.rb +0 -51
  60. data/lib/scout/persist/open.rb +0 -17
  61. data/lib/scout/persist/path.rb +0 -15
  62. data/lib/scout/persist/serialize.rb +0 -157
  63. data/lib/scout/persist.rb +0 -104
  64. data/lib/scout/resource/open.rb +0 -8
  65. data/lib/scout/resource/path.rb +0 -80
  66. data/lib/scout/resource/produce/rake.rb +0 -69
  67. data/lib/scout/resource/produce.rb +0 -151
  68. data/lib/scout/resource/scout.rb +0 -3
  69. data/lib/scout/resource/software.rb +0 -178
  70. data/lib/scout/resource/util.rb +0 -59
  71. data/lib/scout/resource.rb +0 -41
  72. data/lib/scout/simple_opt/accessor.rb +0 -54
  73. data/lib/scout/simple_opt/doc.rb +0 -126
  74. data/lib/scout/simple_opt/get.rb +0 -57
  75. data/lib/scout/simple_opt/parse.rb +0 -67
  76. data/lib/scout/simple_opt/setup.rb +0 -26
  77. data/lib/scout/simple_opt.rb +0 -5
  78. data/lib/scout/tmpfile.rb +0 -129
  79. data/test/scout/indiferent_hash/test_case_insensitive.rb +0 -16
  80. data/test/scout/indiferent_hash/test_options.rb +0 -46
  81. data/test/scout/log/test_progress.rb +0 -108
  82. data/test/scout/misc/test_digest.rb +0 -30
  83. data/test/scout/misc/test_filesystem.rb +0 -30
  84. data/test/scout/misc/test_insist.rb +0 -13
  85. data/test/scout/misc/test_system.rb +0 -21
  86. data/test/scout/open/test_lock.rb +0 -52
  87. data/test/scout/open/test_remote.rb +0 -25
  88. data/test/scout/open/test_stream.rb +0 -676
  89. data/test/scout/open/test_util.rb +0 -73
  90. data/test/scout/path/test_find.rb +0 -119
  91. data/test/scout/path/test_util.rb +0 -22
  92. data/test/scout/persist/test_open.rb +0 -37
  93. data/test/scout/persist/test_path.rb +0 -37
  94. data/test/scout/persist/test_serialize.rb +0 -114
  95. data/test/scout/resource/test_path.rb +0 -46
  96. data/test/scout/resource/test_produce.rb +0 -92
  97. data/test/scout/resource/test_software.rb +0 -24
  98. data/test/scout/resource/test_util.rb +0 -36
  99. data/test/scout/simple_opt/test_doc.rb +0 -16
  100. data/test/scout/simple_opt/test_get.rb +0 -11
  101. data/test/scout/simple_opt/test_parse.rb +0 -10
  102. data/test/scout/simple_opt/test_setup.rb +0 -77
  103. data/test/scout/test_cmd.rb +0 -85
  104. data/test/scout/test_concurrent_stream.rb +0 -29
  105. data/test/scout/test_config.rb +0 -66
  106. data/test/scout/test_indiferent_hash.rb +0 -26
  107. data/test/scout/test_log.rb +0 -32
  108. data/test/scout/test_meta_extension.rb +0 -80
  109. data/test/scout/test_misc.rb +0 -6
  110. data/test/scout/test_named_array.rb +0 -43
  111. data/test/scout/test_open.rb +0 -146
  112. data/test/scout/test_path.rb +0 -54
  113. data/test/scout/test_persist.rb +0 -186
  114. data/test/scout/test_resource.rb +0 -26
  115. data/test/scout/test_tmpfile.rb +0 -53
  116. /data/test/scout/{log/test_color.rb → test_offsite.rb} +0 -0
@@ -1,77 +0,0 @@
1
- require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
- require 'scout/simple_opt'
3
- require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
4
-
5
- class TestSOPTSetup < Test::Unit::TestCase
6
- def setup
7
- SOPT.inputs = nil
8
- SOPT.input_types = nil
9
- SOPT.input_descriptions = nil
10
- SOPT.input_shortcuts = nil
11
- end
12
-
13
- def test_setup
14
- SOPT.setup <<-EOF
15
- Test application
16
-
17
- $ test cmd -arg 1
18
-
19
- It does some imaginary stuff
20
-
21
- -a--arg* Argument
22
- -a2--arg2* Argument
23
-
24
- EOF
25
-
26
- assert_equal "test cmd -arg 1", SOPT.synopsys
27
- assert SOPT.inputs.include? "arg"
28
- assert SOPT.inputs.include? "arg2"
29
- end
30
-
31
- def test_setup_alt
32
- SOPT.setup <<-EOF
33
- Test application
34
-
35
- It does some imaginary stuff
36
-
37
- -a--arg* Argument
38
- -a2--arg2* Argument
39
-
40
- EOF
41
-
42
- assert SOPT.inputs.include? "arg"
43
- assert SOPT.inputs.include? "arg2"
44
- end
45
-
46
- def test_setup_alt2
47
- SOPT.setup <<-EOF
48
- Test application
49
-
50
- -a--arg* Argument
51
- -a2--arg2* Argument
52
-
53
- EOF
54
-
55
- assert SOPT.inputs.include? "arg"
56
- assert SOPT.inputs.include? "arg2"
57
- end
58
-
59
- def test_setup_alt3
60
- SOPT.setup <<-EOF
61
- Pulls the values from a tsv colum
62
-
63
- $ rbbt tsv values [options] <filename.tsv|->
64
-
65
- Use - to read from STDIN
66
-
67
- -tch--tokyocabinet File is a tokyocabinet hash database
68
- -tcb--tokyocabinet_bd File is a tokyocabinet B database
69
- -h--help Print this help
70
- EOF
71
-
72
- assert SOPT.inputs.include? "tokyocabinet"
73
- end
74
-
75
- end
76
-
77
-
@@ -1,85 +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 TestCmd < Test::Unit::TestCase
7
-
8
- def test_cmd_option_string
9
- assert_equal("--user-agent 'firefox'", CMD.process_cmd_options("--user-agent" => "firefox"))
10
- assert_equal("--user-agent='firefox'", CMD.process_cmd_options("--user-agent=" => "firefox"))
11
- assert_equal("-q", CMD.process_cmd_options("-q" => true))
12
- assert_equal("", CMD.process_cmd_options("-q" => nil))
13
- assert_equal("", CMD.process_cmd_options("-q" => false))
14
-
15
- assert(CMD.process_cmd_options("--user-agent" => "firefox", "-q" => true) =~ /--user-agent 'firefox'/)
16
- assert(CMD.process_cmd_options("--user-agent" => "firefox", "-q" => true) =~ /-q/)
17
- end
18
-
19
- def test_cmd
20
- assert_equal("test\n", CMD.cmd("echo '{opt}' test").read)
21
- assert_equal("test", CMD.cmd("echo '{opt}' test", "-n" => true).read)
22
- assert_equal("test2\n", CMD.cmd("cut", "-f" => 2, "-d" => ' ', :in => "test1 test2").read)
23
- end
24
-
25
- def test_pipe
26
- assert_equal("test\n", CMD.cmd("echo test", :pipe => true).read)
27
- assert_equal("test\n", CMD.cmd("echo '{opt}' test", :pipe => true).read)
28
- assert_equal("test", CMD.cmd("echo '{opt}' test", "-n" => true, :pipe => true).read)
29
- assert_equal("test2\n", CMD.cmd("cut", "-f" => 2, "-d" => ' ', :in => "test1 test2", :pipe => true).read)
30
- end
31
-
32
- def test_error
33
- Log.with_severity 6 do
34
- assert_raise ProcessFailed do CMD.cmd('fake-command') end
35
- assert_raise ProcessFailed do CMD.cmd('ls -fake_option') end
36
-
37
- assert_raise ProcessFailed do CMD.cmd('fake-command', :stderr => true) end
38
- assert_raise ProcessFailed do CMD.cmd('ls -fake_option', :stderr => true) end
39
-
40
- assert_nothing_raised ProcessFailed do CMD.cmd('fake-command', :no_fail => true, :pipe => true) end
41
- assert_nothing_raised ProcessFailed do CMD.cmd('ls -fake_option', :no_fail => true, :pipe => true) end
42
-
43
- assert_raise ProcessFailed do CMD.cmd('fake-command', :stderr => true, :pipe => true).join end
44
- assert_raise ConcurrentStreamProcessFailed do CMD.cmd('ls -fake_option', :stderr => true, :pipe => true).join end
45
- end
46
- end
47
-
48
- def test_pipes
49
- text = <<-EOF
50
- line1
51
- line2
52
- line3
53
- line11
54
- line22
55
- line33
56
- EOF
57
-
58
- TmpFile.with_file(text * 100) do |file|
59
-
60
- Open.open(file) do |f|
61
- io = CMD.cmd('tail -n 10', :in => f, :pipe => true)
62
- io2 = CMD.cmd('head -n 10', :in => io, :pipe => true)
63
- io3 = CMD.cmd('head -n 10', :in => io2, :pipe => true)
64
- assert_equal 10, io3.read.split(/\n/).length
65
- end
66
- end
67
- end
68
-
69
- def test_STDIN_close
70
- TmpFile.with_file("Hello") do |file|
71
- STDIN.close
72
- Open.open(file) do |f|
73
- io = CMD.cmd("tr 'e' 'E'", :in => f, :pipe => true)
74
- txt = io.read
75
- io.join
76
- assert_equal "HEllo", txt
77
- end
78
- end
79
- end
80
-
81
- def test_bash
82
- assert_equal "TEST", CMD.bash("echo TEST").read.strip
83
- assert_equal ENV["HOME"], CMD.bash("echo $HOME").read.strip
84
- end
85
- end
@@ -1,29 +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/exceptions'
5
- require 'scout/cmd'
6
-
7
- class TestClass < Test::Unit::TestCase
8
- def test_concurrent_stream_pipe
9
- io = CMD.cmd("ls", :pipe => true, :autojoin => true)
10
- io.read
11
- io.close
12
- end
13
-
14
- def test_concurrent_stream_process_failed
15
- assert_raise ConcurrentStreamProcessFailed do
16
- io = CMD.cmd("grep . NONEXISTINGFILE", :pipe => true, :autojoin => true)
17
- io.read
18
- io.close
19
- end
20
- end
21
-
22
- def test_concurrent_stream_process_failed_autojoin
23
- assert_raise ConcurrentStreamProcessFailed do
24
- io = CMD.cmd("grep . NONEXISTINGFILE", :pipe => true, :autojoin => true)
25
- io.read
26
- end
27
- end
28
- end
29
-
@@ -1,66 +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 TestConfig < Test::Unit::TestCase
5
- setup do
6
- Scout::Config.set({:cpus => 30}, :test_config, :test)
7
- Scout::Config.set(:cpus, 5, "slow::2", :test)
8
- Scout::Config.set({:token => "token"}, "token")
9
- Scout::Config.set(:notoken, "no_token")
10
- Scout::Config.set({:emptytoken => "empty"})
11
- end
12
-
13
- def test_simple
14
- assert_equal 30, Scout::Config.get(:cpus, :test_config)
15
- end
16
-
17
- def test_match
18
- assert_equal({20 => ["token"]}, Scout::Config.match({["key:token"] => "token"}, "key:token"))
19
- end
20
-
21
- def test_simple_no_token
22
- assert_equal "token", Scout::Config.get("token", "token")
23
- assert_equal "no_token", Scout::Config.get("notoken", "key:notoken")
24
- assert_equal 'token', Scout::Config.get("token", "key:token")
25
- assert_equal 'token', Scout::Config.get("token")
26
- assert_equal nil, Scout::Config.get("token", "someotherthing")
27
- assert_equal "default_token", Scout::Config.get("token", 'unknown', :default => 'default_token')
28
- assert_equal 'empty', Scout::Config.get("emptytoken", 'key:emptytoken')
29
- end
30
-
31
- def test_prio
32
- assert_equal 5, Scout::Config.get(:cpus, :slow, :test)
33
- end
34
-
35
- def test_with_config
36
- Scout::Config.add_entry 'key', 'valueA', 'token'
37
- assert_equal "valueA", Scout::Config.get('key', 'token')
38
- assert_equal "default", Scout::Config.get('key2', 'token', :default => 'default')
39
-
40
- Scout::Config.with_config do
41
- Scout::Config.add_entry 'key', 'valueB', 'token'
42
- Scout::Config.add_entry 'key2', 'valueB2', 'token'
43
- assert_equal "valueB", Scout::Config.get('key', 'token')
44
- assert_equal "valueB2", Scout::Config.get('key2', 'token', :default => 'default')
45
- end
46
-
47
- assert_equal "valueA", Scout::Config.get('key', 'token')
48
- assert_equal "default", Scout::Config.get('key2', 'token', :default => 'default')
49
- end
50
-
51
- def test_order
52
- Scout::Config.add_entry 'key', 'V1', 'token1'
53
- Scout::Config.add_entry 'key', 'V2', 'token2'
54
- Scout::Config.add_entry 'key', 'V3', 'token2'
55
-
56
- assert_equal "V3", Scout::Config.get('key', 'token2')
57
- assert_equal "V1", Scout::Config.get('key', 'token1')
58
- assert_equal "V3", Scout::Config.get('key', 'token2', 'token1')
59
- assert_equal "V1", Scout::Config.get('key', 'token1', 'token2')
60
- end
61
-
62
- def test_default
63
- Scout::Config.add_entry 'key', 'V1', 'token1'
64
- assert_equal "V3", Scout::Config.get('key', 'token2', :default => 'V3')
65
- end
66
- end
@@ -1,26 +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 TestClass < Test::Unit::TestCase
5
- def test_indiferent_hash
6
- a = {:a => 1, "b" => 2}
7
- a.extend IndiferentHash
8
-
9
- assert_equal 1, a[:a]
10
- assert_equal 1, a["a"]
11
- assert_equal 2, a["b"]
12
- assert_equal 2, a[:b]
13
- end
14
-
15
- def test_case_insensitive_hash
16
- a = {:a => 1, "b" => 2}
17
- a.extend CaseInsensitiveHash
18
-
19
- assert_equal 1, a[:a]
20
- assert_equal 1, a["A"]
21
- assert_equal 1, a[:A]
22
- assert_equal 2, a["B"]
23
- assert_equal 2, a[:b]
24
- end
25
- end
26
-
@@ -1,32 +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 TestLog < Test::Unit::TestCase
5
- def test_get_level
6
- assert_equal 0, Log.get_level(:debug)
7
- assert_equal 1, Log.get_level(:low)
8
- assert_equal 1, Log.get_level("LOW")
9
- assert_equal 1, Log.get_level(1)
10
- assert_equal 0, Log.get_level(nil)
11
- end
12
-
13
- def test_color
14
- assert Log.color(:green, "green")
15
- end
16
-
17
- def test_iif
18
- TmpFile.with_file do |tmp|
19
- Log.logfile(tmp)
20
- iif :foo
21
- assert File.read(tmp).include? ":foo"
22
- assert File.read(tmp).include? "INFO"
23
- end
24
- end
25
-
26
- def test_tty_size
27
- assert Integer === Log.tty_size
28
- end
29
-
30
- end
31
-
32
-
@@ -1,80 +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 TestMetaExtension < Test::Unit::TestCase
5
- module ExtensionClass
6
- extend MetaExtension
7
-
8
- extension_attr :code, :code2
9
- end
10
-
11
- module ExtensionClass2
12
- extend MetaExtension
13
-
14
- extension_attr :code3, :code4
15
- end
16
-
17
-
18
- def test_setup_annotate
19
- str = "String"
20
- ExtensionClass.setup(str, :code)
21
- assert ExtensionClass === str
22
- assert_equal :code, str.code
23
-
24
- str2 = "String2"
25
- str.annotate(str2)
26
- assert_equal :code, str2.code
27
- end
28
-
29
- def test_marshal
30
- str = "String"
31
- ExtensionClass.setup(str, :code)
32
- assert ExtensionClass === str
33
- assert_equal :code, str.code
34
-
35
- str2 = Marshal.load(Marshal.dump(str))
36
- assert_equal :code, str2.code
37
- end
38
-
39
- def test_setup_alternatives
40
- str = "String"
41
-
42
- ExtensionClass.setup(str, :code2 => :code)
43
- assert_equal :code, str.code2
44
-
45
- ExtensionClass.setup(str, code2: :code)
46
- assert_equal :code, str.code2
47
-
48
- ExtensionClass.setup(str, "code2" => :code)
49
- assert_equal :code, str.code2
50
-
51
- end
52
-
53
- def test_setup_block
54
- o = ExtensionClass.setup nil, :code => :c, :code2 => :c2 do
55
- puts 1
56
- end
57
-
58
- assert o.extension_attr_hash.include?(:code)
59
- assert o.extension_attr_hash.include?(:code2)
60
- end
61
-
62
- def test_twice
63
- str = "String"
64
-
65
- ExtensionClass.setup(str, :code2 => :code)
66
- assert_equal :code, str.code2
67
- assert_include str.instance_variable_get(:@extension_attrs), :code
68
-
69
- str.extend ExtensionClass2
70
- str.code3 = :code_alt
71
- assert_equal :code, str.code2
72
- assert_equal :code_alt, str.code3
73
- assert_include str.instance_variable_get(:@extension_attrs), :code
74
- assert_include str.instance_variable_get(:@extension_attrs), :code3
75
-
76
- assert_include str.extension_attr_hash, :code
77
- assert_include str.extension_attr_hash, :code3
78
- end
79
- end
80
-
@@ -1,6 +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 TestMisc < Test::Unit::TestCase
5
- end
6
-
@@ -1,43 +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 TestNamedArray < Test::Unit::TestCase
5
- def test_identify_names
6
- names =<<-EOF.split("\n")
7
- ValueA
8
- ValueB (Entity type)
9
- 15
10
- EOF
11
- assert_equal 0, NamedArray.identify_name(names, "ValueA")
12
- assert_equal :key, NamedArray.identify_name(names, :key)
13
- assert_equal 0, NamedArray.identify_name(names, nil)
14
- assert_equal 1, NamedArray.identify_name(names, "ValueB (Entity type)")
15
- assert_equal 1, NamedArray.identify_name(names, "ValueB")
16
- assert_equal 1, NamedArray.identify_name(names, 1)
17
- end
18
-
19
- def test_missing_field
20
- a = NamedArray.setup([1,2], [:a, :b])
21
- assert_equal 1, a[:a]
22
- assert_equal nil, a[:c]
23
- end
24
-
25
- def test_zip_fields
26
- a = [%w(a b), %w(1 1)]
27
- assert_equal [%w(a 1), %w(b 1)], NamedArray.zip_fields(a)
28
- end
29
-
30
- def test_add_zipped
31
- a = [%w(a b), %w(1 1)]
32
- NamedArray.add_zipped a, [%w(c), %w(1)]
33
- NamedArray.add_zipped a, [%w(d), %w(1)]
34
- assert_equal [%w(a b c d), %w(1 1 1 1)], a
35
- end
36
-
37
- def test_method_missing
38
- a = NamedArray.setup([1,2], [:a, :b])
39
- assert_equal 1, a.a
40
- assert_equal 2, a.b
41
- end
42
- end
43
-
@@ -1,146 +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 TestOpen < Test::Unit::TestCase
5
-
6
- def test_read
7
- content =<<-EOF
8
- 1
9
- 2
10
- 3
11
- 4
12
- EOF
13
- TmpFile.with_file(content) do |file|
14
- sum = 0
15
- Open.read file do |line| sum += line.to_i end
16
- assert_equal(1 + 2 + 3 + 4, sum)
17
- assert_equal(content, Open.read(file))
18
- end
19
- end
20
-
21
- def test_gzip
22
- content =<<-EOF
23
- 1
24
- 2
25
- 3
26
- 4
27
- EOF
28
- TmpFile.with_file(content) do |file|
29
- `gzip #{file}`
30
- assert_equal(content, Open.read(file + '.gz'))
31
- FileUtils.rm file + '.gz'
32
- end
33
- end
34
-
35
-
36
-
37
- #def test_wget
38
- # assert(Misc.fixutf8(Open.wget('http://google.com', :quiet => true).read) =~ /html/)
39
- #end
40
-
41
- #def test_nice
42
- # nice = 0.5
43
-
44
- # t = Time.now
45
- # Open.wget('http://google.com', :quiet => true, :nice => nice).read
46
- # assert(Time.now - t + 0.5 >= nice)
47
-
48
- # Open.wget('http://google.com', :quiet => true, :nice => nice, :nice_key => 1).read
49
- # t = Time.now
50
- # Open.wget('http://google.com', :quiet => true, :nice => nice, :nice_key => 1).read
51
- # assert(Time.now - t + 0.5 >= nice)
52
- #end
53
-
54
- #def test_remote?
55
- # assert(Open.remote?('http://google.com'))
56
- # assert(! Open.remote?('~/.bashrc'))
57
- #end
58
-
59
- #def test_open
60
- # assert(Open.read('http://google.com', :quiet => true, :nocache => :update) =~ /html/)
61
- #end
62
-
63
- #def test_repo_dir
64
- # file1 = "TEST"
65
- # file2 = "TEST" * 1000
66
- # TmpFile.with_file do |tmpdir|
67
- # tmpdir = Rbbt.tmp.repo_dir.find
68
- # normal = File.join(tmpdir, 'normal')
69
- # repo = File.join(tmpdir, 'repo')
70
-
71
- # Open.repository_dirs.push(repo)
72
-
73
- # Misc.benchmark(100) do
74
- # filename = "file" << (rand * 100).to_i.to_s
75
- # Open.write(File.join(normal, filename), file2)
76
- # 100.times do
77
- # Open.read(File.join(normal, filename))
78
- # end
79
- # end
80
-
81
- # Misc.benchmark(100) do
82
- # filename = "file" << (rand * 100).to_i.to_s
83
- # Open.write(File.join(repo, filename), file2)
84
- # 100.times do
85
- # Open.read(File.join(repo, filename))
86
- # end
87
- # end
88
- # end
89
- #end
90
- #
91
- #def test_repo_dir2
92
- # TmpFile.with_file do |tmpdir|
93
- # tmpdir = Rbbt.tmp.repo_dir.find
94
- # repo = File.join(tmpdir, 'repo')
95
-
96
- # Open.repository_dirs.push(repo)
97
-
98
- # obj = { :a => "???a"}
99
- # filename = "file" << (rand * 100).to_i.to_s
100
- # Open.write(File.join(repo, filename), Marshal.dump(obj))
101
- # dump = Open.read(File.join(repo, filename))
102
- # obj_cp = Marshal.load(dump)
103
- # assert_equal obj, obj_cp
104
- # end
105
- #end
106
-
107
- #def test_repo_marshal
108
- # TmpFile.with_file do |tmpdir|
109
- # tmpdir = Rbbt.tmp.repo_dir.find
110
- # repo = File.join(tmpdir, 'repo')
111
-
112
- # filename = 'file'
113
- # Open.repository_dirs.push(repo)
114
-
115
- # obj = {:a => "string", :pid => nil, :num => 1000, :p => Rbbt.tmp.foo}
116
- # Open.write(File.join(repo, filename), Marshal.dump(obj))
117
- # new =Open.open(File.join(repo, filename)) do |f|
118
- # Marshal.load(f)
119
- # end
120
-
121
- # assert_equal new, obj
122
- # end
123
-
124
- #end
125
-
126
- #def test_write_stream_repo
127
- # TmpFile.with_file do |tmpdir|
128
- # tmpdir = Rbbt.tmp.repo_dir.find
129
- # repo = File.join(tmpdir, 'repo')
130
-
131
- # file = File.join(repo, 'file')
132
- # Open.repository_dirs.push(repo)
133
-
134
- # text = (["text"] * 5) * "\n"
135
-
136
- # Misc.consume_stream(StringIO.new(text), false, file)
137
-
138
- # assert_equal text, Open.read(file)
139
- # assert !File.exist?(file)
140
- # assert Open.exists? file
141
- # end
142
-
143
- #end
144
-
145
- end
146
-
@@ -1,54 +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 TestPath < Test::Unit::TestCase
5
- def test_join
6
- path = '/tmp'
7
- path.extend Path
8
- assert_equal '/tmp/foo', path.join(:foo)
9
- assert_equal '/tmp/foo/bar', path.join(:bar, :foo)
10
- end
11
-
12
- def test_get
13
- path = '/tmp'
14
- path.extend Path
15
- assert_equal '/tmp/foo', path[:foo]
16
- assert_equal '/tmp/foo/bar', path.foo[:bar]
17
- assert_equal '/tmp/foo/bar', path[:bar, :foo]
18
- end
19
-
20
- def test_slash
21
- path = '/tmp'
22
- path.extend Path
23
- assert_equal '/tmp/foo', path/:foo
24
- assert_equal '/tmp/foo/bar', path/:foo/:bar
25
- assert_equal '/tmp/foo/bar', path.foo/:bar
26
- assert_equal '/tmp/foo/bar', path./(:bar, :foo)
27
- end
28
-
29
- def test_setup
30
- path = 'tmp'
31
- Path.setup(path)
32
- assert_equal 'scout', path.pkgdir
33
- assert path.libdir.end_with?("scout-gear")
34
- end
35
-
36
- def test_lib_dir
37
- TmpFile.with_file do |tmpdir|
38
- Path.setup tmpdir
39
- FileUtils.mkdir_p tmpdir.lib
40
- lib_path = File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
41
- lib_path = File.join(Path.caller_lib_dir, 'lib', lib_path)
42
- File.write tmpdir.lib.file, <<-EOR
43
- require '#{lib_path}'
44
- a = "1"
45
- Path.setup(a)
46
- print a.libdir
47
- EOR
48
- Misc.in_dir tmpdir.tmp do
49
- assert_equal tmpdir, `ruby #{tmpdir.lib.file}`
50
- end
51
- end
52
- end
53
- end
54
-