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 9require 'rake' 10require 'rake/clean' 11require_relative 'rakefile_helper' 12require 'rspec/core/rake_task' 13 14TEMP_DIRS = [ 15 File.join(__dir__, 'build'), 16 File.join(__dir__, 'sandbox') 17] 18 19TEMP_DIRS.each do |dir| 20 directory(dir) 21 CLOBBER.include(dir) 22end 23 24task :prepare_for_tests => TEMP_DIRS 25 26include RakefileHelpers 27 28# Load proper GCC as defult configuration 29DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml' 30configure_toolchain(DEFAULT_CONFIG_FILE) 31 32desc "Test unity with its own unit tests" 33task :unit => [:prepare_for_tests] do 34 run_tests unit_test_files 35end 36 37desc "Test unity's helper scripts" 38task :scripts => [:prepare_for_tests] do 39 Dir['tests/test_*.rb'].each do |scriptfile| 40 require "./"+scriptfile 41 end 42end 43 44desc "Run all rspecs" 45RSpec::Core::RakeTask.new(:spec) do |t| 46 t.pattern = 'spec/**/*_spec.rb' 47end 48 49desc "Generate test summary" 50task :summary do 51 report_summary 52end 53 54desc "Build and test Unity" 55task :all => [:clean, :prepare_for_tests, :scripts, :unit, :style, :summary] 56task :default => [:clobber, :all] 57task :ci => [:no_color, :default] 58task :cruise => [:no_color, :default] 59 60desc "Load configuration" 61task :config, :config_file do |t, args| 62 configure_toolchain(args[:config_file]) 63end 64 65task :no_color do 66 $colour_output = false 67end 68 69task :verbose do 70 $verbose = true 71end 72 73namespace :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 122end 123 124task :style => ['style:check'] 125