diff options
| author | Jean Mertz <jean@mertz.fm> | 2014-10-02 15:49:53 +0200 |
|---|---|---|
| committer | Jean Mertz <jean@mertz.fm> | 2014-10-08 09:26:58 +0200 |
| commit | d4801e39b1e82e85ffebeff797be4f0b9d5d6493 (patch) | |
| tree | eb9530b6035d6dd04fd930a209ff4d35067ee761 | |
| parent | b75e1de72453e20312dcdc1ea1a480c048ee59a9 (diff) | |
| download | chef-d4801e39b1e82e85ffebeff797be4f0b9d5d6493.tar.gz | |
Skip checking files/**/*.rb files when doing syntax checks
Chef should not be concerned with Ruby syntax in files delivered through the
`cookbook_file` provider.
| -rw-r--r-- | lib/chef/cookbook/syntax_check.rb | 15 | ||||
| -rw-r--r-- | spec/data/cookbooks/ignorken/files/default/not_me.rb | 2 | ||||
| -rw-r--r-- | spec/data/cookbooks/ignorken/templates/ubuntu-12.10/not_me.rb | 2 |
3 files changed, 16 insertions, 3 deletions
diff --git a/lib/chef/cookbook/syntax_check.rb b/lib/chef/cookbook/syntax_check.rb index 1437785259..96fc7e7b84 100644 --- a/lib/chef/cookbook/syntax_check.rb +++ b/lib/chef/cookbook/syntax_check.rb @@ -101,15 +101,24 @@ class Chef end def remove_ignored_files(file_list) - return file_list unless chefignore.ignores.length > 0 + return file_list if chefignore.ignores.empty? + file_list.reject do |full_path| relative_pn = Chef::Util::PathHelper.relative_path_from(cookbook_path, full_path) - chefignore.ignored? relative_pn.to_s + chefignore.ignored?(relative_pn.to_s) end end + def remove_uninteresting_ruby_files(file_list) + file_list.reject { |f| f =~ %r{#{cookbook_path}/(files|templates)/} } + end + def ruby_files - remove_ignored_files Dir[File.join(Chef::Util::PathHelper.escape_glob(cookbook_path), '**', '*.rb')] + path = Chef::Util::PathHelper.escape_glob(cookbook_path) + files = Dir[File.join(path, '**', '*.rb')] + files = remove_ignored_files(files) + files = remove_uninteresting_ruby_files(files) + files end def untested_ruby_files diff --git a/spec/data/cookbooks/ignorken/files/default/not_me.rb b/spec/data/cookbooks/ignorken/files/default/not_me.rb new file mode 100644 index 0000000000..8063e32a95 --- /dev/null +++ b/spec/data/cookbooks/ignorken/files/default/not_me.rb @@ -0,0 +1,2 @@ +a cat walked on the keyboard one day... +(*&(*&(*&(*&(*^%$%^%#^^&(*)(*{}}}}}}}}+++++===)))))) diff --git a/spec/data/cookbooks/ignorken/templates/ubuntu-12.10/not_me.rb b/spec/data/cookbooks/ignorken/templates/ubuntu-12.10/not_me.rb new file mode 100644 index 0000000000..8063e32a95 --- /dev/null +++ b/spec/data/cookbooks/ignorken/templates/ubuntu-12.10/not_me.rb @@ -0,0 +1,2 @@ +a cat walked on the keyboard one day... +(*&(*&(*&(*&(*^%$%^%#^^&(*)(*{}}}}}}}}+++++===)))))) |
