diff --git a/test/rakefile b/test/rakefile index 9bcf2300d0a02e71f88388c3060f5bb40de88324..4a2f3d2c12cf7c92386c9387e88504a047d48fe1 100644 --- a/test/rakefile +++ b/test/rakefile @@ -76,18 +76,35 @@ namespace :style do task :check do report "\nVERIFYING RUBY STYLE" report execute("rubocop ../auto ../examples ../extras --config .rubocop.yml", true) - report "Style PASSED." + report "Styling Ruby:PASS" end namespace :check do Dir['../**/*.rb'].each do |f| - task File.basename(f, '.rb').to_sym => ['style:clean'] do + filename = File.basename(f, '.rb') + desc "Check Style of #{filename}" + task filename.to_sym => ['style:clean'] do report execute("rubocop #{f} --color --config .rubocop.yml", true) report "Style Checked for #{f}" end end end + desc "Fix Style of all C Code" + task :c do + run_astyle("../src/*.* ../extras/fixture/src/*.*") + end + + namespace :c do + Dir['../{src,extras/**}/*.{c,h}'].each do |f| + filename = File.basename(f)[0..-3] + desc "Check Style of #{filename}" + task filename.to_sym do + run_astyle f + end + end + end + desc "Attempt to Autocorrect style" task :auto => ['style:clean'] do execute("rubocop ../auto ../examples ../extras --auto-correct --config .rubocop.yml") diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index 410da7fcfd7e427aefa9a10fc8c37682311d8b48..be5bf3ea23d2e9327aac741879e388992d7d6a0f 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -157,6 +157,18 @@ module RakefileHelpers { :command => command, :pre_support => pre_support, :post_support => post_support } end + def run_astyle(style_what) + report "Styling C Code..." + command = "AStyle " \ + "--style=allman --indent=spaces=4 --indent-switches --indent-preproc-define --indent-preproc-block " \ + "--pad-oper --pad-comma --unpad-paren --pad-header " \ + "--align-pointer=type --align-reference=name " \ + "--add-brackets --mode=c --suffix=none " \ + "#{style_what}" + execute(command, false) + report "Styling C:PASS" + end + def execute(command_string, ok_to_fail = false) report command_string if $verbose output = `#{command_string}`.chomp