Skip to content

Commit 59bcf0c

Browse files
authored
Merge pull request #83 from ruby/refine-test-helper
Load win32/resolv with rake test
2 parents e0c92ee + 3ecfce3 commit 59bcf0c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/resolv.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class ResolvTimeout < Timeout::Error; end
182182
class Hosts
183183
if WINDOWS
184184
begin
185-
require 'win32/resolv'
185+
require 'win32/resolv' unless defined?(Win32::Resolv)
186186
DefaultFileName = Win32::Resolv.get_hosts_path || IO::NULL
187187
rescue LoadError
188188
end
@@ -1023,7 +1023,7 @@ def Config.default_config_hash(filename="/etc/resolv.conf")
10231023
config_hash = Config.parse_resolv_conf(filename)
10241024
else
10251025
if WINDOWS
1026-
require 'win32/resolv'
1026+
require 'win32/resolv' unless defined?(Win32::Resolv)
10271027
search, nameserver = Win32::Resolv.get_resolv_info
10281028
config_hash = {}
10291029
config_hash[:nameserver] = nameserver if nameserver

test/lib/helper.rb

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
require "test/unit"
22
require "core_assertions"
33

4+
if RUBY_PLATFORM =~ /mswin|mingw/
5+
# "win32/resolv" is installation path by Ruby installer.
6+
# We should load that file manually for testing with Windows platform.
7+
require_relative "../../ext/win32/resolv/lib/resolv"
8+
end
9+
410
Test::Unit::TestCase.include Test::Unit::CoreAssertions

0 commit comments

Comments
 (0)