rakefile 3.0 KB
Newer Older
M
Mark VanderVoord 已提交
1 2 3 4 5 6
# ==========================================
#   Unity Project - A Test Framework for C
#   Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
#   [Released under MIT License. Please refer to license.txt for details]
# ==========================================

7
$verbose = false
M
Mark VanderVoord 已提交
8 9 10

require 'rake'
require 'rake/clean'
J
John Lindgren 已提交
11
require_relative 'rakefile_helper'
12
require 'rspec/core/rake_task'
M
Mark VanderVoord 已提交
13 14

TEMP_DIRS = [
J
John Lindgren 已提交
15 16
	File.join(__dir__, 'build'),
	File.join(__dir__, 'sandbox')
M
Mark VanderVoord 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
]

TEMP_DIRS.each do |dir|
  directory(dir)
  CLOBBER.include(dir)
end

task :prepare_for_tests => TEMP_DIRS

include RakefileHelpers

# Load proper GCC as defult configuration
DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'
configure_toolchain(DEFAULT_CONFIG_FILE)

desc "Test unity with its own unit tests"
task :unit => [:prepare_for_tests] do
34
  run_tests unit_test_files
M
Mark VanderVoord 已提交
35 36 37 38 39 40 41 42 43
end

desc "Test unity's helper scripts"
task :scripts => [:prepare_for_tests] do
  Dir['tests/test_*.rb'].each do |scriptfile|
    require "./"+scriptfile
  end
end

44 45 46 47 48
desc "Run all rspecs"
RSpec::Core::RakeTask.new(:spec) do |t|
  t.pattern = 'spec/**/*_spec.rb'
end

M
Mark VanderVoord 已提交
49 50 51 52 53 54
desc "Generate test summary"
task :summary do
  report_summary
end

desc "Build and test Unity"
55
task :all => [:clean, :prepare_for_tests, :scripts, :unit, :style, :summary]
M
Mark VanderVoord 已提交
56 57 58 59 60 61 62 63 64 65 66 67
task :default => [:clobber, :all]
task :ci => [:no_color, :default]
task :cruise => [:no_color, :default]

desc "Load configuration"
task :config, :config_file do |t, args|
  configure_toolchain(args[:config_file])
end

task :no_color do
  $colour_output = false
end
68 69 70 71

task :verbose do
  $verbose = true
end
72 73 74 75

namespace :style do
  desc "Check style"
  task :check do
76 77
    report "\nVERIFYING RUBY STYLE"
    report execute("rubocop ../auto ../examples ../extras --config .rubocop.yml", true)
78
    report "Styling Ruby:PASS"
79 80
  end

81 82
  namespace :check do
    Dir['../**/*.rb'].each do |f|
83 84 85
      filename = File.basename(f, '.rb')
      desc "Check Style of #{filename}"
      task filename.to_sym => ['style:clean'] do
86
        report execute("rubocop #{f} --color --config .rubocop.yml", true)
87
        report "Style Checked for #{f}"
88 89 90 91
      end
    end
  end

92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
  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

107
  desc "Attempt to Autocorrect style"
108 109
  task :auto  => ['style:clean'] do
    execute("rubocop ../auto ../examples ../extras --auto-correct --config .rubocop.yml")
110 111 112 113
    report "Autocorrected What We Could."
  end

  desc "Update style todo list"
114 115
  task :todo  => ['style:clean'] do
    execute("rubocop ../auto ../examples ../extras --auto-gen-config --config .rubocop.yml")
116 117
    report "Updated Style TODO List."
  end
118 119 120 121

  task :clean do
    File.delete(".rubocop_todo.yml") if File.exists?(".rubocop_todo.yml")
  end
122 123 124
end

task :style => ['style:check']