spec: add wsl guard
WSL 2 is officially released. It uses Linux kernel, so almost all specs for Linux work on WSL, except one: gethostbyaddr. I guess network resolution in WSL is based on Windows, so the behavior seems a bit different from normal Linux. This change adds `platform_is_not :wsl` guard, and guards out the test in question.
This commit is contained in:
parent
0d1f0cd9cc
commit
e73e504e2f
@ -26,8 +26,11 @@ class PlatformGuard < SpecGuard
|
|||||||
def self.os?(*oses)
|
def self.os?(*oses)
|
||||||
oses.any? do |os|
|
oses.any? do |os|
|
||||||
raise ":java is not a valid OS" if os == :java
|
raise ":java is not a valid OS" if os == :java
|
||||||
if os == :windows
|
case os
|
||||||
|
when :windows
|
||||||
PLATFORM =~ /(mswin|mingw)/
|
PLATFORM =~ /(mswin|mingw)/
|
||||||
|
when :wsl
|
||||||
|
wsl?
|
||||||
else
|
else
|
||||||
PLATFORM.include?(os.to_s)
|
PLATFORM.include?(os.to_s)
|
||||||
end
|
end
|
||||||
@ -38,6 +41,14 @@ class PlatformGuard < SpecGuard
|
|||||||
os?(:windows)
|
os?(:windows)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.wsl?
|
||||||
|
if defined?(@wsl_p)
|
||||||
|
@wsl_p
|
||||||
|
else
|
||||||
|
@wsl_p = `uname -r`.match?(/microsoft/i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
WORD_SIZE = 1.size * 8
|
WORD_SIZE = 1.size * 8
|
||||||
|
|
||||||
POINTER_SIZE = begin
|
POINTER_SIZE = begin
|
||||||
|
@ -113,7 +113,7 @@ describe 'Socket.gethostbyaddr' do
|
|||||||
Socket.gethostbyaddr(@addr, :INET6).should be_an_instance_of(Array)
|
Socket.gethostbyaddr(@addr, :INET6).should be_an_instance_of(Array)
|
||||||
end
|
end
|
||||||
|
|
||||||
platform_is_not :windows do
|
platform_is_not :windows, :wsl do
|
||||||
it 'raises SocketError when the address is not supported by the family' do
|
it 'raises SocketError when the address is not supported by the family' do
|
||||||
-> { Socket.gethostbyaddr(@addr, :INET) }.should raise_error(SocketError)
|
-> { Socket.gethostbyaddr(@addr, :INET) }.should raise_error(SocketError)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user