summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/mspec/lib/mspec/guards/platform.rb13
-rw-r--r--spec/ruby/library/socket/socket/gethostbyaddr_spec.rb2
2 files changed, 13 insertions, 2 deletions
diff --git a/spec/mspec/lib/mspec/guards/platform.rb b/spec/mspec/lib/mspec/guards/platform.rb
index 2d22d4fb59..2d5c2de6b6 100644
--- a/spec/mspec/lib/mspec/guards/platform.rb
+++ b/spec/mspec/lib/mspec/guards/platform.rb
@@ -26,8 +26,11 @@ class PlatformGuard < SpecGuard
def self.os?(*oses)
oses.any? do |os|
raise ":java is not a valid OS" if os == :java
- if os == :windows
+ case os
+ when :windows
PLATFORM =~ /(mswin|mingw)/
+ when :wsl
+ wsl?
else
PLATFORM.include?(os.to_s)
end
@@ -38,6 +41,14 @@ class PlatformGuard < SpecGuard
os?(:windows)
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
POINTER_SIZE = begin
diff --git a/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb b/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb
index 5d97341103..8bebeb0e21 100644
--- a/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb
+++ b/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb
@@ -113,7 +113,7 @@ describe 'Socket.gethostbyaddr' do
Socket.gethostbyaddr(@addr, :INET6).should be_an_instance_of(Array)
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
-> { Socket.gethostbyaddr(@addr, :INET) }.should raise_error(SocketError)
end