summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Cooper <josh@puppetlabs.com>2011-07-19 14:16:49 -0700
committerJosh Cooper <josh@puppetlabs.com>2011-07-19 14:16:49 -0700
commit21c5929aae899e559e9a813c48424da4fcbec54b (patch)
treefa90342427d0cd41c6aea56df8d89d2deb3def9d
parentd69bf48ecae71ff01679bb38cdeebc8f4a8b8b15 (diff)
parent0e4ae653c0628cb0df9ccace98bca4bc7478fb7c (diff)
downloadpuppet-21c5929aae899e559e9a813c48424da4fcbec54b.tar.gz
puppet-21c5929aae899e559e9a813c48424da4fcbec54b.tar.xz
puppet-21c5929aae899e559e9a813c48424da4fcbec54b.zip
Merge branch 'feature/master/8268-puppet-agent-windows'
* feature/master/8268-puppet-agent-windows: Maint: Fix miscellaneous tests Maint: Don't test for extended signals on Windows Maint: Tagged spec tests that are known to fail on Windows Fix tests with "relative" paths on Windows (#8268) Require windows drive letters in absolute file paths (#8489) Consistently use File::PATH_SEPARATOR
-rw-r--r--lib/puppet/defaults.rb8
-rw-r--r--lib/puppet/file_serving/fileset.rb9
-rw-r--r--lib/puppet/indirector/facts/facter.rb4
-rw-r--r--lib/puppet/node/environment.rb5
-rw-r--r--lib/puppet/parser/type_loader.rb3
-rw-r--r--lib/puppet/type/file.rb2
-rwxr-xr-xspec/integration/application/doc_spec.rb2
-rwxr-xr-xspec/integration/file_serving/terminus_helper_spec.rb2
-rwxr-xr-xspec/integration/indirector/direct_file_server_spec.rb8
-rwxr-xr-xspec/integration/indirector/file_content/file_server_spec.rb2
-rwxr-xr-xspec/integration/indirector/file_metadata/file_server_spec.rb2
-rwxr-xr-xspec/integration/parser/compiler_spec.rb2
-rwxr-xr-xspec/integration/parser/ruby_manifest_spec.rb2
-rwxr-xr-xspec/integration/provider/mount_spec.rb2
-rwxr-xr-xspec/integration/provider/package_spec.rb2
-rwxr-xr-x[-rw-r--r--]spec/integration/provider/ssh_authorized_key_spec.rb2
-rwxr-xr-xspec/integration/resource/type_collection_spec.rb2
-rwxr-xr-xspec/integration/ssl/certificate_authority_spec.rb2
-rwxr-xr-xspec/integration/ssl/certificate_request_spec.rb2
-rwxr-xr-xspec/integration/ssl/certificate_revocation_list_spec.rb2
-rwxr-xr-xspec/integration/ssl/host_spec.rb2
-rwxr-xr-xspec/integration/transaction_spec.rb24
-rwxr-xr-xspec/integration/type/file_spec.rb30
-rwxr-xr-xspec/integration/type/tidy_spec.rb2
-rwxr-xr-xspec/integration/util/autoload_spec.rb2
-rwxr-xr-xspec/integration/util/settings_spec.rb4
-rwxr-xr-xspec/lib/puppet_spec/files.rb10
-rwxr-xr-xspec/unit/application/device_spec.rb14
-rwxr-xr-xspec/unit/application/inspect_spec.rb3
-rwxr-xr-xspec/unit/application/master_spec.rb2
-rwxr-xr-xspec/unit/configurer/downloader_spec.rb7
-rwxr-xr-xspec/unit/daemon_spec.rb4
-rwxr-xr-xspec/unit/file_bucket/dipper_spec.rb6
-rwxr-xr-xspec/unit/file_serving/configuration_spec.rb5
-rwxr-xr-xspec/unit/file_serving/fileset_spec.rb126
-rwxr-xr-xspec/unit/indirector/certificate_request/ca_spec.rb2
-rwxr-xr-xspec/unit/indirector/certificate_status/file_spec.rb2
-rwxr-xr-xspec/unit/indirector/file_bucket_file/file_spec.rb6
-rwxr-xr-xspec/unit/indirector/resource/ral_spec.rb2
-rwxr-xr-xspec/unit/indirector/resource_type/parser_spec.rb6
-rwxr-xr-xspec/unit/indirector/ssl_file_spec.rb4
-rwxr-xr-xspec/unit/module_spec.rb4
-rwxr-xr-xspec/unit/network/http_pool_spec.rb2
-rwxr-xr-xspec/unit/node/environment_spec.rb13
-rwxr-xr-xspec/unit/other/selinux_spec.rb4
-rwxr-xr-xspec/unit/parser/compiler_spec.rb4
-rwxr-xr-xspec/unit/parser/files_spec.rb11
-rwxr-xr-xspec/unit/parser/functions/extlookup_spec.rb9
-rwxr-xr-xspec/unit/parser/functions/sprintf_spec.rb3
-rwxr-xr-xspec/unit/parser/type_loader_spec.rb14
-rwxr-xr-xspec/unit/property_spec.rb2
-rwxr-xr-xspec/unit/provider/exec/shell_spec.rb2
-rwxr-xr-xspec/unit/provider/host/parsed_spec.rb2
-rwxr-xr-xspec/unit/provider/macauthorization_spec.rb5
-rwxr-xr-xspec/unit/provider/mount/parsed_spec.rb2
-rwxr-xr-xspec/unit/provider/service/smf_spec.rb1
-rwxr-xr-xspec/unit/provider/ssh_authorized_key/parsed_spec.rb4
-rwxr-xr-xspec/unit/provider/user/user_role_add_spec.rb2
-rwxr-xr-xspec/unit/provider/user/useradd_spec.rb2
-rwxr-xr-xspec/unit/resource/catalog_spec.rb5
-rwxr-xr-xspec/unit/resource/status_spec.rb6
-rwxr-xr-xspec/unit/resource_spec.rb3
-rwxr-xr-xspec/unit/ssl/host_spec.rb2
-rwxr-xr-xspec/unit/ssl/inventory_spec.rb2
-rwxr-xr-xspec/unit/sslcertificates/ca_spec.rb2
-rwxr-xr-xspec/unit/transaction/event_manager_spec.rb6
-rwxr-xr-xspec/unit/transaction/event_spec.rb4
-rwxr-xr-xspec/unit/transaction/report_spec.rb4
-rwxr-xr-xspec/unit/transaction/resource_harness_spec.rb2
-rwxr-xr-xspec/unit/transaction_spec.rb4
-rwxr-xr-xspec/unit/type/exec_spec.rb59
-rwxr-xr-xspec/unit/type/file/checksum_spec.rb17
-rwxr-xr-xspec/unit/type/file/content_spec.rb3
-rwxr-xr-xspec/unit/type/file/selinux_spec.rb18
-rwxr-xr-xspec/unit/type/file/source_spec.rb36
-rwxr-xr-xspec/unit/type/file_spec.rb2
-rwxr-xr-xspec/unit/type/group_spec.rb2
-rwxr-xr-xspec/unit/type/host_spec.rb2
-rwxr-xr-xspec/unit/type/mount_spec.rb10
-rwxr-xr-xspec/unit/type/noop_metaparam_spec.rb4
-rwxr-xr-xspec/unit/type/resources_spec.rb2
-rwxr-xr-xspec/unit/type/ssh_authorized_key_spec.rb8
-rwxr-xr-xspec/unit/type/tidy_spec.rb4
-rwxr-xr-xspec/unit/type/user_spec.rb2
-rwxr-xr-xspec/unit/type_spec.rb43
-rwxr-xr-xspec/unit/util/autoload_spec.rb38
-rwxr-xr-xspec/unit/util/backups_spec.rb29
-rwxr-xr-xspec/unit/util/execution_stub_spec.rb2
-rwxr-xr-xspec/unit/util/log_spec.rb6
-rwxr-xr-xspec/unit/util/logging_spec.rb4
-rwxr-xr-xspec/unit/util/network_device/config_spec.rb8
-rwxr-xr-xspec/unit/util/rdoc/parser_spec.rb4
-rwxr-xr-xspec/unit/util/run_mode_spec.rb2
-rwxr-xr-xspec/unit/util/settings/file_setting_spec.rb9
-rwxr-xr-xspec/unit/util/settings_spec.rb14
-rwxr-xr-xspec/unit/util/storage_spec.rb2
96 files changed, 459 insertions, 325 deletions
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index d5e06c54a..e6beb512e 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -441,9 +441,11 @@ module Puppet
authorization system for `puppet master`."
],
:ca => [true, "Wether the master should function as a certificate authority."],
- :modulepath => {:default => "$confdir/modules:/usr/share/puppet/modules",
- :desc => "The search path for modules as a colon-separated list of
- directories.", :type => :setting }, # We don't want this to be considered a file, since it's multiple files.
+ :modulepath => {
+ :default => "$confdir/modules#{File::PATH_SEPARATOR}/usr/share/puppet/modules",
+ :desc => "The search path for modules as a list of directories separated by the '#{File::PATH_SEPARATOR}' character.",
+ :type => :setting # We don't want this to be considered a file, since it's multiple files.
+ },
:ssl_client_header => ["HTTP_X_CLIENT_DN", "The header containing an authenticated
client's SSL DN. Only used with Mongrel. This header must be set by the proxy
to the authenticated client's SSL DN (e.g., `/CN=puppet.puppetlabs.com`).
diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb
index f29f70a53..b4f1457df 100644
--- a/lib/puppet/file_serving/fileset.rb
+++ b/lib/puppet/file_serving/fileset.rb
@@ -59,8 +59,13 @@ class Puppet::FileServing::Fileset
end
def initialize(path, options = {})
- path = path.chomp(File::SEPARATOR) unless path == File::SEPARATOR
- raise ArgumentError.new("Fileset paths must be fully qualified") unless File.expand_path(path) == path
+ if Puppet.features.microsoft_windows?
+ # REMIND: UNC path
+ path = path.chomp(File::SEPARATOR) unless path =~ /^[A-Za-z]:\/$/
+ else
+ path = path.chomp(File::SEPARATOR) unless path == File::SEPARATOR
+ end
+ raise ArgumentError.new("Fileset paths must be fully qualified: #{path}") unless File.expand_path(path) == path
@path = path
diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb
index ab7378a34..6312a95fb 100644
--- a/lib/puppet/indirector/facts/facter.rb
+++ b/lib/puppet/indirector/facts/facter.rb
@@ -9,12 +9,12 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
def self.load_fact_plugins
# Add any per-module fact directories to the factpath
- module_fact_dirs = Puppet[:modulepath].split(":").collect do |d|
+ module_fact_dirs = Puppet[:modulepath].split(File::PATH_SEPARATOR).collect do |d|
["lib", "plugins"].map do |subdirectory|
Dir.glob("#{d}/*/#{subdirectory}/facter")
end
end.flatten
- dirs = module_fact_dirs + Puppet[:factpath].split(":")
+ dirs = module_fact_dirs + Puppet[:factpath].split(File::PATH_SEPARATOR)
x = dirs.each do |dir|
load_facts_in_dir(dir)
end
diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb
index dc631979e..96fdc3c1e 100644
--- a/lib/puppet/node/environment.rb
+++ b/lib/puppet/node/environment.rb
@@ -136,14 +136,15 @@ class Puppet::Node::Environment
end
def validate_dirs(dirs)
+ dir_regex = Puppet.features.microsoft_windows? ? /^[A-Za-z]:#{File::SEPARATOR}/ : /^#{File::SEPARATOR}/
dirs.collect do |dir|
- if dir !~ /^#{File::SEPARATOR}/
+ if dir !~ dir_regex
File.join(Dir.getwd, dir)
else
dir
end
end.find_all do |p|
- p =~ /^#{File::SEPARATOR}/ && FileTest.directory?(p)
+ p =~ dir_regex && FileTest.directory?(p)
end
end
diff --git a/lib/puppet/parser/type_loader.rb b/lib/puppet/parser/type_loader.rb
index 1fba73d0b..68def068d 100644
--- a/lib/puppet/parser/type_loader.rb
+++ b/lib/puppet/parser/type_loader.rb
@@ -80,7 +80,8 @@ class Puppet::Parser::TypeLoader
loaded_asts = []
files.each do |file|
- unless file =~ /^#{File::SEPARATOR}/
+ regex = Puppet.features.microsoft_windows? ? /^[A-Za-z]:#{File::SEPARATOR}/ : /^#{File::SEPARATOR}/
+ unless file =~ regex
file = File.join(dir, file)
end
@loading_helper.do_once(file) do
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 72e9a9495..8ab12ca2f 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -36,7 +36,7 @@ Puppet::Type.newtype(:file) do
validate do |value|
# accept various path syntaxes: lone slash, posix, win32, unc
- unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
+ unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^[A-Za-z]:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
fail Puppet::Error, "File paths must be fully qualified, not '#{value}'"
end
end
diff --git a/spec/integration/application/doc_spec.rb b/spec/integration/application/doc_spec.rb
index 9412976f0..47fd93a03 100755
--- a/spec/integration/application/doc_spec.rb
+++ b/spec/integration/application/doc_spec.rb
@@ -5,7 +5,7 @@ require 'puppet_spec/files'
describe Puppet::Application::Doc do
include PuppetSpec::Files
- it "should not generate an error when module dir overlaps parent of site.pp (#4798)", :'fails_on_ruby_1.9.2' => true do
+ it "should not generate an error when module dir overlaps parent of site.pp (#4798)", :'fails_on_ruby_1.9.2' => true, :fails_on_windows => true do
begin
# Note: the directory structure below is more complex than it
# needs to be, but it's representative of the directory structure
diff --git a/spec/integration/file_serving/terminus_helper_spec.rb b/spec/integration/file_serving/terminus_helper_spec.rb
index 7500b1fc0..99fee9ce5 100755
--- a/spec/integration/file_serving/terminus_helper_spec.rb
+++ b/spec/integration/file_serving/terminus_helper_spec.rb
@@ -10,7 +10,7 @@ class TerminusHelperIntegrationTester
end
end
-describe Puppet::FileServing::TerminusHelper do
+describe Puppet::FileServing::TerminusHelper, :fails_on_windows => true do
it "should be able to recurse on a single file" do
@path = Tempfile.new("fileset_integration")
request = Puppet::Indirector::Request.new(:metadata, :find, @path.path, :recurse => true)
diff --git a/spec/integration/indirector/direct_file_server_spec.rb b/spec/integration/indirector/direct_file_server_spec.rb
index e53b48d69..68ed00740 100755
--- a/spec/integration/indirector/direct_file_server_spec.rb
+++ b/spec/integration/indirector/direct_file_server_spec.rb
@@ -7,12 +7,14 @@ require 'spec_helper'
require 'puppet/indirector/file_content/file'
-describe Puppet::Indirector::DirectFileServer, " when interacting with the filesystem and the model" do
+describe Puppet::Indirector::DirectFileServer, " when interacting with the filesystem and the model", :fails_on_windows => true do
+ include PuppetSpec::Files
+
before do
# We just test a subclass, since it's close enough.
@terminus = Puppet::Indirector::FileContent::File.new
- @filepath = "/path/to/my/file"
+ @filepath = make_absolute("/path/to/my/file")
end
it "should return an instance of the model" do
@@ -32,7 +34,7 @@ describe Puppet::Indirector::DirectFileServer, " when interacting with the files
end
end
-describe Puppet::Indirector::DirectFileServer, " when interacting with FileServing::Fileset and the model" do
+describe Puppet::Indirector::DirectFileServer, " when interacting with FileServing::Fileset and the model", :fails_on_windows => true do
before do
@terminus = Puppet::Indirector::FileContent::File.new
diff --git a/spec/integration/indirector/file_content/file_server_spec.rb b/spec/integration/indirector/file_content/file_server_spec.rb
index 88d2345d8..2a8c134a4 100755
--- a/spec/integration/indirector/file_content/file_server_spec.rb
+++ b/spec/integration/indirector/file_content/file_server_spec.rb
@@ -10,7 +10,7 @@ require 'shared_behaviours/file_server_terminus'
require 'puppet_spec/files'
-describe Puppet::Indirector::FileContent::FileServer, " when finding files" do
+describe Puppet::Indirector::FileContent::FileServer, " when finding files", :fails_on_windows => true do
it_should_behave_like "Puppet::Indirector::FileServerTerminus"
include PuppetSpec::Files
diff --git a/spec/integration/indirector/file_metadata/file_server_spec.rb b/spec/integration/indirector/file_metadata/file_server_spec.rb
index 9e84134a6..5259837fc 100755
--- a/spec/integration/indirector/file_metadata/file_server_spec.rb
+++ b/spec/integration/indirector/file_metadata/file_server_spec.rb
@@ -8,7 +8,7 @@ require 'spec_helper'
require 'puppet/indirector/file_metadata/file_server'
require 'shared_behaviours/file_server_terminus'
-describe Puppet::Indirector::FileMetadata::FileServer, " when finding files" do
+describe Puppet::Indirector::FileMetadata::FileServer, " when finding files", :fails_on_windows => true do
it_should_behave_like "Puppet::Indirector::FileServerTerminus"
before do
diff --git a/spec/integration/parser/compiler_spec.rb b/spec/integration/parser/compiler_spec.rb
index 9f6aae907..51611f888 100755
--- a/spec/integration/parser/compiler_spec.rb
+++ b/spec/integration/parser/compiler_spec.rb
@@ -13,7 +13,7 @@ describe Puppet::Parser::Compiler do
Puppet.settings.clear
end
- it "should be able to determine the configuration version from a local version control repository" do
+ it "should be able to determine the configuration version from a local version control repository", :fails_on_windows => true do
# This should always work, because we should always be
# in the puppet repo when we run this.
version = %x{git rev-parse HEAD}.chomp
diff --git a/spec/integration/parser/ruby_manifest_spec.rb b/spec/integration/parser/ruby_manifest_spec.rb
index 7f3bb71e9..b04baf5e0 100755
--- a/spec/integration/parser/ruby_manifest_spec.rb
+++ b/spec/integration/parser/ruby_manifest_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
require 'tempfile'
require 'puppet_spec/files'
-describe "Pure ruby manifests" do
+describe "Pure ruby manifests", :fails_on_windows => true do
include PuppetSpec::Files
before do
diff --git a/spec/integration/provider/mount_spec.rb b/spec/integration/provider/mount_spec.rb
index 4af0dca4a..eb8cc134a 100755
--- a/spec/integration/provider/mount_spec.rb
+++ b/spec/integration/provider/mount_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
require 'puppet/file_bucket/dipper'
-describe "mount provider (integration)" do
+describe "mount provider (integration)", :fails_on_windows => true do
include PuppetSpec::Files
def create_fake_fstab(initially_contains_entry)
diff --git a/spec/integration/provider/package_spec.rb b/spec/integration/provider/package_spec.rb
index 5fecdf13c..701752371 100755
--- a/spec/integration/provider/package_spec.rb
+++ b/spec/integration/provider/package_spec.rb
@@ -12,7 +12,7 @@ describe "Package Provider", :'fails_on_ruby_1.9.2' => true do
lambda { pkg.provider.install }.should raise_error
end
- it "should be able to get a list of existing packages" do
+ it "should be able to get a list of existing packages", :fails_on_windows => true do
provider.instances.each do |package|
package.should be_instance_of(provider)
package.properties[:provider].should == provider.name
diff --git a/spec/integration/provider/ssh_authorized_key_spec.rb b/spec/integration/provider/ssh_authorized_key_spec.rb
index 902f9ad22..f7f61ab25 100644..100755
--- a/spec/integration/provider/ssh_authorized_key_spec.rb
+++ b/spec/integration/provider/ssh_authorized_key_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
require 'puppet/file_bucket/dipper'
-describe "ssh_authorized_key provider (integration)" do
+describe "ssh_authorized_key provider (integration)", :fails_on_windows => true do
include PuppetSpec::Files
before :each do
diff --git a/spec/integration/resource/type_collection_spec.rb b/spec/integration/resource/type_collection_spec.rb
index 6ea2e7fe7..0852a9850 100755
--- a/spec/integration/resource/type_collection_spec.rb
+++ b/spec/integration/resource/type_collection_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
require 'puppet_spec/files'
require 'puppet/resource/type_collection'
-describe Puppet::Resource::TypeCollection do
+describe Puppet::Resource::TypeCollection, :fails_on_windows => true do
describe "when autoloading from modules" do
include PuppetSpec::Files
diff --git a/spec/integration/ssl/certificate_authority_spec.rb b/spec/integration/ssl/certificate_authority_spec.rb
index c5e145459..c6ff58ed0 100755
--- a/spec/integration/ssl/certificate_authority_spec.rb
+++ b/spec/integration/ssl/certificate_authority_spec.rb
@@ -8,7 +8,7 @@ require 'spec_helper'
require 'puppet/ssl/certificate_authority'
require 'tempfile'
-describe Puppet::SSL::CertificateAuthority do
+describe Puppet::SSL::CertificateAuthority, :fails_on_windows => true do
before do
# Get a safe temporary file
file = Tempfile.new("ca_integration_testing")
diff --git a/spec/integration/ssl/certificate_request_spec.rb b/spec/integration/ssl/certificate_request_spec.rb
index 688466c37..31bb48d66 100755
--- a/spec/integration/ssl/certificate_request_spec.rb
+++ b/spec/integration/ssl/certificate_request_spec.rb
@@ -8,7 +8,7 @@ require 'spec_helper'
require 'puppet/ssl/certificate_request'
require 'tempfile'
-describe Puppet::SSL::CertificateRequest do
+describe Puppet::SSL::CertificateRequest, :fails_on_windows => true do
before do
# Get a safe temporary file
file = Tempfile.new("csr_integration_testing")
diff --git a/spec/integration/ssl/certificate_revocation_list_spec.rb b/spec/integration/ssl/certificate_revocation_list_spec.rb
index 051a81569..95f0e6314 100755
--- a/spec/integration/ssl/certificate_revocation_list_spec.rb
+++ b/spec/integration/ssl/certificate_revocation_list_spec.rb
@@ -8,7 +8,7 @@ require 'spec_helper'
require 'puppet/ssl/certificate_revocation_list'
require 'tempfile'
-describe Puppet::SSL::CertificateRevocationList do
+describe Puppet::SSL::CertificateRevocationList, :fails_on_windows => true do
before do
# Get a safe temporary file
file = Tempfile.new("ca_integration_testing")
diff --git a/spec/integration/ssl/host_spec.rb b/spec/integration/ssl/host_spec.rb
index e9c37c151..2da5bcfe3 100755
--- a/spec/integration/ssl/host_spec.rb
+++ b/spec/integration/ssl/host_spec.rb
@@ -8,7 +8,7 @@ require 'spec_helper'
require 'puppet/ssl/host'
require 'tempfile'
-describe Puppet::SSL::Host do
+describe Puppet::SSL::Host, :fails_on_windows => true do
before do
# Get a safe temporary file
file = Tempfile.new("host_integration_testing")
diff --git a/spec/integration/transaction_spec.rb b/spec/integration/transaction_spec.rb
index 00e9dbb8e..b4214214e 100755
--- a/spec/integration/transaction_spec.rb
+++ b/spec/integration/transaction_spec.rb
@@ -1,9 +1,7 @@
#!/usr/bin/env rspec
require 'spec_helper'
-require 'puppet_spec/files'
require 'puppet/transaction'
-require 'puppet_spec/files'
describe Puppet::Transaction do
include PuppetSpec::Files
@@ -20,10 +18,10 @@ describe Puppet::Transaction do
it "should not apply generated resources if the parent resource fails" do
catalog = Puppet::Resource::Catalog.new
- resource = Puppet::Type.type(:file).new :path => "/foo/bar", :backup => false
+ resource = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar"), :backup => false
catalog.add_resource resource
- child_resource = Puppet::Type.type(:file).new :path => "/foo/bar/baz", :backup => false
+ child_resource = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar/baz"), :backup => false
resource.expects(:eval_generate).returns([child_resource])
@@ -39,7 +37,7 @@ describe Puppet::Transaction do
it "should not apply virtual resources" do
catalog = Puppet::Resource::Catalog.new
- resource = Puppet::Type.type(:file).new :path => "/foo/bar", :backup => false
+ resource = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar"), :backup => false
resource.virtual = true
catalog.add_resource resource
@@ -63,7 +61,7 @@ describe Puppet::Transaction do
it "should not apply virtual exported resources" do
catalog = Puppet::Resource::Catalog.new
- resource = Puppet::Type.type(:file).new :path => "/foo/bar", :backup => false
+ resource = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar"), :backup => false
resource.exported = true
resource.virtual = true
catalog.add_resource resource
@@ -91,7 +89,7 @@ describe Puppet::Transaction do
it "should not apply host resources on device" do
catalog = Puppet::Resource::Catalog.new
- resource = Puppet::Type.type(:file).new :path => "/foo/bar", :backup => false
+ resource = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar"), :backup => false
catalog.add_resource resource
transaction = Puppet::Transaction.new(catalog)
@@ -133,7 +131,7 @@ describe Puppet::Transaction do
# Verify that one component requiring another causes the contained
# resources in the requiring component to get refreshed.
- it "should propagate events from a contained resource through its container to its dependent container's contained resources" do
+ it "should propagate events from a contained resource through its container to its dependent container's contained resources", :fails_on_windows => true do
transaction = nil
file = Puppet::Type.type(:file).new :path => tmpfile("event_propagation"), :ensure => :present
execfile = File.join(tmpdir("exec_event"), "exectestingness2")
@@ -157,7 +155,7 @@ describe Puppet::Transaction do
end
# Make sure that multiple subscriptions get triggered.
- it "should propagate events to all dependent resources" do
+ it "should propagate events to all dependent resources", :fails_on_windows => true do
path = tmpfile("path")
file1 = tmpfile("file1")
file2 = tmpfile("file2")
@@ -187,7 +185,7 @@ describe Puppet::Transaction do
FileTest.should be_exist(file2)
end
- it "should not let one failed refresh result in other refreshes failing" do
+ it "should not let one failed refresh result in other refreshes failing", :fails_on_windows => true do
path = tmpfile("path")
newfile = tmpfile("file")
file = Puppet::Type.type(:file).new(
@@ -220,7 +218,7 @@ describe Puppet::Transaction do
FileTest.should be_exists(newfile)
end
- it "should still trigger skipped resources", :'fails_on_ruby_1.9.2' => true do
+ it "should still trigger skipped resources", :'fails_on_ruby_1.9.2' => true, :fails_on_windows => true do
catalog = mk_catalog
catalog.add_resource(*Puppet::Type.type(:schedule).mkdefaultschedules)
@@ -272,7 +270,7 @@ describe Puppet::Transaction do
FileTest.should be_exists(fname)
end
- it "should not attempt to evaluate resources with failed dependencies" do
+ it "should not attempt to evaluate resources with failed dependencies", :fails_on_windows => true do
exec = Puppet::Type.type(:exec).new(
:command => "/bin/mkdir /this/path/cannot/possibly/exist",
@@ -300,7 +298,7 @@ describe Puppet::Transaction do
FileTest.should_not be_exists(file2[:path])
end
- it "should not trigger subscribing resources on failure" do
+ it "should not trigger subscribing resources on failure", :fails_on_windows => true do
file1 = tmpfile("file1")
file2 = tmpfile("file2")
diff --git a/spec/integration/type/file_spec.rb b/spec/integration/type/file_spec.rb
index 4bed8c6c1..241861cc5 100755
--- a/spec/integration/type/file_spec.rb
+++ b/spec/integration/type/file_spec.rb
@@ -12,7 +12,7 @@ describe Puppet::Type.type(:file) do
end
it "should not attempt to manage files that do not exist if no means of creating the file is specified" do
- file = Puppet::Type.type(:file).new :path => "/my/file", :mode => "755"
+ file = Puppet::Type.type(:file).new :path => make_absolute("/my/file"), :mode => "755"
catalog = Puppet::Resource::Catalog.new
catalog.add_resource file
@@ -23,7 +23,7 @@ describe Puppet::Type.type(:file) do
end
describe "when writing files" do
- it "should backup files to a filebucket when one is configured" do
+ it "should backup files to a filebucket when one is configured", :fails_on_windows => true do
bucket = Puppet::Type.type(:filebucket).new :path => tmpfile("filebucket"), :name => "mybucket"
file = Puppet::Type.type(:file).new :path => tmpfile("bucket_backs"), :backup => "mybucket", :content => "foo"
catalog = Puppet::Resource::Catalog.new
@@ -73,7 +73,7 @@ describe Puppet::Type.type(:file) do
File.read(file[:path]).should == "bar\n"
end
- it "should not backup symlinks" do
+ it "should not backup symlinks", :fails_on_windows => true do
link = tmpfile("link")
dest1 = tmpfile("dest1")
dest2 = tmpfile("dest2")
@@ -110,7 +110,7 @@ describe Puppet::Type.type(:file) do
File.read(File.join(backup, "foo")).should == "yay"
end
- it "should backup directories to filebuckets by backing up each file separately" do
+ it "should backup directories to filebuckets by backing up each file separately", :fails_on_windows => true do
bucket = Puppet::Type.type(:filebucket).new :path => tmpfile("filebucket"), :name => "mybucket"
file = Puppet::Type.type(:file).new :path => tmpfile("bucket_backs"), :backup => "mybucket", :content => "foo", :force => true
catalog = Puppet::Resource::Catalog.new
@@ -172,7 +172,7 @@ describe Puppet::Type.type(:file) do
end
end
- it "should be able to recurse over a nonexistent file" do
+ it "should be able to recurse over a nonexistent file", :fails_on_windows => true do
@path = tmpfile("file_integration_tests")
@file = Puppet::Type::File.new(
@@ -214,7 +214,7 @@ describe Puppet::Type.type(:file) do
end
end
- it "should be able to recursively make links to other files" do
+ it "should be able to recursively make links to other files", :fails_on_windows => true do
source = tmpfile("file_link_integration_source")
build_path(source)
@@ -241,7 +241,7 @@ describe Puppet::Type.type(:file) do
end
end
- it "should be able to recursively copy files" do
+ it "should be able to recursively copy files", :fails_on_windows => true do
source = tmpfile("file_source_integration_source")
build_path(source)
@@ -289,7 +289,7 @@ describe Puppet::Type.type(:file) do
(File.stat(file).mode & 007777).should == 0644
end
- it "should recursively manage files even if there is an explicit file whose name is a prefix of the managed file" do
+ it "should recursively manage files even if there is an explicit file whose name is a prefix of the managed file", :fails_on_windows => true do
dir = tmpfile("recursion_vs_explicit_2")
managed = File.join(dir, "file")
@@ -309,7 +309,7 @@ describe Puppet::Type.type(:file) do
end
end
- describe "when generating resources" do
+ describe "when generating resources", :fails_on_windows => true do
before do
@source = tmpfile("generating_in_catalog_source")
@@ -349,7 +349,7 @@ describe Puppet::Type.type(:file) do
describe "when copying files" do
# Ticket #285.
- it "should be able to copy files with pound signs in their names" do
+ it "should be able to copy files with pound signs in their names", :fails_on_windows => true do
source = tmpfile("filewith#signs")
dest = tmpfile("destwith#signs")
@@ -366,7 +366,7 @@ describe Puppet::Type.type(:file) do
File.read(dest).should == "foo"
end
- it "should be able to copy files with spaces in their names" do
+ it "should be able to copy files with spaces in their names", :fails_on_windows => true do
source = tmpfile("filewith spaces")
dest = tmpfile("destwith spaces")
@@ -385,7 +385,7 @@ describe Puppet::Type.type(:file) do
(File.stat(dest).mode & 007777).should == 0755
end
- it "should be able to copy individual files even if recurse has been specified" do
+ it "should be able to copy individual files even if recurse has been specified", :fails_on_windows => true do
source = tmpfile("source")
dest = tmpfile("dest")
@@ -434,7 +434,7 @@ describe Puppet::Type.type(:file) do
File.read(dest).should == "this is some content, yo"
end
- it "should delete files with sources but that are set for deletion" do
+ it "should delete files with sources but that are set for deletion", :fails_on_windows => true do
dest = tmpfile("dest_source_with_ensure")
source = tmpfile("source_source_with_ensure")
File.open(source, "w") { |f| f.puts "yay" }
@@ -442,7 +442,7 @@ describe Puppet::Type.type(:file) do
file = Puppet::Type.type(:file).new(
- :name => dest,
+ :name => make_absolute(dest),
:ensure => :absent,
:source => source,
:backup => false
@@ -455,7 +455,7 @@ describe Puppet::Type.type(:file) do
File.should_not be_exist(dest)
end
- describe "when purging files" do
+ describe "when purging files", :fails_on_windows => true do
before do
@sourcedir = tmpfile("purge_source")
@destdir = tmpfile("purge_dest")
diff --git a/spec/integration/type/tidy_spec.rb b/spec/integration/type/tidy_spec.rb
index 675aaf4cd..08a24099c 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" do
+ it "should be able to remove dead links", :fails_on_windows => true 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 92fc6554c..771e6a718 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" do
+ it "should be able to load files directly from modules", :fails_on_windows => true do
modulepath = tmpfile("autoload_module_testing")
libdir = File.join(modulepath, "mymod", "lib", "foo")
FileUtils.mkdir_p(libdir)
diff --git a/spec/integration/util/settings_spec.rb b/spec/integration/util/settings_spec.rb
index b05c63107..46d783c4e 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/lib/puppet_spec/files.rb b/spec/lib/puppet_spec/files.rb
index 30fb4fc42..9e75d3142 100755
--- a/spec/lib/puppet_spec/files.rb
+++ b/spec/lib/puppet_spec/files.rb
@@ -31,6 +31,16 @@ module PuppetSpec::Files
end
end
+ def make_absolute(path)
+ return path unless Puppet.features.microsoft_windows?
+ # REMIND UNC
+ return path if path =~ /^[A-Za-z]:/
+
+ pwd = Dir.getwd
+ return "#{pwd[0,2]}#{path}" if pwd.length > 2 and pwd =~ /^[A-Za-z]:/
+ return "C:#{path}"
+ end
+
def tmpfile(name)
# Generate a temporary file, just for the name...
source = Tempfile.new(name)
diff --git a/spec/unit/application/device_spec.rb b/spec/unit/application/device_spec.rb
index 42a62da22..f88c0c3d9 100755
--- a/spec/unit/application/device_spec.rb
+++ b/spec/unit/application/device_spec.rb
@@ -7,6 +7,8 @@ require 'ostruct'
require 'puppet/configurer'
describe Puppet::Application::Device do
+ include PuppetSpec::Files
+
before :each do
@device = Puppet::Application[:device]
@device.preinit
@@ -264,8 +266,8 @@ describe Puppet::Application::Device do
describe "for each device" do
before(:each) do
- Puppet[:vardir] = "/dummy"
- Puppet[:confdir] = "/dummy"
+ Puppet[:vardir] = make_absolute("/dummy")
+ Puppet[:confdir] = make_absolute("/dummy")
Puppet[:certname] = "certname"
@device_hash = {
"device1" => OpenStruct.new(:name => "device1", :url => "url", :provider => "cisco"),
@@ -281,12 +283,12 @@ describe Puppet::Application::Device do
end
it "should set vardir to the device vardir" do
- Puppet.settings.expects(:set_value).with(:vardir, "/dummy/devices/device1", :cli)
+ Puppet.settings.expects(:set_value).with(:vardir, make_absolute("/dummy/devices/device1"), :cli)
@device.main
end
it "should set confdir to the device confdir" do
- Puppet.settings.expects(:set_value).with(:confdir, "/dummy/devices/device1", :cli)
+ Puppet.settings.expects(:set_value).with(:confdir, make_absolute("/dummy/devices/device1"), :cli)
@device.main
end
@@ -319,9 +321,9 @@ describe Puppet::Application::Device do
[:vardir, :confdir].each do |setting|
it "should cleanup the #{setting} setting after the run" do
configurer = states('configurer').starts_as('notrun')
- Puppet.settings.expects(:set_value).with(setting, "/dummy/devices/device1", :cli).when(configurer.is('notrun'))
+ Puppet.settings.expects(:set_value).with(setting, make_absolute("/dummy/devices/device1"), :cli).when(configurer.is('notrun'))
@configurer.expects(:run).twice.then(configurer.is('run'))
- Puppet.settings.expects(:set_value).with(setting, "/dummy", :cli).when(configurer.is('run'))
+ Puppet.settings.expects(:set_value).with(setting, make_absolute("/dummy"), :cli).when(configurer.is('run'))
@device.main
end
diff --git a/spec/unit/application/inspect_spec.rb b/spec/unit/application/inspect_spec.rb
index 571683f37..9f12c83ad 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)
@@ -142,7 +143,7 @@ describe Puppet::Application::Inspect do
@inspect.run_command
end
- it "should not send unreadable files" do
+ it "should not send unreadable files", :fails_on_windows => true 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/application/master_spec.rb b/spec/unit/application/master_spec.rb
index e36df8caa..636988fd0 100755
--- a/spec/unit/application/master_spec.rb
+++ b/spec/unit/application/master_spec.rb
@@ -5,7 +5,7 @@ require 'puppet/application/master'
require 'puppet/daemon'
require 'puppet/network/server'
-describe Puppet::Application::Master do
+describe Puppet::Application::Master, :fails_on_windows => true do
before :each do
@master = Puppet::Application[:master]
@daemon = stub_everything 'daemon'
diff --git a/spec/unit/configurer/downloader_spec.rb b/spec/unit/configurer/downloader_spec.rb
index 17b285d53..8bb6a3dc6 100755
--- a/spec/unit/configurer/downloader_spec.rb
+++ b/spec/unit/configurer/downloader_spec.rb
@@ -97,14 +97,15 @@ describe Puppet::Configurer::Downloader do
describe "when creating the catalog to do the downloading" do
before do
- @dler = Puppet::Configurer::Downloader.new("foo", "/download/path", "source")
+ @path = make_absolute("/download/path")
+ @dler = Puppet::Configurer::Downloader.new("foo", @path, "source")
end
it "should create a catalog and add the file to it" do
catalog = @dler.catalog
catalog.resources.size.should == 1
catalog.resources.first.class.should == Puppet::Type::File
- catalog.resources.first.name.should == "/download/path"
+ catalog.resources.first.name.should == @path
end
it "should specify that it is not managing a host catalog" do
@@ -121,7 +122,7 @@ describe Puppet::Configurer::Downloader do
@dler = Puppet::Configurer::Downloader.new("foo", @dl_name, source_name)
end
- it "should not skip downloaded resources when filtering on tags" do
+ it "should not skip downloaded resources when filtering on tags", :fails_on_windows => true do
Puppet[:tags] = 'maytag'
@dler.evaluate
diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb
index e2679a966..fc43d93ad 100755
--- a/spec/unit/daemon_spec.rb
+++ b/spec/unit/daemon_spec.rb
@@ -28,7 +28,9 @@ describe Puppet::Daemon do
end
describe "when setting signal traps" do
- {:INT => :stop, :TERM => :stop, :HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs}.each do |signal, method|
+ signals = {:INT => :stop, :TERM => :stop }
+ signals.update({:HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs}) unless Puppet.features.microsoft_windows?
+ signals.each do |signal, method|
it "should log and call #{method} when it receives #{signal}" do
Signal.expects(:trap).with(signal).yields
diff --git a/spec/unit/file_bucket/dipper_spec.rb b/spec/unit/file_bucket/dipper_spec.rb
index 910b2808d..431b12371 100755
--- a/spec/unit/file_bucket/dipper_spec.rb
+++ b/spec/unit/file_bucket/dipper_spec.rb
@@ -16,7 +16,7 @@ describe Puppet::FileBucket::Dipper do
end
it "should fail in an informative way when there are failures checking for the file on the server" do
- @dipper = Puppet::FileBucket::Dipper.new(:Path => "/my/bucket")
+ @dipper = Puppet::FileBucket::Dipper.new(:Path => make_absolute("/my/bucket"))
file = make_tmp_file('contents')
Puppet::FileBucket::File.indirection.expects(:head).raises ArgumentError
@@ -25,7 +25,7 @@ describe Puppet::FileBucket::Dipper do
end
it "should fail in an informative way when there are failures backing up to the server" do
- @dipper = Puppet::FileBucket::Dipper.new(:Path => "/my/bucket")
+ @dipper = Puppet::FileBucket::Dipper.new(:Path => make_absolute("/my/bucket"))
file = make_tmp_file('contents')
Puppet::FileBucket::File.indirection.expects(:head).returns false
@@ -34,7 +34,7 @@ describe Puppet::FileBucket::Dipper do
lambda { @dipper.backup(file) }.should raise_error(Puppet::Error)
end
- it "should backup files to a local bucket" do
+ it "should backup files to a local bucket", :fails_on_windows => true do
Puppet[:bucketdir] = "/non/existent/directory"
file_bucket = tmpdir("bucket")
diff --git a/spec/unit/file_serving/configuration_spec.rb b/spec/unit/file_serving/configuration_spec.rb
index 6ee1a4f38..ed8663853 100755
--- a/spec/unit/file_serving/configuration_spec.rb
+++ b/spec/unit/file_serving/configuration_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
require 'puppet/file_serving/configuration'
-describe Puppet::FileServing::Configuration do
+describe Puppet::FileServing::Configuration, :fails_on_windows => true do
it "should make :new a private method" do
proc { Puppet::FileServing::Configuration.new }.should raise_error
end
@@ -24,9 +24,10 @@ describe Puppet::FileServing::Configuration do
end
describe Puppet::FileServing::Configuration do
+ include PuppetSpec::Files
before :each do
- @path = "/path/to/configuration/file.conf"
+ @path = make_absolute("/path/to/configuration/file.conf")
Puppet.settings.stubs(:value).with(:trace).returns(false)
Puppet.settings.stubs(:value).with(:fileserverconfig).returns(@path)
end
diff --git a/spec/unit/file_serving/fileset_spec.rb b/spec/unit/file_serving/fileset_spec.rb
index 41810650a..aff4c91fa 100755
--- a/spec/unit/file_serving/fileset_spec.rb
+++ b/spec/unit/file_serving/fileset_spec.rb
@@ -4,6 +4,12 @@ require 'spec_helper'
require 'puppet/file_serving/fileset'
describe Puppet::FileServing::Fileset, " when initializing" do
+ include PuppetSpec::Files
+
+ before :each do
+ @somefile = make_absolute("/some/file")
+ end
+
it "should require a path" do
proc { Puppet::FileServing::Fileset.new }.should raise_error(ArgumentError)
end
@@ -13,83 +19,82 @@ describe Puppet::FileServing::Fileset, " when initializing" do
end
it "should not fail if the path is fully qualified, with a trailing separator" do
- path = "/some/path/with/trailing/separator"
- path_with_separator = "#{path}#{File::SEPARATOR}"
- File.stubs(:lstat).with(path).returns stub('stat')
+ path_with_separator = "#{@somefile}#{File::SEPARATOR}"
+ File.stubs(:lstat).with(@somefile).returns stub('stat')
fileset = Puppet::FileServing::Fileset.new(path_with_separator)
- fileset.path.should == path
+ fileset.path.should == @somefile
end
it "should not fail if the path is just the file separator" do
- path = File::SEPARATOR
+ path = make_absolute(File::SEPARATOR)
File.stubs(:lstat).with(path).returns stub('stat')
fileset = Puppet::FileServing::Fileset.new(path)
fileset.path.should == path
end
it "should fail if its path does not exist" do
- File.expects(:lstat).with("/some/file").returns nil
- proc { Puppet::FileServing::Fileset.new("/some/file") }.should raise_error(ArgumentError)
+ File.expects(:lstat).with(@somefile).returns nil
+ proc { Puppet::FileServing::Fileset.new(@somefile) }.should raise_error(ArgumentError)
end
it "should accept a 'recurse' option" do
- File.expects(:lstat).with("/some/file").returns stub("stat")
- set = Puppet::FileServing::Fileset.new("/some/file", :recurse => true)
+ File.expects(:lstat).with(@somefile).returns stub("stat")
+ set = Puppet::FileServing::Fileset.new(@somefile, :recurse => true)
set.recurse.should be_true
end
it "should accept a 'recurselimit' option" do
- File.expects(:lstat).with("/some/file").returns stub("stat")
- set = Puppet::FileServing::Fileset.new("/some/file", :recurselimit => 3)
+ File.expects(:lstat).with(@somefile).returns stub("stat")
+ set = Puppet::FileServing::Fileset.new(@somefile, :recurselimit => 3)
set.recurselimit.should == 3
end
it "should accept an 'ignore' option" do
- File.expects(:lstat).with("/some/file").returns stub("stat")
- set = Puppet::FileServing::Fileset.new("/some/file", :ignore => ".svn")
+ File.expects(:lstat).with(@somefile).returns stub("stat")
+ set = Puppet::FileServing::Fileset.new(@somefile, :ignore => ".svn")
set.ignore.should == [".svn"]
end
it "should accept a 'links' option" do
- File.expects(:lstat).with("/some/file").returns stub("stat")
- set = Puppet::FileServing::Fileset.new("/some/file", :links => :manage)
+ File.expects(:lstat).with(@somefile).returns stub("stat")
+ set = Puppet::FileServing::Fileset.new(@somefile, :links => :manage)
set.links.should == :manage
end
it "should accept a 'checksum_type' option" do
- File.expects(:lstat).with("/some/file").returns stub("stat")
- set = Puppet::FileServing::Fileset.new("/some/file", :checksum_type => :test)
+ File.expects(:lstat).with(@somefile).returns stub("stat")
+ set = Puppet::FileServing::Fileset.new(@somefile, :checksum_type => :test)
set.checksum_type.should == :test
end
it "should fail if 'links' is set to anything other than :manage or :follow" do
- proc { Puppet::FileServing::Fileset.new("/some/file", :links => :whatever) }.should raise_error(ArgumentError)
+ proc { Puppet::FileServing::Fileset.new(@somefile, :links => :whatever) }.should raise_error(ArgumentError)
end
it "should default to 'false' for recurse" do
- File.expects(:lstat).with("/some/file").returns stub("stat")
- Puppet::FileServing::Fileset.new("/some/file").recurse.should == false
+ File.expects(:lstat).with(@somefile).returns stub("stat")
+ Puppet::FileServing::Fileset.new(@somefile).recurse.should == false
end
it "should default to :infinite for recurselimit" do
- File.expects(:lstat).with("/some/file").returns stub("stat")
- Puppet::FileServing::Fileset.new("/some/file").recurselimit.should == :infinite
+ File.expects(:lstat).with(@somefile).returns stub("stat")
+ Puppet::FileServing::Fileset.new(@somefile).recurselimit.should == :infinite
end
it "should default to an empty ignore list" do
- File.expects(:lstat).with("/some/file").returns stub("stat")
- Puppet::FileServing::Fileset.new("/some/file").ignore.should == []
+ File.expects(:lstat).with(@somefile).returns stub("stat")
+ Puppet::FileServing::Fileset.new(@somefile).ignore.should == []
end
it "should default to :manage for links" do
- File.expects(:lstat).with("/some/file").returns stub("stat")
- Puppet::FileServing::Fileset.new("/some/file").links.should == :manage
+ File.expects(:lstat).with(@somefile).returns stub("stat")
+ Puppet::FileServing::Fileset.new(@somefile).links.should == :manage
end
it "should support using an Indirector Request for its options" do
- File.expects(:lstat).with("/some/file").returns stub("stat")
+ File.expects(:lstat).with(@somefile).returns stub("stat")
request = Puppet::Indirector::Request.new(:file_serving, :find, "foo")
- lambda { Puppet::FileServing::Fileset.new("/some/file", request) }.should_not raise_error
+ lambda { Puppet::FileServing::Fileset.new(@somefile, request) }.should_not raise_error
end
describe "using an indirector request" do
@@ -97,40 +102,43 @@ describe Puppet::FileServing::Fileset, " when initializing" do
File.stubs(:lstat).returns stub("stat")
@values = {:links => :manage, :ignore => %w{a b}, :recurse => true, :recurselimit => 1234}
@request = Puppet::Indirector::Request.new(:file_serving, :find, "foo")
+ @myfile = make_absolute("/my/file")
end
[:recurse, :recurselimit, :ignore, :links].each do |option|
it "should pass :recurse, :recurselimit, :ignore, and :links settings on to the fileset if present" do
@request.stubs(:options).returns(option => @values[option])
- Puppet::FileServing::Fileset.new("/my/file", @request).send(option).should == @values[option]
+ Puppet::FileServing::Fileset.new(@myfile, @request).send(option).should == @values[option]
end
it "should pass :recurse, :recurselimit, :ignore, and :links settings on to the fileset if present with the keys stored as strings" do
@request.stubs(:options).returns(option.to_s => @values[option])
- Puppet::FileServing::Fileset.new("/my/file", @request).send(option).should == @values[option]
+ Puppet::FileServing::Fileset.new(@myfile, @request).send(option).should == @values[option]
end
end
it "should convert the integer as a string to their integer counterpart when setting options" do
@request.stubs(:options).returns(:recurselimit => "1234")
- Puppet::FileServing::Fileset.new("/my/file", @request).recurselimit.should == 1234
+ Puppet::FileServing::Fileset.new(@myfile, @request).recurselimit.should == 1234
end
it "should convert the string 'true' to the boolean true when setting options" do
@request.stubs(:options).returns(:recurse => "true")
- Puppet::FileServing::Fileset.new("/my/file", @request).recurse.should == true
+ Puppet::FileServing::Fileset.new(@myfile, @request).recurse.should == true
end
it "should convert the string 'false' to the boolean false when setting options" do
@request.stubs(:options).returns(:recurse => "false")
- Puppet::FileServing::Fileset.new("/my/file", @request).recurse.should == false
+ Puppet::FileServing::Fileset.new(@myfile, @request).recurse.should == false
end
end
end
describe Puppet::FileServing::Fileset, " when determining whether to recurse" do
+ include PuppetSpec::Files
+
before do
- @path = "/my/path"
+ @path = make_absolute("/my/path")
File.expects(:lstat).with(@path).returns stub("stat")
@fileset = Puppet::FileServing::Fileset.new(@path)
end
@@ -166,8 +174,10 @@ describe Puppet::FileServing::Fileset, " when determining whether to recurse" do
end
describe Puppet::FileServing::Fileset, " when recursing" do
+ include PuppetSpec::Files
+
before do
- @path = "/my/path"
+ @path = make_absolute("/my/path")
File.expects(:lstat).with(@path).returns stub("stat", :directory? => true)
@fileset = Puppet::FileServing::Fileset.new(@path)
@@ -257,7 +267,7 @@ describe Puppet::FileServing::Fileset, " when recursing" do
end
it "should succeed when paths have regexp significant characters" do
- @path = "/my/path/rV1x2DafFr0R6tGG+1bbk++++TM"
+ @path = make_absolute("/my/path/rV1x2DafFr0R6tGG+1bbk++++TM")
File.expects(:lstat).with(@path).returns stub("stat", :directory? => true)
@fileset = Puppet::FileServing::Fileset.new(@path)
mock_dir_structure(@path)
@@ -267,8 +277,10 @@ describe Puppet::FileServing::Fileset, " when recursing" do
end
describe Puppet::FileServing::Fileset, " when following links that point to missing files" do
+ include PuppetSpec::Files
+
before do
- @path = "/my/path"
+ @path = make_absolute("/my/path")
File.expects(:lstat).with(@path).returns stub("stat", :directory? => true)
@fileset = Puppet::FileServing::Fileset.new(@path)
@fileset.links = :follow
@@ -291,8 +303,10 @@ describe Puppet::FileServing::Fileset, " when following links that point to miss
end
describe Puppet::FileServing::Fileset, " when ignoring" do
+ include PuppetSpec::Files
+
before do
- @path = "/my/path"
+ @path = make_absolute("/my/path")
File.expects(:lstat).with(@path).returns stub("stat", :directory? => true)
@fileset = Puppet::FileServing::Fileset.new(@path)
end
@@ -318,8 +332,10 @@ describe Puppet::FileServing::Fileset, " when ignoring" do
end
describe Puppet::FileServing::Fileset, "when merging other filesets" do
+ include PuppetSpec::Files
+
before do
- @paths = %w{/first/path /second/path /third/path}
+ @paths = [make_absolute("/first/path"), make_absolute("/second/path"), make_absolute("/third/path")]
File.stubs(:lstat).returns stub("stat", :directory? => false)
@filesets = @paths.collect do |path|
@@ -331,32 +347,32 @@ describe Puppet::FileServing::Fileset, "when merging other filesets" do
end
it "should return a hash of all files in each fileset with the value being the base path" do
- Dir.expects(:entries).with("/first/path").returns(%w{one uno})
- Dir.expects(:entries).with("/second/path").returns(%w{two dos})
- Dir.expects(:entries).with("/third/path").returns(%w{three tres})
+ Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one uno})
+ Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{two dos})
+ Dir.expects(:entries).with(make_absolute("/third/path")).returns(%w{three tres})
Puppet::FileServing::Fileset.merge(*@filesets).should == {
- "." => "/first/path",
- "one" => "/first/path",
- "uno" => "/first/path",
- "two" => "/second/path",
- "dos" => "/second/path",
- "three" => "/third/path",
- "tres" => "/third/path",
+ "." => make_absolute("/first/path"),
+ "one" => make_absolute("/first/path"),
+ "uno" => make_absolute("/first/path"),
+ "two" => make_absolute("/second/path"),
+ "dos" => make_absolute("/second/path"),
+ "three" => make_absolute("/third/path"),
+ "tres" => make_absolute("/third/path"),
}
end
it "should include the base directory from the first fileset" do
- Dir.expects(:entries).with("/first/path").returns(%w{one})
- Dir.expects(:entries).with("/second/path").returns(%w{two})
+ Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one})
+ Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{two})
- Puppet::FileServing::Fileset.merge(*@filesets)["."].should == "/first/path"
+ Puppet::FileServing::Fileset.merge(*@filesets)["."].should == make_absolute("/first/path")
end
it "should use the base path of the first found file when relative file paths conflict" do
- Dir.expects(:entries).with("/first/path").returns(%w{one})
- Dir.expects(:entries).with("/second/path").returns(%w{one})
+ Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one})
+ Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{one})
- Puppet::FileServing::Fileset.merge(*@filesets)["one"].should == "/first/path"
+ Puppet::FileServing::Fileset.merge(*@filesets)["one"].should == make_absolute("/first/path")
end
end
diff --git a/spec/unit/indirector/certificate_request/ca_spec.rb b/spec/unit/indirector/certificate_request/ca_spec.rb
index ebd64a2fb..fb758b59e 100755
--- a/spec/unit/indirector/certificate_request/ca_spec.rb
+++ b/spec/unit/indirector/certificate_request/ca_spec.rb
@@ -10,7 +10,7 @@ require 'puppet/sslcertificates'
require 'puppet/sslcertificates/ca'
require 'puppet/indirector/certificate_request/ca'
-describe Puppet::SSL::CertificateRequest::Ca do
+describe Puppet::SSL::CertificateRequest::Ca, :fails_on_windows => true do
include PuppetSpec::Files
before :each do
diff --git a/spec/unit/indirector/certificate_status/file_spec.rb b/spec/unit/indirector/certificate_status/file_spec.rb
index ae03aa9cb..897fe0716 100755
--- a/spec/unit/indirector/certificate_status/file_spec.rb
+++ b/spec/unit/indirector/certificate_status/file_spec.rb
@@ -4,7 +4,7 @@ require 'puppet/ssl/host'
require 'puppet/indirector/certificate_status'
require 'tempfile'
-describe "Puppet::Indirector::CertificateStatus::File" do
+describe "Puppet::Indirector::CertificateStatus::File", :fails_on_windows => true do
include PuppetSpec::Files
before do
diff --git a/spec/unit/indirector/file_bucket_file/file_spec.rb b/spec/unit/indirector/file_bucket_file/file_spec.rb
index e0612cb21..ee0b61af1 100755
--- a/spec/unit/indirector/file_bucket_file/file_spec.rb
+++ b/spec/unit/indirector/file_bucket_file/file_spec.rb
@@ -14,7 +14,7 @@ describe Puppet::FileBucketFile::File do
Puppet::FileBucketFile::File.doc.should be_instance_of(String)
end
- describe "non-stubbing tests" do
+ describe "non-stubbing tests", :fails_on_windows => true do
include PuppetSpec::Files
before do
@@ -243,11 +243,11 @@ HERE
describe "when verifying identical files" do
before do
# this is the default from spec_helper, but it keeps getting reset at odd times
- Puppet[:bucketdir] = "/dev/null/bucket"
+ Puppet[:bucketdir] = make_absolute("/dev/null/bucket")
@digest = "4a8ec4fa5f01b4ab1a0ab8cbccb709f0"
@checksum = "{md5}4a8ec4fa5f01b4ab1a0ab8cbccb709f0"
- @dir = '/dev/null/bucket/4/a/8/e/c/4/f/a/4a8ec4fa5f01b4ab1a0ab8cbccb709f0'
+ @dir = make_absolute('/dev/null/bucket/4/a/8/e/c/4/f/a/4a8ec4fa5f01b4ab1a0ab8cbccb709f0')
@contents = "file contents"
diff --git a/spec/unit/indirector/resource/ral_spec.rb b/spec/unit/indirector/resource/ral_spec.rb
index cf746cb0c..e38745f05 100755
--- a/spec/unit/indirector/resource/ral_spec.rb
+++ b/spec/unit/indirector/resource/ral_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
describe "Puppet::Resource::Ral" do
- describe "find" do
+ describe "find", :fails_on_windows => true do
before do
@request = stub 'request', :key => "user/root"
end
diff --git a/spec/unit/indirector/resource_type/parser_spec.rb b/spec/unit/indirector/resource_type/parser_spec.rb
index c4fc455a0..67ea73fd6 100755
--- a/spec/unit/indirector/resource_type/parser_spec.rb
+++ b/spec/unit/indirector/resource_type/parser_spec.rb
@@ -25,7 +25,7 @@ describe Puppet::Indirector::ResourceType::Parser do
@terminus.find(@request).should == type
end
- it "should attempt to load the type if none is found in memory" do
+ it "should attempt to load the type if none is found in memory", :fails_on_windows => true do
dir = tmpdir("find_a_type")
FileUtils.mkdir_p(dir)
Puppet[:modulepath] = dir
@@ -122,13 +122,13 @@ describe Puppet::Indirector::ResourceType::Parser do
@terminus.search(@request).should be_nil
end
- it "should load all resource types from all search paths" do
+ it "should load all resource types from all search paths", :fails_on_windows => true do
dir = tmpdir("searching_in_all")
first = File.join(dir, "first")
second = File.join(dir, "second")
FileUtils.mkdir_p(first)
FileUtils.mkdir_p(second)
- Puppet[:modulepath] = "#{first}:#{second}"
+ Puppet[:modulepath] = "#{first}#{File::PATH_SEPARATOR}#{second}"
# Make a new request, since we've reset the env
@request = Puppet::Indirector::Request.new(:resource_type, :search, "*")
diff --git a/spec/unit/indirector/ssl_file_spec.rb b/spec/unit/indirector/ssl_file_spec.rb
index 5d0859598..1a837f646 100755
--- a/spec/unit/indirector/ssl_file_spec.rb
+++ b/spec/unit/indirector/ssl_file_spec.rb
@@ -8,6 +8,8 @@ require 'spec_helper'
require 'puppet/indirector/ssl_file'
describe Puppet::Indirector::SslFile do
+ include PuppetSpec::Files
+
before :all do
@indirection = stub 'indirection', :name => :testing, :model => @model
Puppet::Indirector::Indirection.expects(:instance).with(:testing).returns(@indirection)
@@ -21,7 +23,7 @@ describe Puppet::Indirector::SslFile do
@setting = :certdir
@file_class.store_in @setting
- @path = "/tmp/my_directory"
+ @path = make_absolute("/tmp/my_directory")
Puppet[:noop] = false
Puppet[@setting] = @path
Puppet[:trace] = false
diff --git a/spec/unit/module_spec.rb b/spec/unit/module_spec.rb
index 8d38657f9..d1d01a1aa 100755
--- a/spec/unit/module_spec.rb
+++ b/spec/unit/module_spec.rb
@@ -275,7 +275,7 @@ describe Puppet::Module do
FileUtils.mkdir_p(first)
FileUtils.mkdir_p(second)
- Puppet[:modulepath] = "#{first}:#{second}"
+ Puppet[:modulepath] = "#{first}#{File::PATH_SEPARATOR}#{second}"
modpath = File.join(first, "foo")
FileUtils.mkdir_p(modpath)
@@ -294,7 +294,7 @@ describe Puppet::Module do
FileUtils.mkdir_p(first)
FileUtils.mkdir_p(second)
- Puppet[:modulepath] = "#{first}:#{second}"
+ Puppet[:modulepath] = "#{first}#{File::PATH_SEPARATOR}#{second}"
modpath = File.join(second, "foo")
FileUtils.mkdir_p(modpath)
diff --git a/spec/unit/network/http_pool_spec.rb b/spec/unit/network/http_pool_spec.rb
index c5d3e0470..32c7a90fe 100755
--- a/spec/unit/network/http_pool_spec.rb
+++ b/spec/unit/network/http_pool_spec.rb
@@ -83,7 +83,7 @@ describe Puppet::Network::HttpPool do
Puppet::Network::HttpPool.http_instance("me", 54321, true)
end
- it "should have a mechanism for clearing the http cache" do
+ it "should have a mechanism for clearing the http cache", :fails_on_windows => true do
stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120
old = Puppet::Network::HttpPool.http_instance("me", 54321)
Puppet::Network::HttpPool.http_instance("me", 54321).should equal(old)
diff --git a/spec/unit/node/environment_spec.rb b/spec/unit/node/environment_spec.rb
index d1badfa3a..144e82e0c 100755
--- a/spec/unit/node/environment_spec.rb
+++ b/spec/unit/node/environment_spec.rb
@@ -144,13 +144,18 @@ describe Puppet::Node::Environment do
end
describe "when validating modulepath or manifestdir directories" do
+ before :each do
+ @path_one = make_absolute('/one')
+ @path_two = make_absolute('/two')
+ end
+
it "should not return non-directories" do
env = Puppet::Node::Environment.new("testing")
- FileTest.expects(:directory?).with("/one").returns true
- FileTest.expects(:directory?).with("/two").returns false
+ FileTest.expects(:directory?).with(@path_one).returns true
+ FileTest.expects(:directory?).with(@path_two).returns false
- env.validate_dirs(%w{/one /two}).should == %w{/one}
+ env.validate_dirs([@path_one, @path_two]).should == [@path_one]
end
it "should use the current working directory to fully-qualify unqualified paths" do
@@ -158,7 +163,7 @@ describe Puppet::Node::Environment do
env = Puppet::Node::Environment.new("testing")
two = File.join(Dir.getwd, "two")
- env.validate_dirs(%w{/one two}).should == ["/one", two]
+ env.validate_dirs([@path_one, 'two']).should == [@path_one, two]
end
end
diff --git a/spec/unit/other/selinux_spec.rb b/spec/unit/other/selinux_spec.rb
index 216feaf1f..f20951868 100755
--- a/spec/unit/other/selinux_spec.rb
+++ b/spec/unit/other/selinux_spec.rb
@@ -5,11 +5,13 @@ require 'puppet/type/selboolean'
require 'puppet/type/selmodule'
describe Puppet::Type.type(:file), " when manipulating file contexts" do
+ include PuppetSpec::Files
+
before :each do
@file = Puppet::Type::File.new(
- :name => "/tmp/foo",
+ :name => make_absolute("/tmp/foo"),
:ensure => "file",
:seluser => "user_u",
:selrole => "role_r",
diff --git a/spec/unit/parser/compiler_spec.rb b/spec/unit/parser/compiler_spec.rb
index e6f481114..411d1b862 100755
--- a/spec/unit/parser/compiler_spec.rb
+++ b/spec/unit/parser/compiler_spec.rb
@@ -43,6 +43,8 @@ class CompilerTestResource
end
describe Puppet::Parser::Compiler do
+ include PuppetSpec::Files
+
def resource(type, title)
Puppet::Parser::Resource.new(type, title, :scope => @scope)
end
@@ -413,7 +415,7 @@ describe Puppet::Parser::Compiler do
end
it "should fail to add resources that conflict with existing resources" do
- path = Puppet.features.posix? ? "/foo" : "C:/foo"
+ path = make_absolute("/foo")
file1 = Puppet::Type.type(:file).new :path => path
file2 = Puppet::Type.type(:file).new :path => path
diff --git a/spec/unit/parser/files_spec.rb b/spec/unit/parser/files_spec.rb
index 04777f0ec..1bf75e623 100755
--- a/spec/unit/parser/files_spec.rb
+++ b/spec/unit/parser/files_spec.rb
@@ -4,9 +4,10 @@ require 'spec_helper'
require 'puppet/parser/files'
describe Puppet::Parser::Files do
+ include PuppetSpec::Files
before do
- @basepath = Puppet.features.posix? ? "/somepath" : "C:/somepath"
+ @basepath = make_absolute("/somepath")
end
it "should have a method for finding a template" do
@@ -77,8 +78,9 @@ describe Puppet::Parser::Files do
it "should accept relative templatedirs" do
FileTest.stubs(:exist?).returns true
Puppet[:templatedir] = "my/templates"
- File.expects(:directory?).with(File.join(Dir.getwd,"my/templates")).returns(true)
- Puppet::Parser::Files.find_template("mytemplate").should == File.join(Dir.getwd,"my/templates/mytemplate")
+ # We expand_path to normalize backslashes and slashes on Windows
+ File.expects(:directory?).with(File.expand_path(File.join(Dir.getwd,"my/templates"))).returns(true)
+ Puppet::Parser::Files.find_template("mytemplate").should == File.expand_path(File.join(Dir.getwd,"my/templates/mytemplate"))
end
it "should use the environment templatedir if no module is found and an environment is specified" do
@@ -158,7 +160,8 @@ describe Puppet::Parser::Files do
end
it "should look for files relative to the current directory" do
- cwd = Dir.getwd
+ # We expand_path to normalize backslashes and slashes on Windows
+ cwd = File.expand_path(Dir.getwd)
Dir.expects(:glob).with("#{cwd}/foobar/init.pp").returns(["#{cwd}/foobar/init.pp"])
Puppet::Parser::Files.find_manifests("foobar/init.pp")[1].should == ["#{cwd}/foobar/init.pp"]
end
diff --git a/spec/unit/parser/functions/extlookup_spec.rb b/spec/unit/parser/functions/extlookup_spec.rb
index 30962e137..59ecf39c0 100755
--- a/spec/unit/parser/functions/extlookup_spec.rb
+++ b/spec/unit/parser/functions/extlookup_spec.rb
@@ -3,6 +3,8 @@ require 'spec_helper'
require 'tempfile'
describe "the extlookup function" do
+ include PuppetSpec::Files
+
before :all do
Puppet::Parser::Functions.autoloader.loadall
end
@@ -64,9 +66,10 @@ describe "the extlookup function" do
describe "should look in $extlookup_datadir for data files listed by $extlookup_precedence" do
before do
- @scope.stubs(:[]).with('::extlookup_datadir').returns("/tmp")
- File.open("/tmp/one.csv","w"){|one| one.puts "key,value1" }
- File.open("/tmp/two.csv","w") do |two|
+ dir = tmpdir('extlookup_datadir')
+ @scope.stubs(:[]).with('::extlookup_datadir').returns(dir)
+ File.open(File.join(dir, "one.csv"),"w"){|one| one.puts "key,value1" }
+ File.open(File.join(dir, "two.csv"),"w") do |two|
two.puts "key,value2"
two.puts "key2,value_two"
end
diff --git a/spec/unit/parser/functions/sprintf_spec.rb b/spec/unit/parser/functions/sprintf_spec.rb
index bd4863f23..3351c7fb3 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/parser/type_loader_spec.rb b/spec/unit/parser/type_loader_spec.rb
index 9367b61c8..fd991ffc4 100755
--- a/spec/unit/parser/type_loader_spec.rb
+++ b/spec/unit/parser/type_loader_spec.rb
@@ -56,8 +56,8 @@ describe Puppet::Parser::TypeLoader do
end
it "should use the directory of the current file if one is set" do
- Puppet::Parser::Files.expects(:find_manifests).with { |pat, opts| opts[:cwd] == "/current" }.returns ["modname", %w{one}]
- @loader.import("myfile", "/current/file")
+ Puppet::Parser::Files.expects(:find_manifests).with { |pat, opts| opts[:cwd] == make_absolute("/current") }.returns ["modname", %w{one}]
+ @loader.import("myfile", make_absolute("/current/file"))
end
it "should pass the environment when looking for files" do
@@ -71,15 +71,15 @@ describe Puppet::Parser::TypeLoader do
end
it "should parse each found file" do
- Puppet::Parser::Files.expects(:find_manifests).returns ["modname", %w{/one}]
- @loader.expects(:parse_file).with("/one").returns(Puppet::Parser::AST::Hostclass.new(''))
+ Puppet::Parser::Files.expects(:find_manifests).returns ["modname", make_absolute("/one")]
+ @loader.expects(:parse_file).with(make_absolute("/one")).returns(Puppet::Parser::AST::Hostclass.new(''))
@loader.import("myfile")
end
it "should make each file qualified before attempting to parse it" do
Puppet::Parser::Files.expects(:find_manifests).returns ["modname", %w{one}]
- @loader.expects(:parse_file).with("/current/one").returns(Puppet::Parser::AST::Hostclass.new(''))
- @loader.import("myfile", "/current/file")
+ @loader.expects(:parse_file).with(make_absolute("/current/one")).returns(Puppet::Parser::AST::Hostclass.new(''))
+ @loader.import("myfile", make_absolute("/current/file"))
end
it "should not attempt to import files that have already been imported" do
@@ -102,7 +102,7 @@ describe Puppet::Parser::TypeLoader do
@modulebase2 = File.join(@base, "second")
FileUtils.mkdir_p(@modulebase2)
- Puppet[:modulepath] = "#{@modulebase1}:#{@modulebase2}"
+ Puppet[:modulepath] = "#{@modulebase1}#{File::PATH_SEPARATOR}#{@modulebase2}"
end
def mk_module(basedir, name)
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index 7728b5d40..99d4bc7c5 100755
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -109,7 +109,7 @@ describe Puppet::Property do
end
end
- describe "when creating an event" do
+ describe "when creating an event", :fails_on_windows => true do
before do
@event = Puppet::Transaction::Event.new
diff --git a/spec/unit/provider/exec/shell_spec.rb b/spec/unit/provider/exec/shell_spec.rb
index 90047b9d6..4e1f00281 100755
--- a/spec/unit/provider/exec/shell_spec.rb
+++ b/spec/unit/provider/exec/shell_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
provider_class = Puppet::Type.type(:exec).provider(:shell)
-describe provider_class do
+describe provider_class, :fails_on_windows => true do
before :each do
@resource = Puppet::Resource.new(:exec, 'foo')
@provider = provider_class.new(@resource)
diff --git a/spec/unit/provider/host/parsed_spec.rb b/spec/unit/provider/host/parsed_spec.rb
index 9cb5890cc..fa41d82e5 100755
--- a/spec/unit/provider/host/parsed_spec.rb
+++ b/spec/unit/provider/host/parsed_spec.rb
@@ -6,7 +6,7 @@ require 'puppet_spec/files'
provider_class = Puppet::Type.type(:host).provider(:parsed)
-describe provider_class do
+describe provider_class, :fails_on_windows => true do
include PuppetSpec::Files
before do
diff --git a/spec/unit/provider/macauthorization_spec.rb b/spec/unit/provider/macauthorization_spec.rb
index a76f917f7..dbe36a04b 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/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb
index 7831dae3a..fdee2efab 100755
--- a/spec/unit/provider/mount/parsed_spec.rb
+++ b/spec/unit/provider/mount/parsed_spec.rb
@@ -8,7 +8,7 @@ require 'shared_behaviours/all_parsedfile_providers'
provider_class = Puppet::Type.type(:mount).provider(:parsed)
-describe provider_class do
+describe provider_class, :fails_on_windows => true do
before :each do
@mount_class = Puppet::Type.type(:mount)
diff --git a/spec/unit/provider/service/smf_spec.rb b/spec/unit/provider/service/smf_spec.rb
index 5212d540a..fd7d50e3a 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/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
index bd5e55a9e..8a7fe755c 100755
--- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
+++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
@@ -128,7 +128,7 @@ describe provider_class do
end
end
- describe "and a user has been specified with no target" do
+ describe "and a user has been specified with no target", :fails_on_windows => true do
before :each do
@resource[:user] = "nobody"
#
@@ -189,7 +189,7 @@ describe provider_class do
end
end
- describe "and a invalid user has been specified with no target" do
+ describe "and a invalid user has been specified with no target", :fails_on_windows => true do
it "should catch an exception and raise a Puppet error" do
@resource[:user] = "thisusershouldnotexist"
diff --git a/spec/unit/provider/user/user_role_add_spec.rb b/spec/unit/provider/user/user_role_add_spec.rb
index 5f2fc306e..c44fc5a65 100755
--- a/spec/unit/provider/user/user_role_add_spec.rb
+++ b/spec/unit/provider/user/user_role_add_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
provider_class = Puppet::Type.type(:user).provider(:user_role_add)
-describe provider_class do
+describe provider_class, :fails_on_windows => true do
before do
@resource = stub("resource", :name => "myuser", :managehome? => nil)
@resource.stubs(:should).returns "fakeval"
diff --git a/spec/unit/provider/user/useradd_spec.rb b/spec/unit/provider/user/useradd_spec.rb
index 724fc12c0..4265ee3a0 100755
--- a/spec/unit/provider/user/useradd_spec.rb
+++ b/spec/unit/provider/user/useradd_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
provider_class = Puppet::Type.type(:user).provider(:useradd)
-describe provider_class do
+describe provider_class, :fails_on_windows => true do
before do
@resource = stub("resource", :name => "myuser", :managehome? => nil)
@resource.stubs(:should).returns "fakeval"
diff --git a/spec/unit/resource/catalog_spec.rb b/spec/unit/resource/catalog_spec.rb
index 8f4910af6..5b914dac3 100755
--- a/spec/unit/resource/catalog_spec.rb
+++ b/spec/unit/resource/catalog_spec.rb
@@ -2,9 +2,10 @@
require 'spec_helper'
describe Puppet::Resource::Catalog, "when compiling" do
+ include PuppetSpec::Files
before do
- @basepath = Puppet.features.posix? ? "/somepath" : "C:/somepath"
+ @basepath = make_absolute("/somepath")
# stub this to not try to create state.yaml
Puppet::Util::Storage.stubs(:store)
end
@@ -508,7 +509,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
@catalog.resource(:file, @basepath+"/something").should equal(resource)
end
- it "should not create aliases for resources non-isomorphic resources whose names do not match their titles" do
+ it "should not create aliases for resources non-isomorphic resources whose names do not match their titles", :fails_on_windows => true do
resource = Puppet::Type.type(:exec).new(:title => "testing", :command => "echo", :path => %w{/bin /usr/bin /usr/local/bin})
@catalog.add_resource(resource)
diff --git a/spec/unit/resource/status_spec.rb b/spec/unit/resource/status_spec.rb
index e5a9291db..18e3359df 100755
--- a/spec/unit/resource/status_spec.rb
+++ b/spec/unit/resource/status_spec.rb
@@ -4,14 +4,16 @@ require 'spec_helper'
require 'puppet/resource/status'
describe Puppet::Resource::Status do
+ include PuppetSpec::Files
+
before do
- @resource = Puppet::Type.type(:file).new :path => "/my/file"
+ @resource = Puppet::Type.type(:file).new :path => make_absolute("/my/file")
@status = Puppet::Resource::Status.new(@resource)
end
it "should compute type and title correctly" do
@status.resource_type.should == "File"
- @status.title.should == "/my/file"
+ @status.title.should == make_absolute("/my/file")
end
[:node, :file, :line, :current_values, :status, :evaluation_time].each do |attr|
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 0485bc7aa..093532119 100755
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -3,9 +3,10 @@ require 'spec_helper'
require 'puppet/resource'
describe Puppet::Resource do
+ include PuppetSpec::Files
before do
- @basepath = Puppet.features.posix? ? "/somepath" : "C:/somepath"
+ @basepath = make_absolute("/somepath")
end
[:catalog, :file, :line].each do |attr|
diff --git a/spec/unit/ssl/host_spec.rb b/spec/unit/ssl/host_spec.rb
index c2d9690e6..e1680941f 100755
--- a/spec/unit/ssl/host_spec.rb
+++ b/spec/unit/ssl/host_spec.rb
@@ -5,7 +5,7 @@ require 'puppet/ssl/host'
require 'puppet/sslcertificates'
require 'puppet/sslcertificates/ca'
-describe Puppet::SSL::Host do
+describe Puppet::SSL::Host, :fails_on_windows => true do
before do
Puppet::SSL::Host.indirection.terminus_class = :file
@host = Puppet::SSL::Host.new("myname")
diff --git a/spec/unit/ssl/inventory_spec.rb b/spec/unit/ssl/inventory_spec.rb
index d8606b1b4..3d141d0cd 100755
--- a/spec/unit/ssl/inventory_spec.rb
+++ b/spec/unit/ssl/inventory_spec.rb
@@ -118,7 +118,7 @@ describe Puppet::SSL::Inventory do
end
end
- describe "and formatting a certificate" do
+ describe "and formatting a certificate", :fails_on_windows => true do
before do
@cert = stub 'cert', :not_before => Time.now, :not_after => Time.now, :subject => "mycert", :serial => 15
end
diff --git a/spec/unit/sslcertificates/ca_spec.rb b/spec/unit/sslcertificates/ca_spec.rb
index eea246ba1..2ff4036dd 100755
--- a/spec/unit/sslcertificates/ca_spec.rb
+++ b/spec/unit/sslcertificates/ca_spec.rb
@@ -5,7 +5,7 @@ require 'puppet'
require 'puppet/sslcertificates'
require 'puppet/sslcertificates/ca'
-describe Puppet::SSLCertificates::CA do
+describe Puppet::SSLCertificates::CA, :fails_on_windows => true do
before :all do
@hosts = %w{host.domain.com Other.Testing.Com}
end
diff --git a/spec/unit/transaction/event_manager_spec.rb b/spec/unit/transaction/event_manager_spec.rb
index d127d0391..37775997d 100755
--- a/spec/unit/transaction/event_manager_spec.rb
+++ b/spec/unit/transaction/event_manager_spec.rb
@@ -4,6 +4,8 @@ require 'spec_helper'
require 'puppet/transaction/event_manager'
describe Puppet::Transaction::EventManager do
+ include PuppetSpec::Files
+
describe "at initialization" do
it "should require a transaction" do
Puppet::Transaction::EventManager.new("trans").transaction.should == "trans"
@@ -23,7 +25,7 @@ describe Puppet::Transaction::EventManager do
before do
@manager = Puppet::Transaction::EventManager.new(@transaction)
- @resource = Puppet::Type.type(:file).new :path => "/my/file"
+ @resource = Puppet::Type.type(:file).new :path => make_absolute("/my/file")
@graph = stub 'graph', :matching_edges => [], :resource => @resource
@manager.stubs(:relationship_graph).returns @graph
@@ -139,7 +141,7 @@ describe Puppet::Transaction::EventManager do
@manager = Puppet::Transaction::EventManager.new(@transaction)
@manager.stubs(:queue_events)
- @resource = Puppet::Type.type(:file).new :path => "/my/file"
+ @resource = Puppet::Type.type(:file).new :path => make_absolute("/my/file")
@event = Puppet::Transaction::Event.new(:name => :event, :resource => @resource)
end
diff --git a/spec/unit/transaction/event_spec.rb b/spec/unit/transaction/event_spec.rb
index 0093baeb9..5f7f367b4 100755
--- a/spec/unit/transaction/event_spec.rb
+++ b/spec/unit/transaction/event_spec.rb
@@ -4,6 +4,8 @@ require 'spec_helper'
require 'puppet/transaction/event'
describe Puppet::Transaction::Event do
+ include PuppetSpec::Files
+
[:previous_value, :desired_value, :property, :resource, :name, :message, :file, :line, :tags, :audited].each do |attr|
it "should support #{attr}", :'fails_on_ruby_1.9.2' => true do
event = Puppet::Transaction::Event.new
@@ -113,7 +115,7 @@ describe Puppet::Transaction::Event do
describe "When converting to YAML" do
it "should include only documented attributes" do
- resource = Puppet::Type.type(:file).new(:title => "/tmp/foo")
+ resource = Puppet::Type.type(:file).new(:title => make_absolute("/tmp/foo"))
event = Puppet::Transaction::Event.new(:source_description => "/my/param", :resource => resource,
:file => "/foo.rb", :line => 27, :tags => %w{one two},
:desired_value => 7, :historical_value => 'Brazil',
diff --git a/spec/unit/transaction/report_spec.rb b/spec/unit/transaction/report_spec.rb
index 4b04cc157..033c4c740 100755
--- a/spec/unit/transaction/report_spec.rb
+++ b/spec/unit/transaction/report_spec.rb
@@ -154,7 +154,7 @@ describe Puppet::Transaction::Report do
def add_statuses(count, type = :file)
count.times do |i|
- status = Puppet::Resource::Status.new(Puppet::Type.type(type).new(:title => "/my/path#{i}"))
+ status = Puppet::Resource::Status.new(Puppet::Type.type(type).new(:title => make_absolute("/my/path#{i}")))
yield status if block_given?
@report.add_resource_status status
end
@@ -208,7 +208,7 @@ describe Puppet::Transaction::Report do
end
describe "for times" do
- it "should provide the total amount of time for each resource type" do
+ it "should provide the total amount of time for each resource type", :fails_on_windows => true do
add_statuses(3, :file) do |status|
status.evaluation_time = 1
end
diff --git a/spec/unit/transaction/resource_harness_spec.rb b/spec/unit/transaction/resource_harness_spec.rb
index a594d3669..cadc31a0f 100755
--- a/spec/unit/transaction/resource_harness_spec.rb
+++ b/spec/unit/transaction/resource_harness_spec.rb
@@ -9,7 +9,7 @@ describe Puppet::Transaction::ResourceHarness do
before do
@mode_750 = Puppet.features.microsoft_windows? ? '644' : '750'
@mode_755 = Puppet.features.microsoft_windows? ? '644' : '755'
- path = Puppet.features.microsoft_windows? ? "c:/my/file" : "/my/file"
+ path = make_absolute("/my/file")
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new)
@resource = Puppet::Type.type(:file).new :path => path
diff --git a/spec/unit/transaction_spec.rb b/spec/unit/transaction_spec.rb
index 3829cfaf5..3f34f65bd 100755
--- a/spec/unit/transaction_spec.rb
+++ b/spec/unit/transaction_spec.rb
@@ -11,8 +11,10 @@ def without_warnings
end
describe Puppet::Transaction do
+ include PuppetSpec::Files
+
before do
- @basepath = Puppet.features.posix? ? "/what/ever" : "C:/tmp"
+ @basepath = make_absolute("/what/ever")
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new)
end
diff --git a/spec/unit/type/exec_spec.rb b/spec/unit/type/exec_spec.rb
index 47d1b8523..2861bb0e3 100755
--- a/spec/unit/type/exec_spec.rb
+++ b/spec/unit/type/exec_spec.rb
@@ -2,6 +2,8 @@
require 'spec_helper'
describe Puppet::Type.type(:exec) do
+ include PuppetSpec::Files
+
def exec_tester(command, exitstatus = 0, rest = {})
@user_name = 'some_user_name'
@group_name = 'some_group_name'
@@ -30,12 +32,13 @@ describe Puppet::Type.type(:exec) do
end
before do
- @command = Puppet.features.posix? ? '/bin/true whatever' : '"C:/Program Files/something.exe" whatever'
+ @command = make_absolute('/bin/true whatever')
+ @executable = make_absolute('/bin/true')
+ @bogus_cmd = make_absolute('/bogus/cmd')
end
- describe "when not stubbing the provider" do
+ describe "when not stubbing the provider", :fails_on_windows => true do
before do
- @executable = Puppet.features.posix? ? '/bin/true' : 'C:/Program Files/something.exe'
File.stubs(:exists?).returns false
File.stubs(:exists?).with(@executable).returns true
File.stubs(:exists?).with('/bin/false').returns true
@@ -139,17 +142,18 @@ describe Puppet::Type.type(:exec) do
end
end
- it "should be able to autorequire files mentioned in the command" do
+ it "should be able to autorequire files mentioned in the command", :fails_on_windows => true do
+ foo = make_absolute('/bin/foo')
catalog = Puppet::Resource::Catalog.new
- tmp = Puppet::Type.type(:file).new(:name => "/bin/foo")
+ tmp = Puppet::Type.type(:file).new(:name => foo)
catalog.add_resource tmp
- execer = Puppet::Type.type(:exec).new(:name => "/bin/foo")
+ execer = Puppet::Type.type(:exec).new(:name => foo)
catalog.add_resource execer
catalog.relationship_graph.dependencies(execer).should == [tmp]
end
- describe "when handling the path parameter" do
+ describe "when handling the path parameter", :fails_on_windows => true do
expect = %w{one two three four}
{ "an array" => expect,
"a colon separated list" => "one:two:three:four",
@@ -165,7 +169,7 @@ describe Puppet::Type.type(:exec) do
end
end
- describe "when setting user" do
+ describe "when setting user", :fails_on_windows => true do
it "should fail if we are not root" do
Puppet.features.stubs(:root?).returns(false)
expect { Puppet::Type.type(:exec).new(:name => @command, :user => 'input') }.
@@ -184,7 +188,7 @@ describe Puppet::Type.type(:exec) do
describe "when setting group" do
shared_examples_for "exec[:group]" do
['one', 2, 'wheel', 4294967295, 4294967296].each do |value|
- it "should accept '#{value}' without error or judgement" do
+ it "should accept '#{value}' without error or judgement", :fails_on_windows => true do
type = Puppet::Type.type(:exec).new(:name => @command, :group => value)
type[:group].should == value
end
@@ -205,7 +209,7 @@ describe Puppet::Type.type(:exec) do
describe "when setting cwd" do
it_should_behave_like "all path parameters", :cwd, :array => false do
def instance(path)
- Puppet::Type.type(:exec).new(:name => '/bin/true', :cwd => path)
+ Puppet::Type.type(:exec).new(:name => @executable, :cwd => path)
end
end
end
@@ -221,7 +225,7 @@ describe Puppet::Type.type(:exec) do
if @param == :name then
instance = Puppet::Type.type(:exec).new()
else
- instance = Puppet::Type.type(:exec).new(:name => "/bin/true")
+ instance = Puppet::Type.type(:exec).new(:name => @executable)
end
if valid then
instance.provider.expects(:validatecmd).returns(true)
@@ -246,7 +250,7 @@ describe Puppet::Type.type(:exec) do
shared_examples_for "all exec command parameters that take arrays" do |param|
describe "when given an array of inputs" do
before :each do
- @test = Puppet::Type.type(:exec).new(:name => "/bin/true")
+ @test = Puppet::Type.type(:exec).new(:name => @executable)
end
it "should accept the array when all commands return valid" do
@@ -281,7 +285,7 @@ describe Puppet::Type.type(:exec) do
describe "for simple parameters" do
before :each do
- @exec = Puppet::Type.type(:exec).new(:name => '/bin/true')
+ @exec = Puppet::Type.type(:exec).new(:name => @executable)
end
describe "when setting environment" do
@@ -338,13 +342,15 @@ describe Puppet::Type.type(:exec) do
end
it "should convert timeout to a float" do
- resource = Puppet::Type.type(:exec).new :command => "/bin/false", :timeout => "12"
+ command = make_absolute('/bin/false')
+ resource = Puppet::Type.type(:exec).new :command => command, :timeout => "12"
resource[:timeout].should be_a(Float)
resource[:timeout].should == 12.0
end
it "should munge negative timeouts to 0.0" do
- resource = Puppet::Type.type(:exec).new :command => "/bin/false", :timeout => "-12.0"
+ command = make_absolute('/bin/false')
+ resource = Puppet::Type.type(:exec).new :command => command, :timeout => "-12.0"
resource.parameter(:timeout).value.should be_a(Float)
resource.parameter(:timeout).value.should == 0.0
end
@@ -442,7 +448,7 @@ describe Puppet::Type.type(:exec) do
describe "when setting creates" do
it_should_behave_like "all path parameters", :creates, :array => true do
def instance(path)
- Puppet::Type.type(:exec).new(:name => '/bin/true', :creates => path)
+ Puppet::Type.type(:exec).new(:name => @executable, :creates => path)
end
end
end
@@ -460,7 +466,7 @@ describe Puppet::Type.type(:exec) do
describe "#check" do
before :each do
- @test = Puppet::Type.type(:exec).new(:name => "/bin/true")
+ @test = Puppet::Type.type(:exec).new(:name => @executable)
end
describe ":refreshonly" do
@@ -525,8 +531,8 @@ describe Puppet::Type.type(:exec) do
}.each do |param, sense|
describe ":#{param}" do
before :each do
- @pass = "/magic/pass"
- @fail = "/magic/fail"
+ @pass = make_absolute("/magic/pass")
+ @fail = make_absolute("/magic/fail")
@pass_status = stub('status', :exitstatus => sense[:pass] ? 0 : 1)
@fail_status = stub('status', :exitstatus => sense[:fail] ? 0 : 1)
@@ -584,9 +590,9 @@ describe Puppet::Type.type(:exec) do
end
end
- describe "#retrieve" do
+ describe "#retrieve", :fails_on_windows => true do
before :each do
- @exec_resource = Puppet::Type.type(:exec).new(:name => "/bogus/cmd")
+ @exec_resource = Puppet::Type.type(:exec).new(:name => @bogus_cmd)
end
it "should return :notrun when check_all_attributes returns true" do
@@ -608,7 +614,7 @@ describe Puppet::Type.type(:exec) do
describe "#output" do
before :each do
- @exec_resource = Puppet::Type.type(:exec).new(:name => "/bogus/cmd")
+ @exec_resource = Puppet::Type.type(:exec).new(:name => @bogus_cmd)
end
it "should return the provider's run output" do
@@ -625,14 +631,15 @@ describe Puppet::Type.type(:exec) do
describe "#refresh" do
before :each do
- @exec_resource = Puppet::Type.type(:exec).new(:name => "/bogus/cmd")
+ @exec_resource = Puppet::Type.type(:exec).new(:name => @bogus_cmd)
end
it "should call provider run with the refresh parameter if it is set" do
+ myother_bogus_cmd = make_absolute('/myother/bogus/cmd')
provider = stub 'provider'
@exec_resource.stubs(:provider).returns(provider)
- @exec_resource.stubs(:[]).with(:refresh).returns('/myother/bogus/cmd')
- provider.expects(:run).with('/myother/bogus/cmd')
+ @exec_resource.stubs(:[]).with(:refresh).returns(myother_bogus_cmd)
+ provider.expects(:run).with(myother_bogus_cmd)
@exec_resource.refresh
end
@@ -641,7 +648,7 @@ describe Puppet::Type.type(:exec) do
provider = stub 'provider'
status = stubs "process_status"
status.stubs(:exitstatus).returns("0")
- provider.expects(:run).with('/bogus/cmd').returns(["silly output", status])
+ provider.expects(:run).with(@bogus_cmd).returns(["silly output", status])
@exec_resource.stubs(:provider).returns(provider)
@exec_resource.refresh
diff --git a/spec/unit/type/file/checksum_spec.rb b/spec/unit/type/file/checksum_spec.rb
index b47f617cc..30c4aba6d 100755
--- a/spec/unit/type/file/checksum_spec.rb
+++ b/spec/unit/type/file/checksum_spec.rb
@@ -4,7 +4,8 @@ require 'spec_helper'
checksum = Puppet::Type.type(:file).attrclass(:checksum)
describe checksum do
before do
- @resource = Puppet::Type.type(:file).new :path => "/foo/bar"
+ @path = Puppet.features.microsoft_windows? ? "c:/foo/bar" : "/foo/bar"
+ @resource = Puppet::Type.type(:file).new :path => @path
@checksum = @resource.parameter(:checksum)
end
@@ -35,25 +36,25 @@ describe checksum do
it "should use its current value when asked to sum a file's content" do
@checksum.value = :md5lite
- @checksum.expects(:md5lite_file).with("/foo/bar").returns "yay"
- @checksum.sum_file("/foo/bar")
+ @checksum.expects(:md5lite_file).with(@path).returns "yay"
+ @checksum.sum_file(@path)
end
it "should use :md5 to sum a file when no value is set" do
- @checksum.expects(:md5_file).with("/foo/bar").returns "yay"
- @checksum.sum_file("/foo/bar")
+ @checksum.expects(:md5_file).with(@path).returns "yay"
+ @checksum.sum_file(@path)
end
it "should convert all sums to strings when summing files" do
@checksum.value = :mtime
- @checksum.expects(:mtime_file).with("/foo/bar").returns Time.now
- lambda { @checksum.sum_file("/foo/bar") }.should_not raise_error
+ @checksum.expects(:mtime_file).with(@path).returns Time.now
+ lambda { @checksum.sum_file(@path) }.should_not raise_error
end
it "should return the summed contents of a file with a checksum label" do
@resource[:checksum] = :md5
@checksum.expects(:md5_file).returns "mysum"
- @checksum.sum_file("/foo/bar").should == "{md5}mysum"
+ @checksum.sum_file(@path).should == "{md5}mysum"
end
it "should return the summed contents of a stream with a checksum label" do
diff --git a/spec/unit/type/file/content_spec.rb b/spec/unit/type/file/content_spec.rb
index 7af5f9d83..04ec48555 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
@@ -298,7 +299,7 @@ describe content do
end
end
- describe "from local source" do
+ describe "from local source", :fails_on_windows => true do
before(:each) do
@resource = Puppet::Type.type(:file).new :path => @filename, :backup => false
@sourcename = tmpfile('source')
diff --git a/spec/unit/type/file/selinux_spec.rb b/spec/unit/type/file/selinux_spec.rb
index 2622948d0..f6e7451c7 100755
--- a/spec/unit/type/file/selinux_spec.rb
+++ b/spec/unit/type/file/selinux_spec.rb
@@ -1,12 +1,14 @@
#!/usr/bin/env rspec
require 'spec_helper'
-
[:seluser, :selrole, :seltype, :selrange].each do |param|
property = Puppet::Type.type(:file).attrclass(param)
describe property do
+ include PuppetSpec::Files
+
before do
- @resource = Puppet::Type.type(:file).new :path => "/my/file"
+ @path = make_absolute("/my/file")
+ @resource = Puppet::Type.type(:file).new :path => @path
@sel = property.new :resource => @resource
end
@@ -18,14 +20,14 @@ require 'spec_helper'
it "should retrieve nil for #{param} if there is no SELinux support" do
stat = stub 'stat', :ftype => "foo"
@resource.expects(:stat).returns stat
- @sel.expects(:get_selinux_current_context).with("/my/file").returns nil
+ @sel.expects(:get_selinux_current_context).with(@path).returns nil
@sel.retrieve.should be_nil
end
it "should retrieve #{param} if a SELinux context is found with a range" do
stat = stub 'stat', :ftype => "foo"
@resource.expects(:stat).returns stat
- @sel.expects(:get_selinux_current_context).with("/my/file").returns "user_u:role_r:type_t:s0"
+ @sel.expects(:get_selinux_current_context).with(@path).returns "user_u:role_r:type_t:s0"
expectedresult = case param
when :seluser; "user_u"
when :selrole; "role_r"
@@ -38,7 +40,7 @@ require 'spec_helper'
it "should retrieve #{param} if a SELinux context is found without a range" do
stat = stub 'stat', :ftype => "foo"
@resource.expects(:stat).returns stat
- @sel.expects(:get_selinux_current_context).with("/my/file").returns "user_u:role_r:type_t"
+ @sel.expects(:get_selinux_current_context).with(@path).returns "user_u:role_r:type_t"
expectedresult = case param
when :seluser; "user_u"
when :selrole; "role_r"
@@ -49,13 +51,13 @@ require 'spec_helper'
end
it "should handle no default gracefully" do
- @sel.expects(:get_selinux_default_context).with("/my/file").returns nil
+ @sel.expects(:get_selinux_default_context).with(@path).returns nil
@sel.default.must be_nil
end
it "should be able to detect matchpathcon defaults" do
@sel.stubs(:debug)
- @sel.expects(:get_selinux_default_context).with("/my/file").returns "user_u:role_r:type_t:s0"
+ @sel.expects(:get_selinux_default_context).with(@path).returns "user_u:role_r:type_t:s0"
expectedresult = case param
when :seluser; "user_u"
when :selrole; "role_r"
@@ -73,7 +75,7 @@ require 'spec_helper'
it "should be able to set a new context" do
stat = stub 'stat', :ftype => "foo"
@sel.should = %w{newone}
- @sel.expects(:set_selinux_context).with("/my/file", ["newone"], param)
+ @sel.expects(:set_selinux_context).with(@path, ["newone"], param)
@sel.sync
end
diff --git a/spec/unit/type/file/source_spec.rb b/spec/unit/type/file/source_spec.rb
index 5665d323d..5129d1e01 100755
--- a/spec/unit/type/file/source_spec.rb
+++ b/spec/unit/type/file/source_spec.rb
@@ -3,9 +3,13 @@ require 'spec_helper'
source = Puppet::Type.type(:file).attrclass(:source)
describe Puppet::Type.type(:file).attrclass(:source) do
+ include PuppetSpec::Files
+
before do
# Wow that's a messy interface to the resource.
@resource = stub 'resource', :[]= => nil, :property => nil, :catalog => stub("catalog", :dependent_data_expired? => false), :line => 0, :file => ''
+ @foobar = make_absolute("/foo/bar")
+ @feebooz = make_absolute("/fee/booz")
end
it "should be a subclass of Parameter" do
@@ -35,7 +39,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
source.new(:resource => @resource).must respond_to(:metadata=)
end
- describe "when returning the metadata" do
+ describe "when returning the metadata", :fails_on_windows => true do
before do
@metadata = stub 'metadata', :source= => nil
end
@@ -52,39 +56,39 @@ describe Puppet::Type.type(:file).attrclass(:source) do
end
it "should collect its metadata using the Metadata class if it is not already set" do
- @source = source.new(:resource => @resource, :value => "/foo/bar")
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/foo/bar").returns @metadata
+ @source = source.new(:resource => @resource, :value => @foobar)
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar).returns @metadata
@source.metadata
end
it "should use the metadata from the first found source" do
metadata = stub 'metadata', :source= => nil
- @source = source.new(:resource => @resource, :value => ["/foo/bar", "/fee/booz"])
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/foo/bar").returns nil
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/fee/booz").returns metadata
+ @source = source.new(:resource => @resource, :value => [@foobar, @feebooz])
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar).returns nil
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@feebooz).returns metadata
@source.metadata.should equal(metadata)
end
it "should store the found source as the metadata's source" do
metadata = mock 'metadata'
- @source = source.new(:resource => @resource, :value => "/foo/bar")
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/foo/bar").returns metadata
+ @source = source.new(:resource => @resource, :value => @foobar)
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar).returns metadata
- metadata.expects(:source=).with("/foo/bar")
+ metadata.expects(:source=).with(@foobar)
@source.metadata
end
it "should fail intelligently if an exception is encountered while querying for metadata" do
- @source = source.new(:resource => @resource, :value => "/foo/bar")
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/foo/bar").raises RuntimeError
+ @source = source.new(:resource => @resource, :value => @foobar)
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar).raises RuntimeError
@source.expects(:fail).raises ArgumentError
lambda { @source.metadata }.should raise_error(ArgumentError)
end
it "should fail if no specified sources can be found" do
- @source = source.new(:resource => @resource, :value => "/foo/bar")
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/foo/bar").returns nil
+ @source = source.new(:resource => @resource, :value => @foobar)
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar).returns nil
@source.expects(:fail).raises RuntimeError
@@ -95,9 +99,9 @@ describe Puppet::Type.type(:file).attrclass(:source) do
expirer = stub 'expired', :dependent_data_expired? => true
metadata = stub 'metadata', :source= => nil
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/fee/booz").returns metadata
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@feebooz).returns metadata
- @source = source.new(:resource => @resource, :value => ["/fee/booz"])
+ @source = source.new(:resource => @resource, :value => [@feebooz])
@source.metadata = "foo"
@source.stubs(:expirer).returns expirer
@@ -113,7 +117,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
describe "when copying the source values" do
before do
- @resource = Puppet::Type.type(:file).new :path => "/foo/bar"
+ @resource = Puppet::Type.type(:file).new :path => @foobar
@source = source.new(:resource => @resource)
@metadata = stub 'metadata', :owner => 100, :group => 200, :mode => 123, :checksum => "{md5}asdfasdf", :ftype => "file"
diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb
index 3a01d09c1..f416e987a 100755
--- a/spec/unit/type/file_spec.rb
+++ b/spec/unit/type/file_spec.rb
@@ -305,7 +305,7 @@ describe Puppet::Type.type(:file) do
file[:path].should == "X:/"
end
- it "should add a slash to a drive letter", :'fails_on_ruby_1.9.2' => true do
+ it "should add a slash to a drive letter", :'fails_on_windows' => true, :'fails_on_ruby_1.9.2' => true do
file = Puppet::Type::File.new(:path => "X:")
file[:path].should == "X:/"
end
diff --git a/spec/unit/type/group_spec.rb b/spec/unit/type/group_spec.rb
index afe28247a..3b6cac8bc 100755
--- a/spec/unit/type/group_spec.rb
+++ b/spec/unit/type/group_spec.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env rspec
require 'spec_helper'
-describe Puppet::Type.type(:group) do
+describe Puppet::Type.type(:group), :fails_on_windows => true do
before do
ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin" unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin")
@class = Puppet::Type.type(:group)
diff --git a/spec/unit/type/host_spec.rb b/spec/unit/type/host_spec.rb
index 602c428af..145fb27ab 100755
--- a/spec/unit/type/host_spec.rb
+++ b/spec/unit/type/host_spec.rb
@@ -34,7 +34,7 @@ describe host do
end
- describe "when validating values" do
+ describe "when validating values", :fails_on_windows => true do
it "should support present as a value for ensure" do
proc { @class.new(:name => "foo", :ensure => :present) }.should_not raise_error
end
diff --git a/spec/unit/type/mount_spec.rb b/spec/unit/type/mount_spec.rb
index 9ef76992a..3309cd267 100755
--- a/spec/unit/type/mount_spec.rb
+++ b/spec/unit/type/mount_spec.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env rspec
require 'spec_helper'
-describe Puppet::Type.type(:mount) do
+describe Puppet::Type.type(:mount), :fails_on_windows => true do
it "should have a :refreshable feature that requires the :remount method" do
Puppet::Type.type(:mount).provider_feature(:refreshable).methods.should == [:remount]
end
@@ -16,7 +16,7 @@ describe Puppet::Type.type(:mount) do
end
end
-describe Puppet::Type.type(:mount), "when validating attributes" do
+describe Puppet::Type.type(:mount), "when validating attributes", :fails_on_windows => true do
[:name, :remounts, :provider].each do |param|
it "should have a #{param} parameter" do
Puppet::Type.type(:mount).attrtype(param).should == :param
@@ -30,7 +30,7 @@ describe Puppet::Type.type(:mount), "when validating attributes" do
end
end
-describe Puppet::Type.type(:mount)::Ensure, "when validating values" do
+describe Puppet::Type.type(:mount)::Ensure, "when validating values", :fails_on_windows => true do
before do
@provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil
Puppet::Type.type(:mount).defaultprovider.expects(:new).returns(@provider)
@@ -62,7 +62,7 @@ describe Puppet::Type.type(:mount)::Ensure, "when validating values" do
end
end
-describe Puppet::Type.type(:mount)::Ensure do
+describe Puppet::Type.type(:mount)::Ensure, :fails_on_windows => true do
before :each do
provider_properties = {}
@provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock, :property_hash => provider_properties
@@ -279,7 +279,7 @@ describe Puppet::Type.type(:mount)::Ensure do
end
end
-describe Puppet::Type.type(:mount), "when modifying an existing mount entry" do
+describe Puppet::Type.type(:mount), "when modifying an existing mount entry", :fails_on_windows => true do
before do
@provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock, :remount => nil
Puppet::Type.type(:mount).defaultprovider.stubs(:new).returns(@provider)
diff --git a/spec/unit/type/noop_metaparam_spec.rb b/spec/unit/type/noop_metaparam_spec.rb
index f4241d417..7083dd037 100755
--- a/spec/unit/type/noop_metaparam_spec.rb
+++ b/spec/unit/type/noop_metaparam_spec.rb
@@ -4,9 +4,11 @@ require 'spec_helper'
require 'puppet/type'
describe Puppet::Type.type(:file).attrclass(:noop) do
+ include PuppetSpec::Files
+
before do
Puppet.settings.stubs(:use)
- @file = Puppet::Type.newfile :path => "/what/ever"
+ @file = Puppet::Type.newfile :path => make_absolute("/what/ever")
end
it "should accept true as a value" do
diff --git a/spec/unit/type/resources_spec.rb b/spec/unit/type/resources_spec.rb
index 48c068cfa..5e9396b24 100755
--- a/spec/unit/type/resources_spec.rb
+++ b/spec/unit/type/resources_spec.rb
@@ -21,7 +21,7 @@ describe resources do
end
end
- describe "#generate" do
+ describe "#generate", :fails_on_windows => true do
before do
@host1 = Puppet::Type.type(:host).new(:name => 'localhost', :ip => '127.0.0.1')
@catalog = Puppet::Resource::Catalog.new
diff --git a/spec/unit/type/ssh_authorized_key_spec.rb b/spec/unit/type/ssh_authorized_key_spec.rb
index 71b8a9ab0..9b3760b71 100755
--- a/spec/unit/type/ssh_authorized_key_spec.rb
+++ b/spec/unit/type/ssh_authorized_key_spec.rb
@@ -4,6 +4,8 @@ require 'spec_helper'
ssh_authorized_key = Puppet::Type.type(:ssh_authorized_key)
describe ssh_authorized_key do
+ include PuppetSpec::Files
+
before do
@class = Puppet::Type.type(:ssh_authorized_key)
@@ -11,7 +13,7 @@ describe ssh_authorized_key do
@class.stubs(:defaultprovider).returns(@provider_class)
@class.stubs(:provider).returns(@provider_class)
- @provider = stub 'provider', :class => @provider_class, :file_path => "/tmp/whatever", :clear => nil
+ @provider = stub 'provider', :class => @provider_class, :file_path => make_absolute("/tmp/whatever"), :clear => nil
@provider_class.stubs(:new).returns(@provider)
@catalog = Puppet::Resource::Catalog.new
end
@@ -180,7 +182,7 @@ describe ssh_authorized_key do
proc { @class.new(:name => "whev", :type => :rsa, :target => "/tmp/here") }.should_not raise_error
end
- it "should use the user's path if not explicitly specified" do
+ it "should use the user's path if not explicitly specified", :fails_on_windows => true do
@class.new(:name => "whev", :user => 'root').should(:target).should == File.expand_path("~root/.ssh/authorized_keys")
end
@@ -226,7 +228,7 @@ describe ssh_authorized_key do
end
- describe "when user is specified" do
+ describe "when user is specified", :fails_on_windows => true do
it "should determine target" do
resource = @class.create(
diff --git a/spec/unit/type/tidy_spec.rb b/spec/unit/type/tidy_spec.rb
index cb030634b..bf892e836 100755
--- a/spec/unit/type/tidy_spec.rb
+++ b/spec/unit/type/tidy_spec.rb
@@ -5,8 +5,10 @@ require 'puppet/file_bucket/dipper'
tidy = Puppet::Type.type(:tidy)
describe tidy do
+ include PuppetSpec::Files
+
before do
- @basepath = Puppet.features.posix? ? "/what/ever" : "C:/tmp"
+ @basepath = make_absolute("/what/ever")
Puppet.settings.stubs(:use)
# for an unknown reason some of these specs fails when run individually
diff --git a/spec/unit/type/user_spec.rb b/spec/unit/type/user_spec.rb
index 71c9e1857..2da755ef2 100755
--- a/spec/unit/type/user_spec.rb
+++ b/spec/unit/type/user_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
user = Puppet::Type.type(:user)
-describe user do
+describe user, :fails_on_windows => true do
before do
ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin" unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin")
@provider = stub 'provider'
diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb
index bbdaec3bc..73150af48 100755
--- a/spec/unit/type_spec.rb
+++ b/spec/unit/type_spec.rb
@@ -1,7 +1,9 @@
#!/usr/bin/env rspec
require 'spec_helper'
-describe Puppet::Type do
+describe Puppet::Type, :'fails_on_windows' => true do
+ include PuppetSpec::Files
+
it "should include the Cacher module" do
Puppet::Type.ancestors.should be_include(Puppet::Util::Cacher)
end
@@ -309,7 +311,8 @@ describe Puppet::Type do
end
it "should use the Resource Type's namevar to determine how to find the name in the hash" do
- Puppet::Type.type(:file).new(:path => "/yay").title.should == "/yay"
+ yay = make_absolute('/yay')
+ Puppet::Type.type(:file).new(:path => yay).title.should == yay
end
[:catalog].each do |param|
@@ -387,7 +390,7 @@ describe Puppet::Type do
end
it "should delete the name via the namevar from the originally provided parameters" do
- Puppet::Type.type(:file).new(:name => "/foo").original_parameters[:path].should be_nil
+ Puppet::Type.type(:file).new(:name => make_absolute('/foo')).original_parameters[:path].should be_nil
end
end
@@ -471,7 +474,7 @@ describe Puppet::Type do
end
it "should provide a value for 'ensure' even if no desired value is provided" do
- @resource = Puppet::Type.type(:file).new(:path => "/my/file/that/can't/exist")
+ @resource = Puppet::Type.type(:file).new(:path => make_absolute("/my/file/that/can't/exist"))
end
it "should not call retrieve on non-ensure properties if the resource is absent and should consider the property absent" do
@@ -513,8 +516,8 @@ describe Puppet::Type do
before do
@catalog = Puppet::Resource::Catalog.new
@container = Puppet::Type.type(:component).new(:name => "container")
- @one = Puppet::Type.type(:file).new(:path => "/file/one")
- @two = Puppet::Type.type(:file).new(:path => "/file/two")
+ @one = Puppet::Type.type(:file).new(:path => make_absolute("/file/one"))
+ @two = Puppet::Type.type(:file).new(:path => make_absolute("/file/two"))
@catalog.add_resource @container
@catalog.add_resource @one
@@ -541,7 +544,9 @@ describe Puppet::Type do
end
end
-describe Puppet::Type::RelationshipMetaparam do
+describe Puppet::Type::RelationshipMetaparam, :fails_on_windows => true do
+ include PuppetSpec::Files
+
it "should be a subclass of Puppet::Parameter" do
Puppet::Type::RelationshipMetaparam.superclass.should equal(Puppet::Parameter)
end
@@ -550,14 +555,15 @@ describe Puppet::Type::RelationshipMetaparam do
Puppet::Type::RelationshipMetaparam.should respond_to(:subclasses)
end
- describe "when munging relationships" do
+ describe "when munging relationships", :'fails_on_windows' => true do
before do
- @resource = Puppet::Type.type(:mount).new :name => "/foo"
+ @path = make_absolute('/foo')
+ @resource = Puppet::Type.type(:mount).new :name => @path
@metaparam = Puppet::Type.metaparamclass(:require).new :resource => @resource
end
it "should accept Puppet::Resource instances" do
- ref = Puppet::Resource.new(:file, "/foo")
+ ref = Puppet::Resource.new(:file, @path)
@metaparam.munge(ref)[0].should equal(ref)
end
@@ -585,18 +591,22 @@ describe Puppet::Type::RelationshipMetaparam do
end
end
-describe Puppet::Type.metaparamclass(:check) do
+describe Puppet::Type.metaparamclass(:check), :fails_on_windows => true do
+ include PuppetSpec::Files
+
it "should warn and create an instance of ':audit'" do
- file = Puppet::Type.type(:file).new :path => "/foo"
+ file = Puppet::Type.type(:file).new :path => make_absolute('/foo')
file.expects(:warning)
file[:check] = :mode
file[:audit].should == [:mode]
end
end
-describe Puppet::Type.metaparamclass(:audit) do
+describe Puppet::Type.metaparamclass(:audit), :fails_on_windows => true do
+ include PuppetSpec::Files
+
before do
- @resource = Puppet::Type.type(:file).new :path => "/foo"
+ @resource = Puppet::Type.type(:file).new :path => make_absolute('/foo')
end
it "should default to being nil" do
@@ -642,8 +652,9 @@ describe Puppet::Type.metaparamclass(:audit) do
Puppet::Type.type(:file).stubs(:title_patterns).returns(
[ [ /(.*)/, [ [:path, lambda{|x| x} ] ] ] ]
)
- res = Puppet::Type.type(:file).new( :title => '/my/file', :path => '/my/file', :owner => 'root', :content => 'hello' )
- res.uniqueness_key.should == [ nil, 'root', '/my/file']
+ myfile = make_absolute('/my/file')
+ res = Puppet::Type.type(:file).new( :title => myfile, :path => myfile, :owner => 'root', :content => 'hello' )
+ res.uniqueness_key.should == [ nil, 'root', myfile]
end
end
end
diff --git a/spec/unit/util/autoload_spec.rb b/spec/unit/util/autoload_spec.rb
index d61b7689e..100975f27 100755
--- a/spec/unit/util/autoload_spec.rb
+++ b/spec/unit/util/autoload_spec.rb
@@ -4,6 +4,8 @@ require 'spec_helper'
require 'puppet/util/autoload'
describe Puppet::Util::Autoload do
+ include PuppetSpec::Files
+
before do
@autoload = Puppet::Util::Autoload.new("foo", "tmp")
@@ -15,32 +17,38 @@ describe Puppet::Util::Autoload do
end
describe "when building the search path" do
+ before :each do
+ @dira = make_absolute('/a')
+ @dirb = make_absolute('/b')
+ @dirc = make_absolute('/c')
+ end
+
it "should collect all of the plugins and lib directories that exist in the current environment's module path" do
Puppet.settings.expects(:value).with(:environment).returns "foo"
- Puppet.settings.expects(:value).with(:modulepath, :foo).returns "/a:/b:/c"
- Dir.expects(:entries).with("/a").returns %w{one two}
- Dir.expects(:entries).with("/b").returns %w{one two}
+ Puppet.settings.expects(:value).with(:modulepath, :foo).returns "#{@dira}#{File::PATH_SEPARATOR}#{@dirb}#{File::PATH_SEPARATOR}#{@dirc}"
+ Dir.expects(:entries).with(@dira).returns %w{one two}
+ Dir.expects(:entries).with(@dirb).returns %w{one two}
FileTest.stubs(:directory?).returns false
- FileTest.expects(:directory?).with("/a").returns true
- FileTest.expects(:directory?).with("/b").returns true
- %w{/a/one/plugins /a/two/lib /b/one/plugins /b/two/lib}.each do |d|
+ FileTest.expects(:directory?).with(@dira).returns true
+ FileTest.expects(:directory?).with(@dirb).returns true
+ ["#{@dira}/one/plugins", "#{@dira}/two/lib", "#{@dirb}/one/plugins", "#{@dirb}/two/lib"].each do |d|
FileTest.expects(:directory?).with(d).returns true
end
- @autoload.module_directories.should == %w{/a/one/plugins /a/two/lib /b/one/plugins /b/two/lib}
+ @autoload.module_directories.should == ["#{@dira}/one/plugins", "#{@dira}/two/lib", "#{@dirb}/one/plugins", "#{@dirb}/two/lib"]
end
it "should not look for lib directories in directories starting with '.'" do
Puppet.settings.expects(:value).with(:environment).returns "foo"
- Puppet.settings.expects(:value).with(:modulepath, :foo).returns "/a"
- Dir.expects(:entries).with("/a").returns %w{. ..}
-
- FileTest.expects(:directory?).with("/a").returns true
- FileTest.expects(:directory?).with("/a/./lib").never
- FileTest.expects(:directory?).with("/a/./plugins").never
- FileTest.expects(:directory?).with("/a/../lib").never
- FileTest.expects(:directory?).with("/a/../plugins").never
+ Puppet.settings.expects(:value).with(:modulepath, :foo).returns @dira
+ Dir.expects(:entries).with(@dira).returns %w{. ..}
+
+ FileTest.expects(:directory?).with(@dira).returns true
+ FileTest.expects(:directory?).with("#{@dira}/./lib").never
+ FileTest.expects(:directory?).with("#{@dira}/./plugins").never
+ FileTest.expects(:directory?).with("#{@dira}/../lib").never
+ FileTest.expects(:directory?).with("#{@dira}/../plugins").never
@autoload.module_directories
end
diff --git a/spec/unit/util/backups_spec.rb b/spec/unit/util/backups_spec.rb
index 611c19304..d2f36a6e6 100755
--- a/spec/unit/util/backups_spec.rb
+++ b/spec/unit/util/backups_spec.rb
@@ -4,28 +4,31 @@ require 'spec_helper'
require 'puppet/util/backups'
describe Puppet::Util::Backups do
+ include PuppetSpec::Files
+
before do
FileTest.stubs(:exists?).returns true
+ @nosuchfile = make_absolute('/no/such/file')
end
describe "when backing up a file" do
it "should noop if the file does not exist" do
FileTest.expects(:exists?).returns false
- file = Puppet::Type.type(:file).new(:name => '/no/such/file')
+ file = Puppet::Type.type(:file).new(:name => @nosuchfile)
file.expects(:bucket).never
file.perform_backup
end
it "should succeed silently if self[:backup] is false" do
- file = Puppet::Type.type(:file).new(:name => '/no/such/file', :backup => false)
+ file = Puppet::Type.type(:file).new(:name => @nosuchfile, :backup => false)
file.expects(:bucket).never
FileTest.expects(:exists?).never
file.perform_backup
end
it "a bucket should be used when provided" do
- path = '/my/file'
+ path = make_absolute('/my/file')
File.stubs(:stat).with(path).returns(mock('stat', :ftype => 'file'))
@@ -39,7 +42,7 @@ describe Puppet::Util::Backups do
end
it "should propagate any exceptions encountered when backing up to a filebucket" do
- path = '/my/file'
+ path = make_absolute('/my/file')
File.stubs(:stat).with(path).returns(mock('stat', :ftype => 'file'))
@@ -54,7 +57,7 @@ describe Puppet::Util::Backups do
describe "and no filebucket is configured" do
it "should remove any local backup if one exists" do
- path = '/my/file'
+ path = make_absolute('/my/file')
FileTest.stubs(:exists?).returns true
backup = path + ".foo"
@@ -69,7 +72,7 @@ describe Puppet::Util::Backups do
end
it "should fail when the old backup can't be removed" do
- path = '/my/file'
+ path = make_absolute('/my/file')
FileTest.stubs(:exists?).returns true
backup = path + ".foo"
@@ -84,7 +87,7 @@ describe Puppet::Util::Backups do
end
it "should not try to remove backups that don't exist" do
- path = '/my/file'
+ path = make_absolute('/my/file')
FileTest.stubs(:exists?).returns true
backup = path + ".foo"
@@ -99,7 +102,7 @@ describe Puppet::Util::Backups do
end
it "a copy should be created in the local directory" do
- path = '/my/file'
+ path = make_absolute('/my/file')
FileTest.stubs(:exists?).with(path).returns true
FileUtils.expects(:cp_r).with(path, path + ".foo", :preserve => true)
@@ -109,7 +112,7 @@ describe Puppet::Util::Backups do
end
it "should propagate exceptions if no backup can be created" do
- path = '/my/file'
+ path = make_absolute('/my/file')
FileTest.stubs(:exists?).with(path).returns true
FileUtils.expects(:cp_r).raises ArgumentError
@@ -122,13 +125,13 @@ describe Puppet::Util::Backups do
describe "when backing up a directory" do
it "a bucket should work when provided" do
- path = '/my/dir'
+ path = make_absolute('/my/dir')
File.stubs(:file?).returns true
- Find.expects(:find).with(path).yields("/my/dir/file")
+ Find.expects(:find).with(path).yields(make_absolute("/my/dir/file"))
bucket = stub('bucket', :name => "eh")
- bucket.expects(:backup).with("/my/dir/file").returns true
+ bucket.expects(:backup).with(make_absolute("/my/dir/file")).returns true
file = Puppet::Type.type(:file).new(:name => path, :backup => 'foo')
file.stubs(:bucket).returns bucket
@@ -139,7 +142,7 @@ describe Puppet::Util::Backups do
end
it "should do nothing when recursing" do
- path = '/my/dir'
+ path = make_absolute('/my/dir')
bucket = stub('bucket', :name => "eh")
bucket.expects(:backup).never
diff --git a/spec/unit/util/execution_stub_spec.rb b/spec/unit/util/execution_stub_spec.rb
index 34987689c..9cd15ca6a 100755
--- a/spec/unit/util/execution_stub_spec.rb
+++ b/spec/unit/util/execution_stub_spec.rb
@@ -16,7 +16,7 @@ describe Puppet::Util::ExecutionStub do
Puppet::Util::ExecutionStub.current_value.should == nil
end
- it "should restore normal execution after 'reset' is called" do
+ it "should restore normal execution after 'reset' is called", :fails_on_windows => true do
true_command = Puppet::Util.which('true') # Note: "true" exists at different paths in different OSes
stub_call_count = 0
Puppet::Util::ExecutionStub.set do |command, options|
diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb
index 1baa0d5af..39da4b010 100755
--- a/spec/unit/util/log_spec.rb
+++ b/spec/unit/util/log_spec.rb
@@ -4,6 +4,8 @@ require 'spec_helper'
require 'puppet/util/log'
describe Puppet::Util::Log do
+ include PuppetSpec::Files
+
it "should write a given message to the specified destination" do
arraydest = []
Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(arraydest))
@@ -167,7 +169,7 @@ describe Puppet::Util::Log do
describe "when setting the source as a RAL object" do
it "should tag itself with any tags the source has" do
- source = Puppet::Type.type(:file).new :path => "/foo/bar"
+ source = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar")
log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source)
source.tags.each do |tag|
log.tags.should be_include(tag)
@@ -188,7 +190,7 @@ describe Puppet::Util::Log do
end
it "should copy over any file and line information" do
- source = Puppet::Type.type(:file).new :path => "/foo/bar"
+ source = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar")
source.file = "/my/file"
source.line = 50
log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source)
diff --git a/spec/unit/util/logging_spec.rb b/spec/unit/util/logging_spec.rb
index 6a77e70ef..2953f54a4 100755
--- a/spec/unit/util/logging_spec.rb
+++ b/spec/unit/util/logging_spec.rb
@@ -46,7 +46,7 @@ describe Puppet::Util::Logging do
@logger.notice "foo"
end
- it "should use the path of any provided resource type" do
+ it "should use the path of any provided resource type", :fails_on_windows => true do
resource = Puppet::Type.type(:mount).new :name => "foo"
resource.expects(:path).returns "/path/to/mount".to_sym
@@ -56,7 +56,7 @@ describe Puppet::Util::Logging do
resource.notice "foo"
end
- it "should use the path of any provided resource parameter" do
+ it "should use the path of any provided resource parameter", :fails_on_windows => true do
resource = Puppet::Type.type(:mount).new :name => "foo"
param = resource.parameter(:name)
diff --git a/spec/unit/util/network_device/config_spec.rb b/spec/unit/util/network_device/config_spec.rb
index d69358a92..d9bd3d979 100755
--- a/spec/unit/util/network_device/config_spec.rb
+++ b/spec/unit/util/network_device/config_spec.rb
@@ -4,9 +4,11 @@ require 'spec_helper'
require 'puppet/util/network_device/config'
describe Puppet::Util::NetworkDevice::Config do
+ include PuppetSpec::Files
+
before(:each) do
- Puppet[:deviceconfig] = "/dummy"
- FileTest.stubs(:exists?).with("/dummy").returns(true)
+ Puppet[:deviceconfig] = make_absolute("/dummy")
+ FileTest.stubs(:exists?).with(make_absolute("/dummy")).returns(true)
end
describe "when initializing" do
@@ -15,7 +17,7 @@ describe Puppet::Util::NetworkDevice::Config do
end
it "should use the deviceconfig setting as pathname" do
- Puppet.expects(:[]).with(:deviceconfig).returns("/dummy")
+ Puppet.expects(:[]).with(:deviceconfig).returns(make_absolute("/dummy"))
Puppet::Util::NetworkDevice::Config.new
end
diff --git a/spec/unit/util/rdoc/parser_spec.rb b/spec/unit/util/rdoc/parser_spec.rb
index 92b50e09b..4c2c79e88 100755
--- a/spec/unit/util/rdoc/parser_spec.rb
+++ b/spec/unit/util/rdoc/parser_spec.rb
@@ -8,6 +8,8 @@ require 'rdoc/options'
require 'rdoc/rdoc'
describe RDoc::Parser, :'fails_on_ruby_1.9.2' => true do
+ include PuppetSpec::Files
+
before :each do
File.stubs(:stat).with("init.pp")
@top_level = stub_everything 'toplevel', :file_relative_name => "init.pp"
@@ -21,7 +23,7 @@ describe RDoc::Parser, :'fails_on_ruby_1.9.2' => true do
Puppet::Parser::Parser.stubs(:new).returns(parser)
parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new('')).at_least_once
parser.expects(:file=).with("module/manifests/init.pp")
- parser.expects(:file=).with("/dev/null/manifests/site.pp")
+ parser.expects(:file=).with(make_absolute("/dev/null/manifests/site.pp"))
@parser.scan
end
diff --git a/spec/unit/util/run_mode_spec.rb b/spec/unit/util/run_mode_spec.rb
index c8d2b31f6..883ee1206 100755
--- a/spec/unit/util/run_mode_spec.rb
+++ b/spec/unit/util/run_mode_spec.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env rspec
require 'spec_helper'
-describe Puppet::Util::RunMode do
+describe Puppet::Util::RunMode, :fails_on_windows => true do
before do
@run_mode = Puppet::Util::RunMode.new('fake')
end
diff --git a/spec/unit/util/settings/file_setting_spec.rb b/spec/unit/util/settings/file_setting_spec.rb
index 489628a78..01d891f08 100755
--- a/spec/unit/util/settings/file_setting_spec.rb
+++ b/spec/unit/util/settings/file_setting_spec.rb
@@ -7,8 +7,10 @@ require 'puppet/util/settings/file_setting'
describe Puppet::Util::Settings::FileSetting do
FileSetting = Puppet::Util::Settings::FileSetting
+ include PuppetSpec::Files
+
before do
- @basepath = Puppet.features.posix? ? "/somepath" : "C:/somepath"
+ @basepath = make_absolute("/somepath")
end
describe "when determining whether the service user should be used" do
@@ -165,7 +167,10 @@ describe Puppet::Util::Settings::FileSetting do
it "should fully qualified returned files if necessary (#795)" do
@settings.stubs(:value).with(:mydir).returns "myfile"
- @file.to_resource.title.should == File.join(Dir.getwd, "myfile")
+ path = File.join(Dir.getwd, "myfile")
+ # Dir.getwd can return windows paths with backslashes, so we normalize them using expand_path
+ path = File.expand_path(path) if Puppet.features.microsoft_windows?
+ @file.to_resource.title.should == path
end
it "should set the mode on the file if a mode is provided" do
diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
index aa50c8f3a..efe2be443 100755
--- a/spec/unit/util/settings_spec.rb
+++ b/spec/unit/util/settings_spec.rb
@@ -2,6 +2,8 @@
require 'spec_helper'
describe Puppet::Util::Settings do
+ include PuppetSpec::Files
+
describe "when specifying defaults" do
before do
@settings = Puppet::Util::Settings.new
@@ -377,7 +379,7 @@ describe Puppet::Util::Settings do
end
it "should use its current ':config' value for the file to parse" do
- myfile = Puppet.features.posix? ? "/my/file" : "C:/myfile" # do not stub expand_path here, as this leads to a stack overflow, when mocha tries to use it
+ myfile = make_absolute("/my/file") # do not stub expand_path here, as this leads to a stack overflow, when mocha tries to use it
@settings[:config] = myfile
File.expects(:read).with(myfile).returns "[main]"
@@ -444,25 +446,27 @@ describe Puppet::Util::Settings do
it "should support specifying all metadata (owner, group, mode) in the configuration file" do
@settings.setdefaults :section, :myfile => ["/myfile", "a"]
+ otherfile = make_absolute("/other/file")
text = "[main]
- myfile = /other/file {owner = service, group = service, mode = 644}
+ myfile = #{otherfile} {owner = service, group = service, mode = 644}
"
@settings.expects(:read_file).returns(text)
@settings.parse
- @settings[:myfile].should == "/other/file"
+ @settings[:myfile].should == otherfile
@settings.metadata(:myfile).should == {:owner => "suser", :group => "sgroup", :mode => "644"}
end
it "should support specifying a single piece of metadata (owner, group, or mode) in the configuration file" do
@settings.setdefaults :section, :myfile => ["/myfile", "a"]
+ otherfile = make_absolute("/other/file")
text = "[main]
- myfile = /other/file {owner = service}
+ myfile = #{otherfile} {owner = service}
"
file = "/some/file"
@settings.expects(:read_file).returns(text)
@settings.parse
- @settings[:myfile].should == "/other/file"
+ @settings[:myfile].should == otherfile
@settings.metadata(:myfile).should == {:owner => "suser"}
end
diff --git a/spec/unit/util/storage_spec.rb b/spec/unit/util/storage_spec.rb
index 90c11aa69..575ad1ef3 100755
--- a/spec/unit/util/storage_spec.rb
+++ b/spec/unit/util/storage_spec.rb
@@ -8,7 +8,7 @@ describe Puppet::Util::Storage do
include PuppetSpec::Files
before(:all) do
- @basepath = Puppet.features.posix? ? "/somepath" : "C:/somepath"
+ @basepath = make_absolute("/somepath")
Puppet[:statedir] = tmpdir("statedir")
end