test/functional/bio/test_command.rb in bio-1.4.2 vs test/functional/bio/test_command.rb in bio-1.4.3
- old
+ new
@@ -17,26 +17,30 @@
require 'test/unit'
require 'tempfile'
require 'bio/command'
module Bio
- class FuncTestCommandCall < Test::Unit::TestCase
+ module FuncTestCommandCallCommon
- def setup
- if Bio::Command.module_eval { windows_platform? } then
- cmd = File.expand_path(File.join(BioRubyTestDataPath, 'command', 'echoarg2.bat'))
- @arg = [ cmd, 'test "argument 1"', '"test" argument 2', 'arg3' ]
- @expected = '"""test"" argument 2"'
+ def windows_platform?
+ Bio::Command.module_eval { windows_platform? }
+ end
+ module_function :windows_platform?
+
+ def setup_cmd
+ if windows_platform? then
+ [ File.expand_path(File.join(BioRubyTestDataPath, 'command', 'echoarg2.bat')) ]
else
- cmd = "/bin/echo"
- @arg = [ cmd, "test (echo) command" ]
- @expected = "test (echo) command"
- unless FileTest.executable?(cmd) then
- raise "Unsupported environment: /bin/echo not found"
+ [ "/bin/sh", "/bin/echo" ].each do |cmd|
+ unless FileTest.executable?(cmd) then
+ raise "Unsupported environment: #{cmd} not found"
+ end
end
+ [ "/bin/sh", File.expand_path(File.join(BioRubyTestDataPath, 'command', 'echoarg2.sh')) ]
end
end
+ private :setup_cmd
def test_call_command
ret = Bio::Command.call_command(@arg) do |io|
io.close_write
io.read
@@ -83,12 +87,54 @@
return
end
assert_equal(@expected, ret.to_s.strip)
end
- end #class FuncTestCommandCall
+ end #module FuncTestCommandCallCommon
+ class FuncTestCommandCallSimple < Test::Unit::TestCase
+
+ include FuncTestCommandCallCommon
+
+ def setup
+ @arg = setup_cmd
+ @arg.concat [ "first", "second", "third" ]
+ @expected = "second"
+ end
+ end #class FuncTestCommandCallSimple
+
+ class FuncTestCommandCallWithSpace < Test::Unit::TestCase
+
+ include FuncTestCommandCallCommon
+
+ def setup
+ @arg = setup_cmd
+ @arg.concat [ "this is", "a test for", "escape of space" ]
+ if windows_platform? then
+ @expected = '"a test for"'
+ else
+ @expected = "a test for"
+ end
+ end
+ end #class FuncTestCommandCallWithSpace
+
+ class FuncTestCommandCallMisc1 < Test::Unit::TestCase
+
+ include FuncTestCommandCallCommon
+
+ def setup
+ @arg = setup_cmd
+ @arg.concat [ 'test (a) *.* \'argument 1\'',
+ '\'test\' (b) *.* argument 2', 'arg3' ]
+ if windows_platform? then
+ @expected = '"\'test\' (b) *.* argument 2"'
+ else
+ @expected = '\'test\' (b) *.* argument 2'
+ end
+ end
+ end #class FuncTestCommandCallMisc1
+
class FuncTestCommandQuery < Test::Unit::TestCase
def setup
@data = [ "987", "123", "567", "456", "345" ]
@sorted = @data.sort
@@ -330,22 +376,6 @@
tmpdir.close!
assert_raise(IOError) { tmpdir.path }
end
end #class FuncTestCommandTmpdir
- class FuncTestCommandNet < Test::Unit::TestCase
- def test_read_uri
- assert_nothing_raised {
- Bio::Command.read_uri("http://bioruby.open-bio.org/")
- }
- end
-
- def test_start_http
- end
-
- def test_new_http
- end
-
- def test_post_form
- end
- end #class FuncTestCommandNet
end #module Bio