ceedling 0.0.18 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ceedling/version.rb +2 -2
- data/lib/ceedling/version.rb.erb +1 -1
- data/new_project_template/vendor/ceedling/plugins/gcov/gcov.rb +1 -1
- data/new_project_template/vendor/ceedling/plugins/module_generator/module_generator.rake +14 -0
- data/new_project_template/vendor/ceedling/plugins/module_generator/module_generator.rb +218 -0
- data/new_project_template/vendor/ceedling/plugins/module_generator/module_generator.yml +4 -0
- data/new_project_template/vendor/ceedling/release/build.info +1 -1
- metadata +6 -3
data/lib/ceedling/version.rb
CHANGED
data/lib/ceedling/version.rb.erb
CHANGED
@@ -43,7 +43,7 @@ class Gcov < Plugin
|
|
43
43
|
@ceedling[:tool_executor].exec( compile_command[:line], compile_command[:options] )
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def post_test_fixture_execute(arg_hash)
|
47
47
|
result_file = arg_hash[:result_file]
|
48
48
|
|
49
49
|
if ((result_file =~ /#{GCOV_RESULTS_PATH}/) and (not @result_list.include?(result_file)))
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
namespace :module do
|
3
|
+
|
4
|
+
desc "Generate module (source, header and test files)"
|
5
|
+
task :create, :module_path do |t, args|
|
6
|
+
@ceedling[:module_generator].create(args[:module_path])
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Destroy module (source, header and test files)"
|
10
|
+
task :destroy, :module_path do |t, args|
|
11
|
+
@ceedling[:module_generator].create(args[:module_path], {:destroy => true})
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,218 @@
|
|
1
|
+
require 'plugin'
|
2
|
+
require 'constants'
|
3
|
+
require 'erb'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
class ModuleGenerator < Plugin
|
7
|
+
|
8
|
+
attr_reader :config
|
9
|
+
|
10
|
+
def setup
|
11
|
+
|
12
|
+
#---- New module templates
|
13
|
+
|
14
|
+
@test_template = (<<-EOS).left_margin
|
15
|
+
#include "unity.h"
|
16
|
+
<%if defined?(MODULE_GENERATOR_TEST_INCLUDES) && (MODULE_GENERATOR_TEST_INCLUDES.class == Array) && !MODULE_GENERATOR_TEST_INCLUDES.empty?%>
|
17
|
+
<%MODULE_GENERATOR_TEST_INCLUDES.each do |header_file|%>
|
18
|
+
#include "<%=header_file%>"
|
19
|
+
<%end%>
|
20
|
+
<%end%>
|
21
|
+
#include "<%=@context[:headername]%>"
|
22
|
+
|
23
|
+
void setUp(void)
|
24
|
+
{
|
25
|
+
}
|
26
|
+
|
27
|
+
void tearDown(void)
|
28
|
+
{
|
29
|
+
}
|
30
|
+
|
31
|
+
void test_<%=name%>_needs_to_be_implemented(void)
|
32
|
+
{
|
33
|
+
<%="\t"%>TEST_IGNORE_MESSAGE("Implement me!");
|
34
|
+
}
|
35
|
+
EOS
|
36
|
+
|
37
|
+
@source_template = (<<-EOS).left_margin
|
38
|
+
<%if defined?(MODULE_GENERATOR_SOURCE_INCLUDES) && (MODULE_GENERATOR_SOURCE_INCLUDES.class == Array) && !MODULE_GENERATOR_SOURCE_INCLUDES.empty?%>
|
39
|
+
<%MODULE_GENERATOR_SOURCE_INCLUDES.each do |header_file|%>
|
40
|
+
#include "<%=header_file%>"
|
41
|
+
<%end%>
|
42
|
+
<%end%>
|
43
|
+
#include "<%=@context[:headername]%>"
|
44
|
+
EOS
|
45
|
+
|
46
|
+
@header_template = (<<-EOS).left_margin
|
47
|
+
#ifndef <%=@context[:name]%>_H
|
48
|
+
#define <%=@context[:name]%>_H
|
49
|
+
|
50
|
+
<%if defined?(MODULE_GENERATOR_HEADER_INCLUDES) && (MODULE_GENERATOR_HEADER_INCLUDES.class == Array) && !MODULE_GENERATOR_HEADER_INCLUDES.empty?%>
|
51
|
+
<%MODULE_GENERATOR_HEADER_INCLUDES.each do |header_file|%>
|
52
|
+
#include "<%=header_file%>"
|
53
|
+
<%end%>
|
54
|
+
<%end%>
|
55
|
+
|
56
|
+
#endif // <%=@context[:name]%>_H
|
57
|
+
EOS
|
58
|
+
|
59
|
+
|
60
|
+
#---- New function templates
|
61
|
+
|
62
|
+
@func_test_template = (<<-EOS).left_margin
|
63
|
+
|
64
|
+
/* ------ <%=@declaration[:name]%> ------ */
|
65
|
+
|
66
|
+
void test_<%=@declaration[:name]%>_needs_to_be_implemented(void)
|
67
|
+
{
|
68
|
+
TEST_IGNORE();
|
69
|
+
}
|
70
|
+
|
71
|
+
EOS
|
72
|
+
|
73
|
+
|
74
|
+
@func_decl_template = (<<-EOS).left_margin
|
75
|
+
|
76
|
+
<%=@declaration[:returns]%> <%=@declaration[:name]%>(<%=@declaration[:arguments]%>);
|
77
|
+
|
78
|
+
EOS
|
79
|
+
|
80
|
+
@func_impl_template = (<<-EOS).left_margin
|
81
|
+
|
82
|
+
<%=@declaration[:returns]%> <%=@declaration[:name]%>(<%=@declaration[:arguments]%>)
|
83
|
+
{
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
|
87
|
+
EOS
|
88
|
+
end
|
89
|
+
|
90
|
+
def create(path, optz={})
|
91
|
+
|
92
|
+
extract_context(path, optz)
|
93
|
+
|
94
|
+
if !optz.nil? && (optz[:destroy] == true)
|
95
|
+
@ceedling[:streaminator].stdout_puts "Destroying '#{path}'..."
|
96
|
+
@files.each do |file|
|
97
|
+
if File.exist?(file[:path])
|
98
|
+
@ceedling[:tool_executor].exec("svn delete \"#{file[:path]}\" --force")
|
99
|
+
@ceedling[:streaminator].stdout_puts "File #{file[:path]} deleted and removed from source control"
|
100
|
+
else
|
101
|
+
@ceedling[:streaminator].stdout_puts "File #{file[:path]} does not exist!"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
exit
|
105
|
+
end
|
106
|
+
|
107
|
+
@ceedling[:streaminator].stdout_puts "Generating '#{path}'..."
|
108
|
+
|
109
|
+
[File.dirname(@files[0][:path]), File.dirname(@files[1][:path])].each do |dir|
|
110
|
+
makedirs(dir, {:verbose => true})
|
111
|
+
@ceedling[:tool_executor].exec("svn add \"#{dir}\"")
|
112
|
+
end
|
113
|
+
|
114
|
+
# define_name = headername.gsub(/\.h$/, '_H').upcase
|
115
|
+
|
116
|
+
@files[0][:template] = @test_template
|
117
|
+
@files[1][:template] = @source_template
|
118
|
+
@files[2][:template] = @header_template
|
119
|
+
|
120
|
+
@files.each do |file|
|
121
|
+
if File.exist?(file[:path])
|
122
|
+
@ceedling[:streaminator].stdout_puts "File #{file[:path]} already exists!"
|
123
|
+
else
|
124
|
+
File.open(file[:path], 'w') do |new_file|
|
125
|
+
new_file << ERB.new(file[:template], 0, "<>").result(binding)
|
126
|
+
end
|
127
|
+
@ceedling[:tool_executor].exec("svn add \"#{file[:path]}\"")
|
128
|
+
if $?.exitstatus == 0
|
129
|
+
@ceedling[:streaminator].stdout_puts "File #{file[:path]} created and added to source control"
|
130
|
+
else
|
131
|
+
@ceedling[:streaminator].stdout_puts "File #{file[:path]} created but FAILED adding to source control!"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
def add_function(path, optz={})
|
139
|
+
extract_context(path, optz)
|
140
|
+
|
141
|
+
parse_function_declaration(optz[:declaration])
|
142
|
+
|
143
|
+
@files[0][:template] = @func_test_template
|
144
|
+
@files[1][:template] = @func_impl_template
|
145
|
+
@files[2][:template] = @func_decl_template
|
146
|
+
|
147
|
+
@files.each do |file|
|
148
|
+
if File.exist?(file[:path])
|
149
|
+
puts "Appending content to " + file[:path] + "..."
|
150
|
+
File.open(file[:path], 'a+') do |cur_file|
|
151
|
+
cur_file << ERB.new(file[:template], 0, "<>").result(binding)
|
152
|
+
end
|
153
|
+
else
|
154
|
+
raise "Error: #{file[:path]} could not be opened!"
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
@ceedling[:streaminator].stdout_puts "Done generating new function goods!"
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
def parse_function_declaration(declaration)
|
164
|
+
p declaration
|
165
|
+
tokens = declaration.match(/^\\?\"?\s*([\w\s]+)\s+(\w+)\s*\((.*)\)\s*\"?$/)
|
166
|
+
p tokens
|
167
|
+
@declaration = {
|
168
|
+
:returns => tokens[1],
|
169
|
+
:name => tokens[2],
|
170
|
+
:arguments => tokens[3]
|
171
|
+
}
|
172
|
+
p "-"*10
|
173
|
+
p @declaration
|
174
|
+
p "-"*10
|
175
|
+
end
|
176
|
+
|
177
|
+
def extract_context(path, optz={})
|
178
|
+
if (!defined?(MODULE_GENERATOR_PROJECT_ROOT) ||
|
179
|
+
!defined?(MODULE_GENERATOR_SOURCE_ROOT) ||
|
180
|
+
!defined?(MODULE_GENERATOR_TEST_ROOT))
|
181
|
+
raise "You must have ':module_generator:project_root:', ':module_generator:source_root:' and ':module_generator:test_root:' defined in your Ceedling configuration file"
|
182
|
+
end
|
183
|
+
|
184
|
+
@context = {}
|
185
|
+
|
186
|
+
@context[:paths] = {
|
187
|
+
:base => @ceedling[:file_wrapper].get_expanded_path(MODULE_GENERATOR_PROJECT_ROOT).gsub('\\', '/').sub(/^\//, '').sub(/\/$/, ''),
|
188
|
+
:src => MODULE_GENERATOR_SOURCE_ROOT.gsub('\\', '/').sub(/^\//, '').sub(/\/$/, ''),
|
189
|
+
:test => MODULE_GENERATOR_TEST_ROOT.gsub('\\', '/').sub(/^\//, '').sub(/\/$/, '')
|
190
|
+
}
|
191
|
+
|
192
|
+
location = File.dirname(path.gsub('\\', '/'))
|
193
|
+
location.sub!(/^\/?#{@context[:paths][:base]}\/?/i, '')
|
194
|
+
location.sub!(/^\/?#{@context[:paths][:src]}\/?/i, '')
|
195
|
+
location.sub!(/^\/?#{@context[:paths][:test]}\/?/i, '')
|
196
|
+
|
197
|
+
@context[:location] = location
|
198
|
+
|
199
|
+
@context[:name] = File.basename(path).sub(/\.[ch]$/, '')
|
200
|
+
|
201
|
+
# p @context[:name]
|
202
|
+
|
203
|
+
@context[:testname] = "test_#{@context[:name]}.c"
|
204
|
+
@context[:sourcename] = "#{@context[:name]}.c"
|
205
|
+
@context[:headername] = "#{@context[:name]}.h"
|
206
|
+
|
207
|
+
# p @context
|
208
|
+
|
209
|
+
@files = [
|
210
|
+
{:path => File.join(PROJECT_ROOT, @context[:paths][:test], location, @context[:testname])},
|
211
|
+
{:path => File.join(PROJECT_ROOT, @context[:paths][:src], location, @context[:sourcename])},
|
212
|
+
{:path => File.join(PROJECT_ROOT, @context[:paths][:src], location, @context[:headername])}
|
213
|
+
]
|
214
|
+
|
215
|
+
# p @files
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
215
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 9
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.18
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Karlesky, Mark VanderVoord
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-
|
20
|
+
date: 2011-08-09 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: thor
|
@@ -249,6 +249,9 @@ files:
|
|
249
249
|
- new_project_template/vendor/ceedling/plugins/gcov/gcov.rb
|
250
250
|
- new_project_template/vendor/ceedling/plugins/gcov/readme.txt
|
251
251
|
- new_project_template/vendor/ceedling/plugins/gcov/template.erb
|
252
|
+
- new_project_template/vendor/ceedling/plugins/module_generator/module_generator.rake
|
253
|
+
- new_project_template/vendor/ceedling/plugins/module_generator/module_generator.rb
|
254
|
+
- new_project_template/vendor/ceedling/plugins/module_generator/module_generator.yml
|
252
255
|
- new_project_template/vendor/ceedling/plugins/stdout_ide_tests_report/stdout_ide_tests_report.rb
|
253
256
|
- new_project_template/vendor/ceedling/plugins/stdout_ide_tests_report/stdout_ide_tests_report.yml
|
254
257
|
- new_project_template/vendor/ceedling/plugins/stdout_pretty_tests_report/stdout_pretty_tests_report.rb
|