Skip to content

Commit cb644da

Browse files
committed
Skip tests on Windows
The do not work out of the box, I'm sure this can be fixed but I have no idea how to do that.
1 parent 2cf80da commit cb644da

File tree

1 file changed

+36
-34
lines changed

1 file changed

+36
-34
lines changed

test/test_cgi_server.rb

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,31 @@ def setup_http_server_option(use_ssl)
2929
end
3030

3131
def test_client_server
32-
# NOTE: I don't enable SSL testing as this hangs
32+
omit("The CGI file does not work on Windows") if Gem.win_platform?
33+
3334
Tempfile.create("cgi-bin") do |tempfile|
3435
tempfile.write(cgi_bin_script)
3536
tempfile.close
3637
File.chmod(0755, tempfile.path)
3738

38-
[false].each do |use_ssl|
39-
option = setup_http_server_option(use_ssl)
40-
with_server(option, WEBrick::HTTPServlet::CGIHandler, tempfile.path) {|addr|
41-
@s = XMLRPC::Client.new3(:host => addr.ip_address, :port => addr.ip_port, :use_ssl => use_ssl)
42-
@s.user = 'admin'
43-
@s.password = 'admin'
44-
silent do
45-
do_test
46-
end
47-
@s.http.finish
48-
@s = XMLRPC::Client.new3(:host => addr.ip_address, :port => addr.ip_port, :use_ssl => use_ssl)
49-
@s.user = '01234567890123456789012345678901234567890123456789012345678901234567890123456789'
50-
@s.password = 'guest'
51-
silent do
52-
do_test
53-
end
54-
@s.http.finish
55-
}
39+
# NOTE: I don't enable SSL testing as this hangs
40+
use_ssl = false
41+
option = setup_http_server_option(use_ssl)
42+
with_server(option, WEBrick::HTTPServlet::CGIHandler, tempfile.path) do |addr|
43+
@s = XMLRPC::Client.new3(:host => addr.ip_address, :port => addr.ip_port, :use_ssl => use_ssl)
44+
@s.user = 'admin'
45+
@s.password = 'admin'
46+
silent do
47+
do_test
48+
end
49+
@s.http.finish
50+
@s = XMLRPC::Client.new3(:host => addr.ip_address, :port => addr.ip_port, :use_ssl => use_ssl)
51+
@s.user = '01234567890123456789012345678901234567890123456789012345678901234567890123456789'
52+
@s.password = 'guest'
53+
silent do
54+
do_test
55+
end
56+
@s.http.finish
5657
end
5758
end
5859
end
@@ -68,43 +69,44 @@ def silent
6869

6970
def do_test
7071
# simple call
71-
assert_equal 9, @s.call('test.add', 4, 5)
72+
assert_equal(9, @s.call('test.add', 4, 5))
7273

7374
# fault exception
7475
assert_raise(XMLRPC::FaultException) { @s.call('test.div', 1, 0) }
7576

7677
# fault exception via call2
7778
ok, param = @s.call2('test.div', 1, 0)
78-
assert_equal false, ok
79-
assert_instance_of XMLRPC::FaultException, param
80-
assert_equal 1, param.faultCode
81-
assert_equal 'division by zero', param.faultString
79+
assert_equal(false, ok)
80+
assert_instance_of(XMLRPC::FaultException, param)
81+
assert_equal(1, param.faultCode)
82+
assert_equal('division by zero', param.faultString)
8283

8384
# call2 without fault exception
8485
ok, param = @s.call2('test.div', 10, 5)
85-
assert_equal true, ok
86-
assert_equal param, 2
86+
assert_equal(true, ok)
87+
assert_equal(param, 2)
8788

8889
# introspection
89-
assert_equal ["test.add", "test.div", "system.listMethods", "system.methodSignature", "system.methodHelp"], @s.call("system.listMethods")
90+
assert_equal(["test.add", "test.div", "system.listMethods", "system.methodSignature", "system.methodHelp"],
91+
@s.call("system.listMethods"))
9092

9193
# default handler (missing handler)
9294
ok, param = @s.call2('test.nonexisting')
93-
assert_equal false, ok
95+
assert_equal(false, ok)
9496
assert_equal(-99, param.faultCode)
9597

9698
# default handler (wrong number of arguments)
9799
ok, param = @s.call2('test.add', 1, 2, 3)
98-
assert_equal false, ok
100+
assert_equal(false, ok)
99101
assert_equal(-99, param.faultCode)
100102

101103
# multibyte characters
102-
assert_equal "あいうえおかきくけこ", @s.call('test.add', "あいうえお", "かきくけこ")
104+
assert_equal("あいうえおかきくけこ", @s.call('test.add', "あいうえお", "かきくけこ"))
103105
end
104106

105107
def cgi_bin_script
106108
<<~RUBY
107-
#!/usr/bin/env ruby
109+
#!#{Gem.ruby}
108110
# frozen_string_literal: true
109111
110112
$LOAD_PATH << #{File.expand_path("../lib", __dir__).inspect}
@@ -113,11 +115,11 @@ def cgi_bin_script
113115
114116
s = XMLRPC::CGIServer.new
115117
116-
s.add_handler("test.add") do |a,b|
118+
s.add_handler("test.add") do |a, b|
117119
a + b
118120
end
119121
120-
s.add_handler("test.div") do |a,b|
122+
s.add_handler("test.div") do |a, b|
121123
if b == 0
122124
raise XMLRPC::FaultException.new(1, "division by zero")
123125
else
@@ -126,7 +128,7 @@ def cgi_bin_script
126128
end
127129
128130
s.set_default_handler do |name, *args|
129-
raise XMLRPC::FaultException.new(-99, "Method #{name} missing" +
131+
raise XMLRPC::FaultException.new(-99, "Method \#{name} missing" +
130132
" or wrong number of parameters!")
131133
end
132134

0 commit comments

Comments
 (0)