Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/octocatalog-diff/catalog-util/fileresources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def self.module_path(dir)
result = []
Regexp.last_match(1).split(/:/).map(&:strip).each do |path|
next if path.start_with?('$')
result << File.expand_path(path, dir)
result.concat(Dir.glob(File.expand_path(path, dir)))
end
result
else
Expand Down
13 changes: 13 additions & 0 deletions spec/octocatalog-diff/tests/catalog-util/fileresources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,22 @@ def catalog_from_fixture(path)
it 'should return proper entries from environment.conf modulepath' do
allow(File).to receive(:file?).with('/a/environment.conf').and_return(true)
allow(File).to receive(:read).with('/a/environment.conf').and_return('modulepath=modules:site:$basemoduledir')
allow(Dir).to receive(:glob).with('/a/modules').and_return(['/a/modules'])
allow(Dir).to receive(:glob).with('/a/site').and_return(['/a/site'])
result = OctocatalogDiff::CatalogUtil::FileResources.module_path('/a')
expect(result).to eq(['/a/modules', '/a/site'])
end

it 'should expand globs in modulepath, if present' do
allow(File).to receive(:file?).with('/a/environment.conf').and_return(true)
allow(File).to receive(:read).with('/a/environment.conf')
.and_return('modulepath=modules:extra_mods/*/modules:$basemoduledir')
allow(Dir).to receive(:glob).with('/a/modules').and_return(['/a/modules'])
allow(Dir).to receive(:glob).with('/a/extra_mods/*/modules')
.and_return(['/a/extra_mods/a/modules', '/a/extra_mods/b/modules'])
result = OctocatalogDiff::CatalogUtil::FileResources.module_path('/a')
expect(result).to eq(['/a/modules', '/a/extra_mods/a/modules', '/a/extra_mods/b/modules'])
end
end

context 'with mixed files and directories' do
Expand Down