Ruby does not support creating symlinks on Windows (though Windows does
support them), and since the tidy spec test is designed to reproduce a
specific bug (as opposed to testing symlink functionality on Windows) it
has been disabled.

Ruby on Windows also does not support File.chmod, so the inspect spec
test has been disabled. The general issue of File.chmod on Windows is
something I know needs to be investigated.

Also disabled the cron spec test as this functionality will not be
supported on Windows (instead there will be task manager support).

Re-enable the autoload spec tests as those now pass on Windows (this is
probably due to the cacher changes recently made).

The inventory ssl spec is not supported on Windows and so is disabled.
However, while researching the failure, it was due to
Time.now.strftime("%Z") returning "Pacific Daylight Time" on Windows,
instead of "PDT" like it does on other platforms. As a result, the split
method was sometimes splitting in the wrong place.

As far as I can tell, the inventory code is only called from the CA (to
keep track of serial numbers for certs that it has issued). But it's
something to watch out for on Windows when calling strftime.

Webrick, fileserver and CA functionality are not supported on Windows so
these spec tests are disabled.

Also fix path issue with catalog spec.

Also several spec tests were creating tempfiles manually and calling
system("rm -rf ..."), these have been replaced with
PuppetSpec::Files.tmpdir.

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/network/server/webrick_spec.rb |   14 ++++++--------
 spec/integration/type/tidy_spec.rb              |    2 +-
 spec/integration/util/autoload_spec.rb          |    2 +-
 spec/unit/application/inspect_spec.rb           |    2 +-
 spec/unit/face/ca_spec.rb                       |    2 +-
 spec/unit/network/handler/fileserver_spec.rb    |   10 +++++-----
 spec/unit/network/http/webrick_spec.rb          |   10 +++++-----
 spec/unit/resource/catalog_spec.rb              |    7 ++++---
 spec/unit/ssl/inventory_spec.rb                 |    2 +-
 spec/unit/type/cron_spec.rb                     |    2 +-
 10 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/spec/integration/network/server/webrick_spec.rb 
b/spec/integration/network/server/webrick_spec.rb
index 2390fca..7365462 100755
--- a/spec/integration/network/server/webrick_spec.rb
+++ b/spec/integration/network/server/webrick_spec.rb
@@ -4,7 +4,9 @@ require 'puppet/network/server'
 require 'puppet/ssl/certificate_authority'
 require 'socket'
 
-describe Puppet::Network::Server do
+describe Puppet::Network::Server, :unless => 
Puppet.features.microsoft_windows? do
+  include PuppetSpec::Files
+
   describe "when using webrick" do
     before :each do
       Puppet[:servertype] = 'webrick'
@@ -12,11 +14,10 @@ describe Puppet::Network::Server do
       @params = { :port => 34343, :handlers => [ :node ], :xmlrpc_handlers => 
[ :status ] }
 
       # Get a safe temporary file
-      @tmpfile = Tempfile.new("webrick_integration_testing")
-      @dir = @tmpfile.path + "_dir"
+      dir = tmpdir("webrick_integration_testing")
 
-      Puppet.settings[:confdir] = @dir
-      Puppet.settings[:vardir] = @dir
+      Puppet.settings[:confdir] = dir
+      Puppet.settings[:vardir] = dir
       Puppet.settings[:group] = Process.gid
 
       Puppet::SSL::Host.ca_location = :local
@@ -26,11 +27,8 @@ describe Puppet::Network::Server do
     end
 
     after do
-      @tmpfile.delete
       Puppet.settings.clear
 
-      system("rm -rf #{@dir}")
-
       Puppet::SSL::Host.ca_location = :none
     end
 
diff --git a/spec/integration/type/tidy_spec.rb 
b/spec/integration/type/tidy_spec.rb
index 08a2409..d1bb62d 100755
--- a/spec/integration/type/tidy_spec.rb
+++ b/spec/integration/type/tidy_spec.rb
@@ -12,7 +12,7 @@ describe Puppet::Type.type(:tidy) do
   end
 
   # Testing #355.
-  it "should be able to remove dead links", :fails_on_windows => true do
+  it "should be able to remove dead links", :unless => 
Puppet.features.microsoft_windows? do
     dir = tmpfile("tidy_link_testing")
     link = File.join(dir, "link")
     target = tmpfile("no_such_file_tidy_link_testing")
diff --git a/spec/integration/util/autoload_spec.rb 
b/spec/integration/util/autoload_spec.rb
index 771e6a7..92fc655 100755
--- a/spec/integration/util/autoload_spec.rb
+++ b/spec/integration/util/autoload_spec.rb
@@ -94,7 +94,7 @@ describe Puppet::Util::Autoload do
     }
   end
 
-  it "should be able to load files directly from modules", :fails_on_windows 
=> true do
+  it "should be able to load files directly from modules" do
     modulepath = tmpfile("autoload_module_testing")
     libdir = File.join(modulepath, "mymod", "lib", "foo")
     FileUtils.mkdir_p(libdir)
diff --git a/spec/unit/application/inspect_spec.rb 
b/spec/unit/application/inspect_spec.rb
index be5887f..750f25a 100755
--- a/spec/unit/application/inspect_spec.rb
+++ b/spec/unit/application/inspect_spec.rb
@@ -148,7 +148,7 @@ describe Puppet::Application::Inspect do
           @inspect.run_command
         end
 
-        it "should not send unreadable files", :fails_on_windows => true do
+        it "should not send unreadable files", :unless => 
Puppet.features.microsoft_windows? do
           File.open(@file, 'w') { |f| f.write('stuff') }
           File.chmod(0, @file)
           Puppet::FileBucketFile::Rest.any_instance.expects(:head).never
diff --git a/spec/unit/face/ca_spec.rb b/spec/unit/face/ca_spec.rb
index b8c82ce..1df4d7c 100755
--- a/spec/unit/face/ca_spec.rb
+++ b/spec/unit/face/ca_spec.rb
@@ -2,7 +2,7 @@
 require 'spec_helper'
 require 'puppet/face'
 
-describe Puppet::Face[:ca, '0.1.0'] do
+describe Puppet::Face[:ca, '0.1.0'], :unless => 
Puppet.features.microsoft_windows? do
   include PuppetSpec::Files
 
   before :each do
diff --git a/spec/unit/network/handler/fileserver_spec.rb 
b/spec/unit/network/handler/fileserver_spec.rb
index 0885263..93f1248 100755
--- a/spec/unit/network/handler/fileserver_spec.rb
+++ b/spec/unit/network/handler/fileserver_spec.rb
@@ -41,12 +41,12 @@ describe Puppet::Network::Handler::FileServer do
     @mount.list("/no_such_file", false, false).should be(nil)
   end
 
-  it "should list a symbolic link as a file when given the link path" do
+  it "should list a symbolic link as a file when given the link path", :unless 
=> Puppet.features.microsoft_windows? do
     File.symlink(@file, @link)
     @mount.list("/aLink", false, false).should == [["/", "file"]]
   end
 
-  it "should return nil for a dangling symbolic link when given the link path" 
do
+  it "should return nil for a dangling symbolic link when given the link 
path", :unless => Puppet.features.microsoft_windows? do
     File.symlink("/some/where", @link)
     @mount.list("/aLink", false, false).should be(nil)
   end
@@ -106,18 +106,18 @@ describe Puppet::Network::Handler::FileServer do
     list.sort.should == [   ["/aFile", "file"], ["/", "directory"] , 
["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort
   end
 
-  it "should list a valid symbolic link as a file when recursing base dir" do
+  it "should list a valid symbolic link as a file when recursing base dir", 
:unless => Puppet.features.microsoft_windows? do
     File.symlink(@file, @link)
     list = @mount.list("/", true, false)
     list.sort.should == [ ["/", "directory"], ["/aFile", "file"], ["/aLink", 
"file"] ].sort
   end
 
-  it "should not error when a dangling symlink is present" do
+  it "should not error when a dangling symlink is present", :unless => 
Puppet.features.microsoft_windows? do
     File.symlink("/some/where", @link)
     lambda { @mount.list("/", true, false) }.should_not raise_error
   end
 
-  it "should return the directory contents of valid entries when a dangling 
symlink is present" do
+  it "should return the directory contents of valid entries when a dangling 
symlink is present", :unless => Puppet.features.microsoft_windows? do
     File.symlink("/some/where", @link)
     list = @mount.list("/", true, false)
     list.sort.should == [ ["/aFile", "file"], ["/", "directory"] ].sort
diff --git a/spec/unit/network/http/webrick_spec.rb 
b/spec/unit/network/http/webrick_spec.rb
index be74a10..8504b02 100755
--- a/spec/unit/network/http/webrick_spec.rb
+++ b/spec/unit/network/http/webrick_spec.rb
@@ -8,13 +8,13 @@ require 'puppet/network/handler'
 require 'puppet/network/http'
 require 'puppet/network/http/webrick'
 
-describe Puppet::Network::HTTP::WEBrick, "after initializing" do
+describe Puppet::Network::HTTP::WEBrick, "after initializing", :unless => 
Puppet.features.microsoft_windows? do
   it "should not be listening" do
     Puppet::Network::HTTP::WEBrick.new.should_not be_listening
   end
 end
 
-describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do
+describe Puppet::Network::HTTP::WEBrick, "when turning on listening", :unless 
=> Puppet.features.microsoft_windows? do
   before do
     @mock_webrick = stub('webrick', :[] => {}, :listeners => [], :status => 
:Running)
     [:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
@@ -143,7 +143,7 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on 
listening" do
 end
 
 
-describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle 
a protocol" do
+describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle 
a protocol", :unless => Puppet.features.microsoft_windows? do
   it "should require a protocol" do
     lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol }.should 
raise_error(ArgumentError)
   end
@@ -161,7 +161,7 @@ describe Puppet::Network::HTTP::WEBrick, "when looking up 
the class to handle a
   end
 end
 
-describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do
+describe Puppet::Network::HTTP::WEBrick, "when turning off listening", :unless 
=> Puppet.features.microsoft_windows? do
   before do
     @mock_webrick = stub('webrick', :[] => {}, :listeners => [], :status => 
:Running)
     [:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
@@ -188,7 +188,7 @@ describe Puppet::Network::HTTP::WEBrick, "when turning off 
listening" do
   end
 end
 
-describe Puppet::Network::HTTP::WEBrick do
+describe Puppet::Network::HTTP::WEBrick, :unless => 
Puppet.features.microsoft_windows? do
   before do
     @mock_webrick = stub('webrick', :[] => {})
     [:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
diff --git a/spec/unit/resource/catalog_spec.rb 
b/spec/unit/resource/catalog_spec.rb
index ce783e3..f5f779f 100755
--- a/spec/unit/resource/catalog_spec.rb
+++ b/spec/unit/resource/catalog_spec.rb
@@ -598,11 +598,12 @@ describe Puppet::Resource::Catalog, "when compiling" do
       end
 
       it "should conflict when its uniqueness key matches another resource's 
title" do
-        @resource = Puppet::Type.type(:file).new(:title => "/tmp/foo")
-        @other    = Puppet::Type.type(:file).new(:title => "another file", 
:path => "/tmp/foo")
+        path = make_absolute("/tmp/foo")
+        @resource = Puppet::Type.type(:file).new(:title => path)
+        @other    = Puppet::Type.type(:file).new(:title => "another file", 
:path => path)
 
         @catalog.add_resource(@resource)
-        expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, 
/Cannot alias File\[another file\] to \["\/tmp\/foo"\].*resource \["File", 
"\/tmp\/foo"\] already defined/)
+        expect { @catalog.add_resource(@other) }.to raise_error(ArgumentError, 
/Cannot alias File\[another file\] to \["#{Regexp.escape(path)}"\].*resource 
\["File", "#{Regexp.escape(path)}"\] already defined/)
       end
 
       it "should conflict when its uniqueness key matches the uniqueness key 
derived from another resource's title" do
diff --git a/spec/unit/ssl/inventory_spec.rb b/spec/unit/ssl/inventory_spec.rb
index 3d141d0..000f0a2 100755
--- a/spec/unit/ssl/inventory_spec.rb
+++ b/spec/unit/ssl/inventory_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
 
 require 'puppet/ssl/inventory'
 
-describe Puppet::SSL::Inventory do
+describe Puppet::SSL::Inventory, :unless => Puppet.features.microsoft_windows? 
do
   before do
     @class = Puppet::SSL::Inventory
   end
diff --git a/spec/unit/type/cron_spec.rb b/spec/unit/type/cron_spec.rb
index 7bf92eb..f2c1889 100755
--- a/spec/unit/type/cron_spec.rb
+++ b/spec/unit/type/cron_spec.rb
@@ -1,7 +1,7 @@
 #!/usr/bin/env rspec
 require 'spec_helper'
 
-describe Puppet::Type.type(:cron) do
+describe Puppet::Type.type(:cron), :unless => 
Puppet.features.microsoft_windows? do
   before do
     @class = Puppet::Type.type(:cron)
 
-- 
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