1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# ==========================================
# 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]
# ==========================================
$verbose = false
$extra_paths = []
require 'rake'
require 'rake/clean'
require_relative 'rakefile_helper'
require 'rspec/core/rake_task'
TEMP_DIRS = [
File.join(__dir__, 'build'),
File.join(__dir__, 'sandbox')
]
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)
############# ALL THE SELF-TESTS WE CAN PERFORM
namespace :test do
desc "Build and test Unity"
task :all => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:fixture', 'test:memory', 'test:summary']
task :ci => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:make', 'test:fixture', 'test:memory', 'test:summary']
desc "Test unity with its own unit tests"
task :unit => [:prepare_for_tests] do
run_tests unit_test_files
end
namespace :unit do
unit_test_files.each do |f|
desc "test this unit only"
task File.basename(f,'.c').sub('test_unity_','') => [:prepare_for_tests] do
run_tests [f]
end
end
end
desc "Test unity's helper scripts"
task :scripts => [:prepare_for_tests] do
Dir['tests/test_*.rb'].each do |scriptfile|
require "./"+scriptfile
end
end
desc "Test unity triggered from make"
task :make => [:prepare_for_tests] do
run_make_tests()
end
desc "Test unity fixture addon"
task :fixture => [:prepare_for_tests] do
test_fixtures()
end
desc "Test unity memory addon"
task :memory => [:prepare_for_tests] do
test_memory()
end
desc "Test unity examples"
task :examples => [:prepare_for_tests] do
execute("cd ../examples/example_1 && make -s ci", false)
execute("cd ../examples/example_2 && make -s ci", false)
execute("cd ../examples/example_3 && rake", false)
end
desc "Run all rspecs"
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/**/*_spec.rb'
end
desc "Generate test summary"
task :summary do
report_summary
end
end
###################### Shorthand for many common tasks
task :ci => ['test:ci']
task :all => ['test:all']
task :default => [:clobber, :all]
desc "Load configuration"
task :config, :config_file do |t, args|
configure_toolchain(args[:config_file])
end
task :no_color do
$colour_output = false
end
task :verbose do
$verbose = true
end
################### CODING STYLE VALIDATION
namespace :style do
desc "Check style"
task :check do
report "\nVERIFYING RUBY STYLE"
report execute("rubocop ../auto ../examples ../extras --config .rubocop.yml", true)
report "Styling Ruby:PASS"
end
namespace :check do
Dir['../**/*.rb'].each do |f|
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")
report "Autocorrected What We Could."
end
desc "Update style todo list"
task :todo => ['style:clean'] do
execute("rubocop ../auto ../examples ../extras --auto-gen-config --config .rubocop.yml")
report "Updated Style TODO List."
end
task :clean do
File.delete(".rubocop_todo.yml") if File.exists?(".rubocop_todo.yml")
end
end
task :style => ['style:check']
|