Skip to content

Commit

Permalink
Load win32/resolv with rake test
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Feb 4, 2025
1 parent e0c92ee commit 3ecfce3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/resolv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class ResolvTimeout < Timeout::Error; end
class Hosts
if WINDOWS
begin
require 'win32/resolv'
require 'win32/resolv' unless defined?(Win32::Resolv)
DefaultFileName = Win32::Resolv.get_hosts_path || IO::NULL
rescue LoadError
end
Expand Down Expand Up @@ -1023,7 +1023,7 @@ def Config.default_config_hash(filename="/etc/resolv.conf")
config_hash = Config.parse_resolv_conf(filename)
else
if WINDOWS
require 'win32/resolv'
require 'win32/resolv' unless defined?(Win32::Resolv)
search, nameserver = Win32::Resolv.get_resolv_info
config_hash = {}
config_hash[:nameserver] = nameserver if nameserver
Expand Down
6 changes: 6 additions & 0 deletions test/lib/helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
require "test/unit"
require "core_assertions"

if RUBY_PLATFORM =~ /mswin|mingw/
# "win32/resolv" is installation path by Ruby installer.
# We should load that file manually for testing with Windows platform.
require_relative "../../ext/win32/resolv/lib/resolv"
end

Test::Unit::TestCase.include Test::Unit::CoreAssertions

0 comments on commit 3ecfce3

Please sign in to comment.