Several tests were broken due to pecularities of Windows
and Ruby on Windows:

* Ruby on windows does not differentiate between group and
  other file permissions.
* All open file handles must be closed before the file can
  be deleted
* Sometimes the current working directory (Dir.getwd) is
  reported as C:/foo and other times as C:\\foo, which
  confuses the spec tests.
* Ruby's sprintf formats floating point values differently
  on Windows vs Unix. The Windows exponent has an extra
  leading zero.
* Needed to stub execution of security command with the
  SMF service provider.

Reviewed-by: Jacob Helwig <ja...@puppetlabs.com>
Signed-off-by: Josh Cooper <j...@puppetlabs.com>
---
Local-branch: feature/master/8268-puppet-agent-windows
 spec/integration/util/settings_spec.rb      |    4 ++--
 spec/unit/application/inspect_spec.rb       |    1 +
 spec/unit/parser/functions/sprintf_spec.rb  |    3 ++-
 spec/unit/provider/macauthorization_spec.rb |    5 +++++
 spec/unit/provider/service/smf_spec.rb      |    1 +
 spec/unit/type/file/content_spec.rb         |    1 +
 6 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/spec/integration/util/settings_spec.rb 
b/spec/integration/util/settings_spec.rb
index b05c631..46d783c 100755
--- a/spec/integration/util/settings_spec.rb
+++ b/spec/integration/util/settings_spec.rb
@@ -18,12 +18,12 @@ describe Puppet::Util::Settings do
     File.should be_directory(settings[:maindir])
   end
 
-  it "should make its directories with the corret modes" do
+  it "should make its directories with the correct modes" do
     settings = Puppet::Util::Settings.new
     settings.setdefaults :main,  minimal_default_settings.update( :maindir => 
{:default => tmpfile("main"), :desc => "a", :mode => 0750} )
 
     settings.use(:main)
 
-    (File.stat(settings[:maindir]).mode & 007777).should == 0750
+    (File.stat(settings[:maindir]).mode & 007777).should == 
(Puppet.features.microsoft_windows? ? 0755 : 0750)
   end
 end
diff --git a/spec/unit/application/inspect_spec.rb 
b/spec/unit/application/inspect_spec.rb
index 15a3bee..9f12c83 100755
--- a/spec/unit/application/inspect_spec.rb
+++ b/spec/unit/application/inspect_spec.rb
@@ -98,6 +98,7 @@ describe Puppet::Application::Inspect do
       catalog = Puppet::Resource::Catalog.new
       file = Tempfile.new("foo")
       resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit 
=> "all"})
+      file.close
       file.delete
       catalog.add_resource(resource)
       
Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(catalog)
diff --git a/spec/unit/parser/functions/sprintf_spec.rb 
b/spec/unit/parser/functions/sprintf_spec.rb
index bd4863f..3351c7f 100755
--- a/spec/unit/parser/functions/sprintf_spec.rb
+++ b/spec/unit/parser/functions/sprintf_spec.rb
@@ -30,7 +30,8 @@ describe "the sprintf function" do
 
   it "should format large floats" do
     result = @scope.function_sprintf(["%+.2e", "27182818284590451"])
-    result.should(eql("+2.72e+16"))
+    str = Puppet.features.microsoft_windows? ? "+2.72e+016" : "+2.72e+16"
+    result.should(eql(str))
   end
 
   it "should perform more complex formatting" do
diff --git a/spec/unit/provider/macauthorization_spec.rb 
b/spec/unit/provider/macauthorization_spec.rb
index a76f917..dbe36a0 100755
--- a/spec/unit/provider/macauthorization_spec.rb
+++ b/spec/unit/provider/macauthorization_spec.rb
@@ -106,6 +106,11 @@ describe provider_class do
     end
 
     it "should call the internal method set_right" do
+      @provider.expects(:execute).with { |cmds, args|
+        cmds.include?("read") and
+        cmds.include?(@authname) and
+        args[:combine] == false
+      }.once
       @provider.expects(:set_right)
       @provider.flush
     end
diff --git a/spec/unit/provider/service/smf_spec.rb 
b/spec/unit/provider/service/smf_spec.rb
index 5212d54..fd7d50e 100755
--- a/spec/unit/provider/service/smf_spec.rb
+++ b/spec/unit/provider/service/smf_spec.rb
@@ -111,6 +111,7 @@ describe provider_class do
     it "should import the manifest if service is missing" do
       @provider.expects(:svccfg).with(:import, "/tmp/myservice.xml")
       @provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :enable, 
"/system/myservice"], true)
+      @provider.expects(:svcs).with('-H', '-o', 'state,nstate', 
"/system/myservice").returns("online\t-")
       @provider.start
     end
 
diff --git a/spec/unit/type/file/content_spec.rb 
b/spec/unit/type/file/content_spec.rb
index 6a2f3f4..04ec485 100755
--- a/spec/unit/type/file/content_spec.rb
+++ b/spec/unit/type/file/content_spec.rb
@@ -254,6 +254,7 @@ describe content do
       @content.should = "{md5}foo"
       @content.resource.bucket.class.any_instance.stubs(:getfile).returns "foo"
       @content.write(@fh)
+      @fh.close
     end
 
     describe "from actual content" do
-- 
1.7.5.4

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-dev@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to