ceedling 0.21.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/bin/ceedling +3 -5
- data/ceedling-0.21.0.gem +0 -0
- data/ceedling.gemspec +1 -0
- data/lib/ceedling/configurator.rb +7 -1
- data/lib/ceedling/configurator_plugins.rb +21 -21
- data/lib/ceedling/generator_test_runner.rb +3 -46
- data/lib/ceedling/setupinator.rb +1 -0
- data/lib/ceedling/version.rb +4 -4
- data/plugins/module_generator/lib/module_generator.rb +14 -127
- data/plugins/module_generator/module_generator.rake +15 -3
- data/spec/spec_system_helper.rb +1 -1
- data/vendor/c_exception/release/build.info +1 -1
- data/vendor/c_exception/release/version.info +1 -1
- data/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -146
- data/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +1 -1
- data/vendor/c_exception/vendor/unity/examples/example_1/makefile +1 -1
- data/vendor/c_exception/vendor/unity/examples/example_2/makefile +1 -1
- data/vendor/c_exception/vendor/unity/examples/unity_config.h +11 -19
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
- data/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +7 -13
- data/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
- data/vendor/c_exception/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
- data/vendor/c_exception/vendor/unity/release/build.info +1 -1
- data/vendor/c_exception/vendor/unity/release/version.info +1 -1
- data/vendor/c_exception/vendor/unity/src/unity.c +45 -72
- data/vendor/c_exception/vendor/unity/src/unity.h +3 -4
- data/vendor/c_exception/vendor/unity/src/unity_internals.h +71 -109
- data/vendor/c_exception/vendor/unity/test/Makefile +25 -13
- data/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +0 -1
- data/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +0 -1
- data/vendor/c_exception/vendor/unity/test/tests/testparameterized.c +11 -5
- data/vendor/c_exception/vendor/unity/test/tests/testunity.c +32 -29
- data/vendor/cmock/docs/CMock_Summary.md +4 -0
- data/vendor/cmock/lib/cmock_config.rb +7 -2
- data/vendor/cmock/lib/cmock_generator.rb +9 -1
- data/vendor/cmock/release/build.info +1 -1
- data/vendor/cmock/release/version.info +1 -1
- data/vendor/cmock/test/unit/cmock_generator_main_test.rb +7 -0
- data/vendor/cmock/vendor/c_exception/release/build.info +1 -1
- data/vendor/cmock/vendor/c_exception/release/version.info +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -146
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/makefile +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/makefile +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/unity_config.h +11 -19
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +7 -13
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/release/build.info +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/release/version.info +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.c +45 -72
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.h +3 -4
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity_internals.h +71 -109
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/Makefile +25 -13
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +0 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +0 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testparameterized.c +11 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testunity.c +32 -29
- data/vendor/cmock/vendor/unity/auto/generate_module.rb +202 -146
- data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +1 -1
- data/vendor/cmock/vendor/unity/examples/example_1/makefile +1 -1
- data/vendor/cmock/vendor/unity/examples/example_2/makefile +1 -1
- data/vendor/cmock/vendor/unity/examples/unity_config.h +11 -19
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
- data/vendor/cmock/vendor/unity/extras/fixture/test/Makefile +7 -13
- data/vendor/cmock/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
- data/vendor/cmock/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
- data/vendor/cmock/vendor/unity/release/build.info +1 -1
- data/vendor/cmock/vendor/unity/release/version.info +1 -1
- data/vendor/cmock/vendor/unity/src/unity.c +45 -72
- data/vendor/cmock/vendor/unity/src/unity.h +3 -4
- data/vendor/cmock/vendor/unity/src/unity_internals.h +71 -109
- data/vendor/cmock/vendor/unity/test/Makefile +25 -13
- data/vendor/cmock/vendor/unity/test/targets/gcc_32.yml +0 -1
- data/vendor/cmock/vendor/unity/test/targets/gcc_64.yml +0 -1
- data/vendor/cmock/vendor/unity/test/tests/testparameterized.c +11 -5
- data/vendor/cmock/vendor/unity/test/tests/testunity.c +32 -29
- data/vendor/unity/auto/generate_module.rb +202 -146
- data/vendor/unity/auto/generate_test_runner.rb +1 -1
- data/vendor/unity/examples/example_1/makefile +1 -1
- data/vendor/unity/examples/example_2/makefile +1 -1
- data/vendor/unity/examples/unity_config.h +11 -19
- data/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
- data/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
- data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
- data/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
- data/vendor/unity/extras/fixture/test/Makefile +7 -13
- data/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
- data/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
- data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
- data/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
- data/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
- data/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
- data/vendor/unity/release/build.info +1 -1
- data/vendor/unity/release/version.info +1 -1
- data/vendor/unity/src/unity.c +45 -72
- data/vendor/unity/src/unity.h +3 -4
- data/vendor/unity/src/unity_internals.h +71 -109
- data/vendor/unity/test/Makefile +25 -13
- data/vendor/unity/test/targets/gcc_32.yml +0 -1
- data/vendor/unity/test/targets/gcc_64.yml +0 -1
- data/vendor/unity/test/tests/testparameterized.c +11 -5
- data/vendor/unity/test/tests/testunity.c +32 -29
- metadata +17 -6
- data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
- data/vendor/cmock/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
- data/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa78f4edc69d44667b522fa8d6774b5cba64bd1d
|
4
|
+
data.tar.gz: a00d68217deb360e479bd5689c87facd4dedfbe0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ae2e3a928a4d7bce315ec4670d2fbe2d214f94fb17738d3e02e294687b80f3157cabbc9c94cbbf4339ad29edd933b31a063bfebceabcdd820bc6be7dfe154d1
|
7
|
+
data.tar.gz: baae9e8307806303c0f5fbf511102930a772e7c574e1e69662cc858f840aa5a57f3ecbfce47ea8c1b1e263507507be22b0900226814dd3ff39514c03f492a6e6
|
data/Gemfile
CHANGED
data/bin/ceedling
CHANGED
@@ -164,7 +164,7 @@ else
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
-
rescue
|
167
|
+
rescue LoadError
|
168
168
|
|
169
169
|
begin
|
170
170
|
|
@@ -180,7 +180,7 @@ else
|
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
|
-
rescue
|
183
|
+
rescue LoadError
|
184
184
|
|
185
185
|
#if neither of these libraries were available, we can just shell out to the command and collect results
|
186
186
|
def spawn_command(cmd, &block)
|
@@ -269,7 +269,6 @@ else
|
|
269
269
|
end
|
270
270
|
|
271
271
|
#run rake and capture all the output
|
272
|
-
okay_to_print = !(options[:pretend_we_are_gtest])
|
273
272
|
options[:cmd] = if (options[:pretest].nil? || options[:pretest].empty?)
|
274
273
|
"rake #{options[:args]}"
|
275
274
|
else
|
@@ -277,8 +276,7 @@ else
|
|
277
276
|
end
|
278
277
|
spawn_command(options[:cmd]) do |stdout|
|
279
278
|
stdout.each do |line|
|
280
|
-
|
281
|
-
if (okay_to_print)
|
279
|
+
if (!options[:pretend_we_are_gtest] || (line.match(/^\[.*\]/)) || (line.match(/\d+ FAILED TESTS/)))
|
282
280
|
f.puts(line) if (options[:outfile])
|
283
281
|
if (options[:args].strip == "-T")
|
284
282
|
line.gsub!(/(?<!\w)rake(?!\w)/,'ceedling')
|
data/ceedling-0.21.0.gem
ADDED
Binary file
|
data/ceedling.gemspec
CHANGED
@@ -79,6 +79,11 @@ class Configurator
|
|
79
79
|
end
|
80
80
|
|
81
81
|
|
82
|
+
def populate_unity_defaults(config)
|
83
|
+
unity = config[:unity] || {}
|
84
|
+
@runner_config = unity.merge(@runner_config || config[:test_runner] || {})
|
85
|
+
end
|
86
|
+
|
82
87
|
def populate_cmock_defaults(config)
|
83
88
|
# cmock has its own internal defaults handling, but we need to set these specific values
|
84
89
|
# so they're present for the build environment to access;
|
@@ -106,7 +111,8 @@ class Configurator
|
|
106
111
|
cmock[:includes].uniq!
|
107
112
|
end
|
108
113
|
|
109
|
-
@runner_config = cmock.merge(config[:test_runner] || {})
|
114
|
+
@runner_config = cmock.merge(@runner_config || config[:test_runner] || {})
|
115
|
+
|
110
116
|
@cmock_builder.manufacture(cmock)
|
111
117
|
end
|
112
118
|
|
@@ -10,13 +10,13 @@ class ConfiguratorPlugins
|
|
10
10
|
@script_plugins = []
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
|
14
14
|
def add_load_paths(config)
|
15
15
|
plugin_paths = {}
|
16
|
-
|
16
|
+
|
17
17
|
config[:plugins][:load_paths].each do |root|
|
18
18
|
@system_wrapper.add_load_path( root ) if ( not @file_wrapper.directory_listing( File.join( root, '*.rb' ) ).empty? )
|
19
|
-
|
19
|
+
|
20
20
|
config[:plugins][:enabled].each do |plugin|
|
21
21
|
path = File.join(root, plugin, "lib")
|
22
22
|
|
@@ -26,15 +26,15 @@ class ConfiguratorPlugins
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
return plugin_paths
|
31
31
|
end
|
32
|
-
|
33
|
-
|
32
|
+
|
33
|
+
|
34
34
|
# gather up and return .rake filepaths that exist on-disk
|
35
35
|
def find_rake_plugins(config)
|
36
36
|
plugins_with_path = []
|
37
|
-
|
37
|
+
|
38
38
|
config[:plugins][:load_paths].each do |root|
|
39
39
|
config[:plugins][:enabled].each do |plugin|
|
40
40
|
rake_plugin_path = File.join(root, plugin, "#{plugin}.rake")
|
@@ -44,7 +44,7 @@ class ConfiguratorPlugins
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
return plugins_with_path
|
49
49
|
end
|
50
50
|
|
@@ -56,21 +56,21 @@ class ConfiguratorPlugins
|
|
56
56
|
script_plugin_path = File.join(root, plugin, "lib", "#{plugin}.rb")
|
57
57
|
|
58
58
|
|
59
|
-
if @file_wrapper.exist?(script_plugin_path)
|
60
|
-
@script_plugins << plugin
|
59
|
+
if @file_wrapper.exist?(script_plugin_path)
|
60
|
+
@script_plugins << plugin
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
66
|
-
return @script_plugins
|
65
|
+
|
66
|
+
return @script_plugins
|
67
67
|
end
|
68
|
-
|
69
|
-
|
68
|
+
|
69
|
+
|
70
70
|
# gather up and return configuration .yml filepaths that exist on-disk
|
71
71
|
def find_config_plugins(config)
|
72
72
|
plugins_with_path = []
|
73
|
-
|
73
|
+
|
74
74
|
config[:plugins][:load_paths].each do |root|
|
75
75
|
config[:plugins][:enabled].each do |plugin|
|
76
76
|
config_plugin_path = File.join(root, plugin, "config", "#{plugin}.yml")
|
@@ -81,15 +81,15 @@ class ConfiguratorPlugins
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
84
|
-
|
85
|
-
return plugins_with_path
|
84
|
+
|
85
|
+
return plugins_with_path
|
86
86
|
end
|
87
87
|
|
88
|
-
|
88
|
+
|
89
89
|
# gather up and return default .yml filepaths that exist on-disk
|
90
90
|
def find_plugin_defaults(config)
|
91
91
|
defaults_with_path = []
|
92
|
-
|
92
|
+
|
93
93
|
config[:plugins][:load_paths].each do |root|
|
94
94
|
config[:plugins][:enabled].each do |plugin|
|
95
95
|
default_path = File.join(root, plugin, 'config', 'defaults.yml')
|
@@ -100,7 +100,7 @@ class ConfiguratorPlugins
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
return defaults_with_path
|
103
|
+
return defaults_with_path
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
end
|
@@ -4,52 +4,9 @@ class GeneratorTestRunner
|
|
4
4
|
constructor :configurator, :file_path_utils, :file_wrapper
|
5
5
|
|
6
6
|
def find_test_cases(test_file)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# if we don't have preprocessor assistance, do some basic preprocessing of our own
|
12
|
-
if (not @configurator.project_use_test_preprocessor)
|
13
|
-
source = @file_wrapper.read(test_file)
|
14
|
-
|
15
|
-
# remove line comments
|
16
|
-
source = source.gsub(/\/\/.*$/, '')
|
17
|
-
# remove block comments
|
18
|
-
source = source.gsub(/\/\*.*?\*\//m, '')
|
19
|
-
|
20
|
-
# treat preprocessor directives as a logical line
|
21
|
-
lines = source.split(/(^\s*\#.*$) | (;|\{|\}) /x) # match ;, {, and } as end of lines
|
22
|
-
# otherwise, read the preprocessed file raw
|
23
|
-
else
|
24
|
-
lines = @file_wrapper.read( @file_path_utils.form_preprocessed_file_filepath(test_file) ).split(/;|\{|\}/)
|
25
|
-
end
|
26
|
-
|
27
|
-
# step 1. find test functions in (possibly preprocessed) file
|
28
|
-
# (note that lines are not broken up at end of lines)
|
29
|
-
lines.each do |line|
|
30
|
-
if (line =~ /^\s*void\s+((T|t)est.*)\s*\(\s*(void)?\s*\)/m)
|
31
|
-
tests << ($1.strip)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# step 2. associate test functions with line numbers in (non-preprocessed) original file
|
36
|
-
# (note that this time we must scan file contents broken up by end of lines)
|
37
|
-
raw_lines = @file_wrapper.read(test_file).split("\n")
|
38
|
-
raw_index = 0
|
39
|
-
|
40
|
-
tests.each do |test|
|
41
|
-
raw_lines[raw_index..-1].each_with_index do |line, index|
|
42
|
-
# test function might be declared across lines; look for it by its name followed
|
43
|
-
# by a few tell-tale signs
|
44
|
-
if (line =~ /#{test}\s*($|\(|\()/)
|
45
|
-
raw_index += (index + 1)
|
46
|
-
tests_and_line_numbers << {:test => test, :line_number => raw_index}
|
47
|
-
break
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
return tests_and_line_numbers
|
7
|
+
require 'generate_test_runner.rb'
|
8
|
+
@test_runner_generator ||= UnityTestRunnerGenerator.new( @configurator.get_runner_config )
|
9
|
+
return @test_runner_generator.find_tests(@file_wrapper.read(test_file))
|
53
10
|
end
|
54
11
|
|
55
12
|
def generate(module_name, runner_filepath, test_cases, mock_list, test_file_includes=[])
|
data/lib/ceedling/setupinator.rb
CHANGED
@@ -21,6 +21,7 @@ class Setupinator
|
|
21
21
|
# note: configurator modifies the cmock section of the hash with a couple defaults to tie
|
22
22
|
# project together - the modified hash is used to build cmock object
|
23
23
|
@ceedling[:configurator].populate_defaults( config_hash )
|
24
|
+
@ceedling[:configurator].populate_unity_defaults( config_hash )
|
24
25
|
@ceedling[:configurator].populate_cmock_defaults( config_hash )
|
25
26
|
@ceedling[:configurator].find_and_merge_plugins( config_hash )
|
26
27
|
@ceedling[:configurator].tools_setup( config_hash )
|
data/lib/ceedling/version.rb
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
module Ceedling
|
3
3
|
module Version
|
4
4
|
# @private
|
5
|
-
GEM = "0.
|
5
|
+
GEM = "0.22.0"
|
6
6
|
# @private
|
7
7
|
CEEDLING = GEM
|
8
8
|
# @private
|
9
|
-
CEXCEPTION = "1.3.
|
9
|
+
CEXCEPTION = "1.3.1"
|
10
10
|
# @private
|
11
|
-
CMOCK = "2.4.
|
11
|
+
CMOCK = "2.4.3"
|
12
12
|
# @private
|
13
|
-
UNITY = "2.
|
13
|
+
UNITY = "2.4.0"
|
14
14
|
end
|
15
15
|
end
|
@@ -7,139 +7,26 @@ class ModuleGenerator < Plugin
|
|
7
7
|
|
8
8
|
attr_reader :config
|
9
9
|
|
10
|
-
def
|
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
|
10
|
+
def create(module_name, optz={})
|
36
11
|
|
37
|
-
|
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
|
12
|
+
require "generate_module.rb" #From Unity Scripts
|
45
13
|
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
end
|
59
|
-
|
60
|
-
def create(path, optz={})
|
61
|
-
|
62
|
-
extract_context(path, optz)
|
63
|
-
|
64
|
-
if !optz.nil? && (optz[:destroy] == true)
|
65
|
-
@ceedling[:streaminator].stdout_puts "Destroying '#{path}'..."
|
66
|
-
@files.each do |file|
|
67
|
-
if File.exist?(file[:path])
|
68
|
-
File.delete(file[:path])
|
69
|
-
@ceedling[:streaminator].stdout_puts "File #{file[:path]} deleted"
|
70
|
-
else
|
71
|
-
@ceedling[:streaminator].stdout_puts "File #{file[:path]} does not exist!"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
exit
|
14
|
+
if ((!optz.nil?) && (optz[:destroy]))
|
15
|
+
UnityModuleGenerator.new( divine_options(optz) ).destroy(module_name)
|
16
|
+
else
|
17
|
+
UnityModuleGenerator.new( divine_options(optz) ).generate(module_name)
|
75
18
|
end
|
76
|
-
|
77
|
-
@ceedling[:streaminator].stdout_puts "Generating '#{path}'..."
|
78
|
-
|
79
|
-
[File.dirname(@files[0][:path]), File.dirname(@files[1][:path])].each do |dir|
|
80
|
-
makedirs(dir, {:verbose => true})
|
81
|
-
end
|
82
|
-
|
83
|
-
# define_name = headername.gsub(/\.h$/, '_H').upcase
|
84
|
-
|
85
|
-
@files[0][:template] = @test_template
|
86
|
-
@files[1][:template] = @source_template
|
87
|
-
@files[2][:template] = @header_template
|
88
|
-
|
89
|
-
@files.each do |file|
|
90
|
-
if File.exist?(file[:path])
|
91
|
-
@ceedling[:streaminator].stdout_puts "File #{file[:path]} already exists!"
|
92
|
-
else
|
93
|
-
File.open(file[:path], 'w') do |new_file|
|
94
|
-
new_file << ERB.new(file[:template], 0, "<>").result(binding)
|
95
|
-
end
|
96
|
-
@ceedling[:streaminator].stdout_puts "File #{file[:path]} created"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
19
|
end
|
101
|
-
|
20
|
+
|
102
21
|
private
|
103
|
-
|
104
|
-
def extract_context(path, optz={})
|
105
|
-
if (!defined?(MODULE_GENERATOR_PROJECT_ROOT) ||
|
106
|
-
!defined?(MODULE_GENERATOR_SOURCE_ROOT) ||
|
107
|
-
!defined?(MODULE_GENERATOR_TEST_ROOT))
|
108
|
-
raise "You must have ':module_generator:project_root:', ':module_generator:source_root:' and ':module_generator:test_root:' defined in your Ceedling configuration file"
|
109
|
-
end
|
110
|
-
|
111
|
-
@context = {}
|
112
22
|
|
113
|
-
|
114
|
-
|
115
|
-
:
|
116
|
-
:
|
23
|
+
def divine_options(optz={})
|
24
|
+
{
|
25
|
+
:path_src => MODULE_GENERATOR_SOURCE_ROOT.gsub('\\', '/').sub(/^\//, '').sub(/\/$/, ''),
|
26
|
+
:path_inc => MODULE_GENERATOR_SOURCE_ROOT.gsub('\\', '/').sub(/^\//, '').sub(/\/$/, ''),
|
27
|
+
:path_tst => MODULE_GENERATOR_TEST_ROOT.gsub('\\', '/').sub(/^\//, '').sub(/\/$/, ''),
|
28
|
+
:pattern => optz[:pattern],
|
117
29
|
}
|
118
|
-
|
119
|
-
location = File.dirname(path.gsub('\\', '/'))
|
120
|
-
location.sub!(/^\/?#{Regexp.escape(@context[:paths][:base])}\/?/i, '')
|
121
|
-
location.sub!(/^\/?#{Regexp.escape(@context[:paths][:src])}\/?/i, '')
|
122
|
-
location.sub!(/^\/?#{Regexp.escape(@context[:paths][:test])}\/?/i, '')
|
123
|
-
|
124
|
-
@context[:location] = location
|
125
|
-
|
126
|
-
@context[:name] = File.basename(path).sub(/\.[ch]$/, '')
|
127
|
-
|
128
|
-
# p @context[:name]
|
129
|
-
|
130
|
-
@context[:testname] = "test_#{@context[:name]}.c"
|
131
|
-
@context[:sourcename] = "#{@context[:name]}.c"
|
132
|
-
@context[:headername] = "#{@context[:name]}.h"
|
133
|
-
|
134
|
-
# p @context
|
135
|
-
|
136
|
-
@files = [
|
137
|
-
{:path => File.join(MODULE_GENERATOR_PROJECT_ROOT, @context[:paths][:test], location, @context[:testname])},
|
138
|
-
{:path => File.join(MODULE_GENERATOR_PROJECT_ROOT, @context[:paths][:src], location, @context[:sourcename])},
|
139
|
-
{:path => File.join(MODULE_GENERATOR_PROJECT_ROOT, @context[:paths][:src], location, @context[:headername])}
|
140
|
-
]
|
141
|
-
|
142
|
-
# p @files
|
143
30
|
end
|
144
|
-
|
31
|
+
|
145
32
|
end
|
@@ -2,13 +2,25 @@
|
|
2
2
|
namespace :module do
|
3
3
|
|
4
4
|
desc "Generate module (source, header and test files)"
|
5
|
-
|
6
|
-
args[:module_path]
|
5
|
+
task :create, :module_path do |t, args|
|
6
|
+
files = [args[:module_path]] + (args.extras || [])
|
7
|
+
optz = {}
|
8
|
+
["dh", "dih", "mch", "mvp"].each do |pat|
|
9
|
+
p = files.delete(pat)
|
10
|
+
optz[:pattern] = p unless p.nil?
|
11
|
+
end
|
12
|
+
files.each {|v| @ceedling[:module_generator].create(v, optz) }
|
7
13
|
end
|
8
14
|
|
9
15
|
desc "Destroy module (source, header and test files)"
|
10
16
|
task :destroy, :module_path do |t, args|
|
11
|
-
args[:module_path]
|
17
|
+
files = [args[:module_path]] + (args.extras || [])
|
18
|
+
optz = { :destroy => true }
|
19
|
+
["dh", "dih", "mch", "mvp"].each do |pat|
|
20
|
+
p = files.delete(pat)
|
21
|
+
optz[:pattern] = p unless p.nil?
|
22
|
+
end
|
23
|
+
files.each {|v| @ceedling[:module_generator].create(v, optz) }
|
12
24
|
end
|
13
25
|
|
14
26
|
end
|