Standardize on Util::Platform
This commit is contained in:
parent
1aed9f0f38
commit
5143556065
|
@ -1,6 +1,5 @@
|
|||
require 'net/ssh'
|
||||
require 'net/scp'
|
||||
require 'mario'
|
||||
|
||||
module Vagrant
|
||||
# Manages SSH access to a specific environment. Allows an environment to
|
||||
|
@ -27,7 +26,7 @@ module Vagrant
|
|||
# process with an SSH process. This method optionally takes a hash
|
||||
# of options which override the configuration values.
|
||||
def connect(opts={})
|
||||
if Mario::Platform.windows?
|
||||
if Util::Platform.windows?
|
||||
raise Errors::SSHUnavailableWindows, :key_path => env.config.ssh.private_key_path,
|
||||
:ssh_port => port(opts)
|
||||
end
|
||||
|
@ -137,7 +136,7 @@ module Vagrant
|
|||
# if needed, or on failure erroring.
|
||||
def check_key_permissions(key_path)
|
||||
# Windows systems don't have this issue
|
||||
return if Mario::Platform.windows?
|
||||
return if Util::Platform.windows?
|
||||
|
||||
stat = File.stat(key_path)
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'mario'
|
||||
|
||||
module Vagrant
|
||||
# Vagrant UIs handle communication with the outside world (typically
|
||||
# through a shell). They must respond to the typically logger methods
|
||||
|
@ -61,7 +59,7 @@ module Vagrant
|
|||
|
||||
def line_reset
|
||||
reset = "\r"
|
||||
reset += "\e[0K" unless Mario::Platform.windows?
|
||||
reset += "\e[0K" unless Util::Platform.windows?
|
||||
reset
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require 'rbconfig'
|
||||
require 'mario'
|
||||
|
||||
module Vagrant
|
||||
module Util
|
||||
|
@ -53,7 +52,7 @@ module Vagrant
|
|||
|
||||
def tar_file_options
|
||||
# create, write only, fail if the file exists, binary if windows
|
||||
File::WRONLY|File::EXCL|File::CREAT|(Mario::Platform.windows? ? File::BINARY : 0)
|
||||
File::WRONLY | File::EXCL | File::CREAT | (windows? ? File::BINARY : 0)
|
||||
end
|
||||
|
||||
def platform
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
$:.unshift(File.dirname(__FILE__))
|
||||
|
||||
require 'vagrant'
|
||||
require 'mario'
|
||||
require 'contest'
|
||||
require 'mocha'
|
||||
|
||||
|
@ -14,9 +13,6 @@ begin
|
|||
rescue LoadError
|
||||
end
|
||||
|
||||
# Silence Mario by sending log output to black hole
|
||||
Mario::Platform.logger(nil)
|
||||
|
||||
# Add the I18n locale for tests
|
||||
I18n.load_path << File.expand_path("../locales/en.yml", __FILE__)
|
||||
|
||||
|
|
|
@ -80,17 +80,13 @@ class SshTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
context "checking windows" do
|
||||
teardown do
|
||||
Mario::Platform.forced = Mario::Platform::Linux
|
||||
end
|
||||
|
||||
should "error and exit if the platform is windows" do
|
||||
Mario::Platform.forced = Mario::Platform::Windows7
|
||||
Vagrant::Util::Platform.stubs(:windows?).returns(true)
|
||||
assert_raises(Vagrant::Errors::SSHUnavailableWindows) { @ssh.connect }
|
||||
end
|
||||
|
||||
should "not error and exit if the platform is anything other that windows" do
|
||||
Mario::Platform.forced = Mario::Platform::Linux
|
||||
Vagrant::Util::Platform.stubs(:windows?).returns(false)
|
||||
assert_nothing_raised { @ssh.connect }
|
||||
end
|
||||
end
|
||||
|
@ -256,15 +252,11 @@ class SshTest < Test::Unit::TestCase
|
|||
@stat.stubs(:owned?).returns(true)
|
||||
File.stubs(:stat).returns(@stat)
|
||||
|
||||
Mario::Platform.forced = Mario::Platform::Linux
|
||||
end
|
||||
|
||||
teardown do
|
||||
Mario::Platform.forced = Mario::Platform::Linux
|
||||
Vagrant::Util::Platform.stubs(:windows?).returns(false)
|
||||
end
|
||||
|
||||
should "do nothing if on windows" do
|
||||
Mario::Platform.forced = Mario::Platform::Windows7
|
||||
Vagrant::Util::Platform.stubs(:windows?).returns(true)
|
||||
File.expects(:stat).never
|
||||
@ssh.check_key_permissions(@key_path)
|
||||
end
|
||||
|
|
|
@ -6,12 +6,12 @@ class PlatformTest < Test::Unit::TestCase
|
|||
# This constant is not defined on non-windows platforms, so define it here
|
||||
File::BINARY = 4096 unless defined?(File::BINARY)
|
||||
|
||||
Mario::Platform.expects(:windows?).returns(true)
|
||||
Vagrant::Util::Platform.stubs(:windows?).returns(true)
|
||||
assert_equal Vagrant::Util::Platform.tar_file_options, File::CREAT|File::EXCL|File::WRONLY|File::BINARY
|
||||
end
|
||||
|
||||
should "not include binary bit on other platforms" do
|
||||
Mario::Platform.expects(:windows?).returns(false)
|
||||
Vagrant::Util::Platform.stubs(:windows?).returns(false)
|
||||
assert_equal Vagrant::Util::Platform.tar_file_options, File::CREAT|File::EXCL|File::WRONLY
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,6 @@ Gem::Specification.new do |s|
|
|||
s.add_dependency "archive-tar-minitar", "= 0.5.2"
|
||||
s.add_dependency "erubis", "~> 2.7.0"
|
||||
s.add_dependency "json", "~> 1.5.1"
|
||||
s.add_dependency "mario", "~> 0.0.6"
|
||||
s.add_dependency "net-ssh", "~> 2.1.4"
|
||||
s.add_dependency "net-scp", "~> 1.0.4"
|
||||
s.add_dependency "i18n", "~> 0.5.0"
|
||||
|
|
Loading…
Reference in New Issue