From b8bfb01edf2892d1661455b77eab5a37572ed6a9 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 29 Mar 2017 19:23:12 -0400 Subject: [PATCH] =?UTF-8?q?Add=20support=20for=20AStyle=20in=20test=20make?= =?UTF-8?q?file.=20It=E2=80=99s=20going=20to=20assume=20you=20have=20it=20?= =?UTF-8?q?installed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/rakefile | 21 +++++++++++++++++++-- test/rakefile_helper.rb | 12 ++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/test/rakefile b/test/rakefile index 9bcf230..4a2f3d2 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 410da7f..be5bf3e 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 -- GitLab