Skip to content

Commit

Permalink
(PDK-1717) Add guard clause to module path dir enum loop
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sanfrancrisko committed Aug 23, 2021
1 parent 24d7b21 commit b6bfd6f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/puppetlabs_spec_helper/module_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def verify_contents(subject, title, expected_lines)

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

0 comments on commit b6bfd6f

Please sign in to comment.