Skip to content

Commit b6bfd6f

Browse files
author
sanfrancrisko
committed
(PDK-1717) Add guard clause to module path dir enum loop
Prior to this commit, If a non-existent directory is specified in the `MODULEPATH` env var, it will cause the enumeration of module paths to fail. This commit performs a `Dir.exist?` check in that loop before any subsequent unguarded / unrescued calls are made. This issue manifested due to a conflict with the Linux package `lmod` also using the `MODULEPATH` env var and populating it with non-existent dir paths.
1 parent 24d7b21 commit b6bfd6f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/puppetlabs_spec_helper/module_spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def verify_contents(subject, title, expected_lines)
5454

5555
# Add all spec lib dirs to LOAD_PATH
5656
components = module_path.split(File::PATH_SEPARATOR).collect do |dir|
57+
next unless Dir.exist? dir
5758
Dir.entries(dir).reject { |f| f =~ %r{^\.} }.collect { |f| File.join(dir, f, 'spec', 'lib') }
5859
end
5960
components.flatten.each do |d|

0 commit comments

Comments
 (0)