summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Nordsieck <theo@opscode.com>2013-08-13 13:29:09 -0700
committerTheodore Nordsieck <theo@opscode.com>2013-08-13 13:48:37 -0700
commit1c8e70574e5925d26ba738271eada4380a13e1e8 (patch)
treeb7319dc7d001c3a689b1e26b299f465836b7e4f7
parent685b66980e8e3eaeab0ffef2d121251d7fab6b7e (diff)
downloadohai-1c8e70574e5925d26ba738271eada4380a13e1e8.tar.gz
Added windows support for unit tests
-rw-r--r--spec/unit/path/ohai_plugin_common.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/spec/unit/path/ohai_plugin_common.rb b/spec/unit/path/ohai_plugin_common.rb
index 91178054..e99a9879 100644
--- a/spec/unit/path/ohai_plugin_common.rb
+++ b/spec/unit/path/ohai_plugin_common.rb
@@ -133,6 +133,9 @@ eos
def create_exe(cmd, path, platform, arch, env)
cmd_path = File.join( path, cmd )
+ bat_path = cmd_path + ".bat"
+
+ #fake exe
file = <<-eof
#!#{File.join( RbConfig::CONFIG['bindir'], 'ruby' )}
@@ -142,6 +145,13 @@ require '#{path}/ohai_plugin_common.rb'
OhaiPluginCommon.fake_command OhaiPluginCommon.read_output( '#{cmd}' ), '#{platform}', '#{arch}', #{Yajl::Encoder.encode( env )}
eof
File.open(cmd_path, "w") { |f| f.puts file }
+
+ #.bat shim for windows
+ bat = <<-eof
+@#{File.join( RbConfig::CONFIG['bindir'], 'ruby' )} #{cmd_path} %1 %2 %3 %4 %5 %6 %7 %8 %9
+eof
+ File.open(bat_path, "w") { |f| f.puts bat }
+
sleep 0.01 until File.exists? cmd_path
Mixlib::ShellOut.new("chmod 755 #{cmd_path}").run_command
end
@@ -157,7 +167,7 @@ shared_context "cross platform data" do
e[:platform].each do |platform|
e[:arch].each do |arch|
e[:env].each do |env|
- it "provides data when the platform is '#{platform}', the architecture is '#{arch}' and the environment is '#{env}'", :unix_only do
+ it "provides data when the platform is '#{platform}', the architecture is '#{arch}' and the environment is '#{env}'" do
path = OhaiPluginCommon.get_path
cmd_not_found = Set.new
@@ -177,6 +187,9 @@ shared_context "cross platform data" do
@ohai = Ohai::System.new
+ # require 'pry'
+ # binding.pry unless env == []
+
begin
plugin_names.each do | plugin_name |
Ohai::Loader.new( @ohai ).load_plugin( File.join( OhaiPluginCommon.plugin_path, plugin_name + ".rb" ), plugin_name )
@@ -185,7 +198,7 @@ shared_context "cross platform data" do
end
ensure
ENV['PATH'] = old_path
- cmd_list.each { |c| Mixlib::ShellOut.new("rm #{path}/#{c}").run_command if !cmd_not_found.include?( c )}
+ cmd_list.each { |c| [ "", ".bat" ].each { |ext| Mixlib::ShellOut.new("rm #{path}/#{c}#{ext}").run_command if !cmd_not_found.include?( c )}}
end
OhaiPluginCommon.subsumes?( @ohai.data, e[:ohai] ).should be_true