summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util/rdoc/parser.rb
diff options
context:
space:
mode:
authorJosh Cooper <josh@puppetlabs.com>2011-07-22 12:44:15 -0700
committerJacob Helwig <jacob@puppetlabs.com>2011-08-19 13:52:57 -0700
commitad29bf6114f637adfd686e88535aa79bc8cae7b8 (patch)
treef91c7c9c9020a10a72753e8d52081adb927e090c /lib/puppet/util/rdoc/parser.rb
parenteaa7d92f4017fcdae54e5f6addf1edd3a72fe384 (diff)
downloadpuppet-ad29bf6114f637adfd686e88535aa79bc8cae7b8.tar.gz
puppet-ad29bf6114f637adfd686e88535aa79bc8cae7b8.tar.xz
puppet-ad29bf6114f637adfd686e88535aa79bc8cae7b8.zip
Fix issue with forward and backslashes in Windows paths
The environment validates its modulepath and manifestdir settings, but it uses Dir.getwd to convert a relative path into an absolute path. The problem is that on Windows, Dir.getwd returns a path with backslashes. (Interestingly this only happens when puppet is loaded, not in irb for example.) And since we do not yet support backslashes in Windows paths or UNC paths, the directory is not included in the environment. For the time being, I am using File.expand_path to normalize the path. It has the side-effect of converting backslashes to forward slashes. This is sufficient to work around backslashes in Dir.getwd. In the near future, I will be refactoring how paths are split, validated, tested, etc, and I have a REMIND in place to fix the environment. But as a result of this change it exposed a bug in our rdoc parser dealing with the finding the root of a path. The parser assumed that the root was '/', but caused an infinite loop when passed a Windows path. I added a test for this case, which is only run on Windows, because on Unix File.dirname("C:/") == '.'. After all of that, I had to disable one of the rdoc spec tests, because it attempted to reproduce a specific bug, which caused rdoc to try to create a directory of the form: C:/.../files/C:/.... Of course, this fails because ':' is not a valid filename character on Windows. Paired-with: Nick Lewis <nick@puppetlabs.com> Reviewed-by: Jacob Helwig <jacob@puppetlabs.com> (cherry picked from commit 9279d0954eb20d75e18a666fd572b5492e157608)
Diffstat (limited to 'lib/puppet/util/rdoc/parser.rb')
-rw-r--r--lib/puppet/util/rdoc/parser.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb
index 762ce25f0..a8996ee9a 100644
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@ -113,7 +113,9 @@ class Parser
Puppet::Module.modulepath.each do |mp|
# check that fullpath is a descendant of mp
dirname = fullpath
- while (dirname = File.dirname(dirname)) != '/'
+ previous = dirname
+ while (dirname = File.dirname(previous)) != previous
+ previous = dirname
return nil if File.identical?(dirname,mp)
end
end