rakefile 3.0 KB

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