Merge pull request #8749 from chrisroberts/platform/cygwin-detection
Remove PATH based cygwin detection
This commit is contained in:
commit
8dbb5d55a4
|
@ -11,21 +11,12 @@ module Vagrant
|
||||||
class Platform
|
class Platform
|
||||||
class << self
|
class << self
|
||||||
def cygwin?
|
def cygwin?
|
||||||
return @_cygwin if defined?(@_cygwin)
|
if !defined?(@_cygwin)
|
||||||
@_cygwin = -> {
|
@_cygwin = ENV["VAGRANT_DETECTED_OS"].to_s.downcase.include?("cygwin") ||
|
||||||
# Installer detects Cygwin
|
platform.include?("cygwin") ||
|
||||||
return true if ENV["VAGRANT_DETECTED_OS"] &&
|
ENV["OSTYPE"].to_s.downcase.include?("cygwin")
|
||||||
ENV["VAGRANT_DETECTED_OS"].downcase.include?("cygwin")
|
end
|
||||||
|
@_cygwin
|
||||||
# Ruby running in Cygwin
|
|
||||||
return true if platform.include?("cygwin")
|
|
||||||
|
|
||||||
# Heuristic. If the path contains Cygwin, we just assume we're
|
|
||||||
# in Cygwin. It is generally a safe bet.
|
|
||||||
path = ENV["PATH"] || ""
|
|
||||||
return path.include?("cygwin")
|
|
||||||
}.call
|
|
||||||
return @_cygwin
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def wsl?
|
def wsl?
|
||||||
|
|
|
@ -29,14 +29,20 @@ describe Vagrant::Util::Platform do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns true if OSTYPE includes cygwin" do
|
||||||
|
with_temp_env(OSTYPE: "cygwin") do
|
||||||
|
expect(subject).to be_cygwin
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "returns true if platform has cygwin" do
|
it "returns true if platform has cygwin" do
|
||||||
allow(subject).to receive(:platform).and_return("cygwin")
|
allow(subject).to receive(:platform).and_return("cygwin")
|
||||||
expect(subject).to be_cygwin
|
expect(subject).to be_cygwin
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if the PATH contains cygwin" do
|
it "returns false if the PATH contains cygwin" do
|
||||||
with_temp_env(PATH: "C:/cygwin") do
|
with_temp_env(PATH: "C:/cygwin") do
|
||||||
expect(subject).to be_cygwin
|
expect(subject).to_not be_cygwin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue