1 # ========================================== 2 # Unity Project - A Test Framework for C 3 # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams 4 # [Released under MIT License. Please refer to license.txt for details] 5 # ========================================== 6 7 $verbose = false 8 9 require 'rake' 10 require 'rake/clean' 11 require_relative 'rakefile_helper' 12 require 'rspec/core/rake_task' 13 14 TEMP_DIRS = [ 15 File.join(__dir__, 'build'), 16 File.join(__dir__, 'sandbox') 17 ] 18 19 TEMP_DIRS.each do |dir| 20 directory(dir) 21 CLOBBER.include(dir) 22 end 23 24 task :prepare_for_tests => TEMP_DIRS 25 26 include RakefileHelpers 27 28 # Load proper GCC as defult configuration 29 DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml' 30 configure_toolchain(DEFAULT_CONFIG_FILE) 31 32 desc "Test unity with its own unit tests" 33 task :unit => [:prepare_for_tests] do 34 run_tests unit_test_files 35 end 36 37 desc "Test unity's helper scripts" 38 task :scripts => [:prepare_for_tests] do 39 Dir['tests/test_*.rb'].each do |scriptfile| 40 require "./"+scriptfile 41 end 42 end 43 44 desc "Run all rspecs" 45 RSpec::Core::RakeTask.new(:spec) do |t| 46 t.pattern = 'spec/**/*_spec.rb' 47 end 48 49 desc "Generate test summary" 50 task :summary do 51 report_summary 52 end 53 54 desc "Build and test Unity" 55 task :all => [:clean, :prepare_for_tests, :scripts, :unit, :style, :summary] 56 task :default => [:clobber, :all] 57 task :ci => [:no_color, :default] 58 task :cruise => [:no_color, :default] 59 60 desc "Load configuration" 61 task :config, :config_file do |t, args| 62 configure_toolchain(args[:config_file]) 63 end 64 65 task :no_color do 66 $colour_output = false 67 end 68 69 task :verbose do 70 $verbose = true 71 end 72 73 namespace :style do 74 desc "Check style" 75 task :check do 76 report "\nVERIFYING RUBY STYLE" 77 report execute("rubocop ../auto ../examples ../extras --config .rubocop.yml", true) 78 report "Styling Ruby:PASS" 79 end 80 81 namespace :check do 82 Dir['../**/*.rb'].each do |f| 83 filename = File.basename(f, '.rb') 84 desc "Check Style of #{filename}" 85 task filename.to_sym => ['style:clean'] do 86 report execute("rubocop #{f} --color --config .rubocop.yml", true) 87 report "Style Checked for #{f}" 88 end 89 end 90 end 91 92 desc "Fix Style of all C Code" 93 task :c do 94 run_astyle("../src/*.* ../extras/fixture/src/*.*") 95 end 96 97 namespace :c do 98 Dir['../{src,extras/**}/*.{c,h}'].each do |f| 99 filename = File.basename(f)[0..-3] 100 desc "Check Style of #{filename}" 101 task filename.to_sym do 102 run_astyle f 103 end 104 end 105 end 106 107 desc "Attempt to Autocorrect style" 108 task :auto => ['style:clean'] do 109 execute("rubocop ../auto ../examples ../extras --auto-correct --config .rubocop.yml") 110 report "Autocorrected What We Could." 111 end 112 113 desc "Update style todo list" 114 task :todo => ['style:clean'] do 115 execute("rubocop ../auto ../examples ../extras --auto-gen-config --config .rubocop.yml") 116 report "Updated Style TODO List." 117 end 118 119 task :clean do 120 File.delete(".rubocop_todo.yml") if File.exists?(".rubocop_todo.yml") 121 end 122 end 123 124 task :style => ['style:check'] 125