diff options
| author | Josh Cooper <josh@puppetlabs.com> | 2011-07-18 23:05:35 -0700 |
|---|---|---|
| committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-08-19 13:48:29 -0700 |
| commit | c26f3e5f79fa2caa17d18be41e32871ac09b1dc4 (patch) | |
| tree | a27fb91f82ba4e98bb4ed4281151a150f0b51fac /spec/unit/util/settings | |
| parent | bfeb33734358528209221be09b97ffc8513d3f87 (diff) | |
| download | puppet-c26f3e5f79fa2caa17d18be41e32871ac09b1dc4.tar.gz puppet-c26f3e5f79fa2caa17d18be41e32871ac09b1dc4.tar.xz puppet-c26f3e5f79fa2caa17d18be41e32871ac09b1dc4.zip | |
Fix tests with "relative" paths on Windows
Absolute paths on Unix, e.g. /foo/bar, are not absolute on Windows,
which breaks many test cases. This commit adds a method to
PuppetSpec::Files.make_absolute that makes the path absolute in
test cases.
On Unix (Puppet.features.posix?) it is a no-op. On Windows,
(Puppet.features.microsoft_windows?) the drive from the current
working directory is prepended.
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
(cherry picked from commit 462a95e3d077b1915a919399b846068816c84583)
Conflicts:
spec/unit/parser/functions/extlookup_spec.rb
Diffstat (limited to 'spec/unit/util/settings')
| -rwxr-xr-x | spec/unit/util/settings/file_setting_spec.rb | 9 |
1 files changed, 7 insertions, 2 deletions
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 |
