Skip socket tests on Windows platform.

Some test may be OK but we skip everything as a starting point.
parent b103fa22
unless SocketTest.win?
# Note: most of tests below will fail if UDPSocket is broken. # Note: most of tests below will fail if UDPSocket is broken.
assert('IPSocket.getaddress') do assert('IPSocket.getaddress') do
...@@ -38,3 +40,5 @@ assert('IPSocket.peeraddr') do ...@@ -38,3 +40,5 @@ assert('IPSocket.peeraddr') do
server.close server.close
true true
end end
end # win?
unless SocketTest.win?
assert('Socket.gethostname') do assert('Socket.gethostname') do
assert_true(Socket.gethostname.is_a? String) assert_true(Socket.gethostname.is_a? String)
end end
...@@ -32,3 +34,5 @@ assert('Socket#recvfrom') do ...@@ -32,3 +34,5 @@ assert('Socket#recvfrom') do
c.close rescue nil c.close rescue nil
end end
end end
end # win?
...@@ -12,9 +12,20 @@ mrb_sockettest_tmppath(mrb_state *mrb, mrb_value klass) ...@@ -12,9 +12,20 @@ mrb_sockettest_tmppath(mrb_state *mrb, mrb_value klass)
return str; return str;
} }
mrb_value
mrb_sockettest_win_p(mrb_state *mrb, mrb_value klass)
{
#ifdef _WIN32
return mrb_true_value();
#else
return mrb_false_value();
#endif
}
void void
mrb_mruby_socket_gem_test(mrb_state* mrb) mrb_mruby_socket_gem_test(mrb_state* mrb)
{ {
struct RClass *c = mrb_define_module(mrb, "SocketTest"); struct RClass *c = mrb_define_module(mrb, "SocketTest");
mrb_define_class_method(mrb, c, "tmppath", mrb_sockettest_tmppath, MRB_ARGS_NONE()); mrb_define_class_method(mrb, c, "tmppath", mrb_sockettest_tmppath, MRB_ARGS_NONE());
mrb_define_class_method(mrb, c, "win?", mrb_sockettest_win_p, MRB_ARGS_NONE());
} }
unless SocketTest.win?
def unixserver_test_block def unixserver_test_block
path = SocketTest.tmppath path = SocketTest.tmppath
File.unlink path rescue nil File.unlink path rescue nil
...@@ -124,3 +126,5 @@ assert('UNIXSocket#recvfrom') do ...@@ -124,3 +126,5 @@ assert('UNIXSocket#recvfrom') do
# a[1][1] would be "" or something # a[1][1] would be "" or something
end end
end end
end # win?
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment