summaryrefslogtreecommitdiff
path: root/spec/mspec/lib
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2020-05-30 01:45:46 +0900
committerYusuke Endoh <mame@ruby-lang.org>2020-05-30 01:52:38 +0900
commite73e504e2f2618453c75cc322fa4813ab9661c60 (patch)
tree097fb15f0656c08e669388a3b7f8568a9571df8d /spec/mspec/lib
parent0d1f0cd9ccb8c4d237f1eba92254a2ab306ae231 (diff)
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.
Diffstat (limited to 'spec/mspec/lib')
-rw-r--r--spec/mspec/lib/mspec/guards/platform.rb13
1 files changed, 12 insertions, 1 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