ceedling 0.21.0 → 0.22.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.
- 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
data/spec/spec_system_helper.rb
CHANGED
|
@@ -185,7 +185,7 @@ module CeedlingTestCases
|
|
|
185
185
|
Dir.chdir @proj_name do
|
|
186
186
|
`bundle exec ruby -S rake module:create[ponies] 2>&1`
|
|
187
187
|
output = `bundle exec ruby -S rake test:all 2>&1`
|
|
188
|
-
expect(output).to match(/
|
|
188
|
+
expect(output).to match(/No tests executed/i)
|
|
189
189
|
end
|
|
190
190
|
end
|
|
191
191
|
end
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
18
|
|
2
2
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
1.3
|
|
1
|
+
1.3.1
|
|
2
2
|
|
|
@@ -11,46 +11,8 @@
|
|
|
11
11
|
require 'rubygems'
|
|
12
12
|
require 'fileutils'
|
|
13
13
|
|
|
14
|
-
HERE = File.expand_path(File.dirname(__FILE__)) + '/'
|
|
15
|
-
|
|
16
|
-
#help text when requested
|
|
17
|
-
HELP_TEXT = [ "\nGENERATE MODULE\n-------- ------",
|
|
18
|
-
"\nUsage: ruby generate_module [options] module_name",
|
|
19
|
-
" -i\"include\" sets the path to output headers to 'include' (DEFAULT ../src)",
|
|
20
|
-
" -s\"../src\" sets the path to output source to '../src' (DEFAULT ../src)",
|
|
21
|
-
" -t\"C:/test\" sets the path to output source to 'C:/test' (DEFAULT ../test)",
|
|
22
|
-
" -p\"MCH\" sets the output pattern to MCH.",
|
|
23
|
-
" dh - driver hardware.",
|
|
24
|
-
" dih - driver interrupt hardware.",
|
|
25
|
-
" mch - model conductor hardware.",
|
|
26
|
-
" mvp - model view presenter.",
|
|
27
|
-
" src - just a single source module. (DEFAULT)",
|
|
28
|
-
" -d destroy module instead of creating it.",
|
|
29
|
-
" -u update subversion too (requires subversion command line)",
|
|
30
|
-
" -y\"my.yml\" selects a different yaml config file for module generation",
|
|
31
|
-
"" ].join("\n")
|
|
32
|
-
|
|
33
|
-
#Built in patterns
|
|
34
|
-
PATTERNS = { 'src' => {'' => { :inc => [] } },
|
|
35
|
-
'dh' => {'Driver' => { :inc => ['%1$sHardware.h'] },
|
|
36
|
-
'Hardware' => { :inc => [] }
|
|
37
|
-
},
|
|
38
|
-
'dih' => {'Driver' => { :inc => ['%1$sHardware.h', '%1$sInterrupt.h'] },
|
|
39
|
-
'Interrupt'=> { :inc => ['%1$sHardware.h'] },
|
|
40
|
-
'Hardware' => { :inc => [] }
|
|
41
|
-
},
|
|
42
|
-
'mch' => {'Model' => { :inc => [] },
|
|
43
|
-
'Conductor'=> { :inc => ['%1$sModel.h', '%1$sHardware.h'] },
|
|
44
|
-
'Hardware' => { :inc => [] }
|
|
45
|
-
},
|
|
46
|
-
'mvp' => {'Model' => { :inc => [] },
|
|
47
|
-
'Presenter'=> { :inc => ['%1$sModel.h', '%1$sView.h'] },
|
|
48
|
-
'View' => { :inc => [] }
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
14
|
#TEMPLATE_TST
|
|
53
|
-
TEMPLATE_TST
|
|
15
|
+
TEMPLATE_TST ||= %q[#include "unity.h"
|
|
54
16
|
%2$s#include "%1$s.h"
|
|
55
17
|
|
|
56
18
|
void setUp(void)
|
|
@@ -68,135 +30,229 @@ void test_%1$s_NeedToImplement(void)
|
|
|
68
30
|
]
|
|
69
31
|
|
|
70
32
|
#TEMPLATE_SRC
|
|
71
|
-
TEMPLATE_SRC
|
|
33
|
+
TEMPLATE_SRC ||= %q[%2$s#include "%1$s.h"
|
|
72
34
|
]
|
|
73
35
|
|
|
74
36
|
#TEMPLATE_INC
|
|
75
|
-
TEMPLATE_INC
|
|
37
|
+
TEMPLATE_INC ||= %q[#ifndef _%3$s_H
|
|
76
38
|
#define _%3$s_H%2$s
|
|
77
39
|
|
|
78
40
|
#endif // _%3$s_H
|
|
79
41
|
]
|
|
80
42
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
43
|
+
class UnityModuleGenerator
|
|
44
|
+
|
|
45
|
+
############################
|
|
46
|
+
def initialize(options=nil)
|
|
47
|
+
|
|
48
|
+
here = File.expand_path(File.dirname(__FILE__)) + '/'
|
|
49
|
+
|
|
50
|
+
@options = UnityModuleGenerator.default_options
|
|
51
|
+
case(options)
|
|
52
|
+
when NilClass then @options
|
|
53
|
+
when String then @options.merge!(UnityModuleGenerator.grab_config(options))
|
|
54
|
+
when Hash then @options.merge!(options)
|
|
55
|
+
else raise "If you specify arguments, it should be a filename or a hash of options"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Create default file paths if none were provided
|
|
59
|
+
@options[:path_src] = here + "../src/" if @options[:path_src].nil?
|
|
60
|
+
@options[:path_inc] = @options[:path_src] if @options[:path_inc].nil?
|
|
61
|
+
@options[:path_tst] = here + "../test/" if @options[:path_tst].nil?
|
|
62
|
+
@options[:path_src] += '/' unless (@options[:path_src][-1] == 47)
|
|
63
|
+
@options[:path_inc] += '/' unless (@options[:path_inc][-1] == 47)
|
|
64
|
+
@options[:path_tst] += '/' unless (@options[:path_tst][-1] == 47)
|
|
65
|
+
|
|
66
|
+
#Built in patterns
|
|
67
|
+
@patterns = { 'src' => {'' => { :inc => [] } },
|
|
68
|
+
'dh' => {'Driver' => { :inc => ['%1$sHardware.h'] },
|
|
69
|
+
'Hardware' => { :inc => [] }
|
|
70
|
+
},
|
|
71
|
+
'dih' => {'Driver' => { :inc => ['%1$sHardware.h', '%1$sInterrupt.h'] },
|
|
72
|
+
'Interrupt'=> { :inc => ['%1$sHardware.h'] },
|
|
73
|
+
'Hardware' => { :inc => [] }
|
|
74
|
+
},
|
|
75
|
+
'mch' => {'Model' => { :inc => [] },
|
|
76
|
+
'Conductor'=> { :inc => ['%1$sModel.h', '%1$sHardware.h'] },
|
|
77
|
+
'Hardware' => { :inc => [] }
|
|
78
|
+
},
|
|
79
|
+
'mvp' => {'Model' => { :inc => [] },
|
|
80
|
+
'Presenter'=> { :inc => ['%1$sModel.h', '%1$sView.h'] },
|
|
81
|
+
'View' => { :inc => [] }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
99
84
|
end
|
|
100
|
-
end
|
|
101
|
-
raise "ERROR: You must have a Module name specified! (use option -h for help)" if @module_name.nil?
|
|
102
|
-
|
|
103
|
-
#load yaml file if one was requested
|
|
104
|
-
if @yaml_config
|
|
105
|
-
require 'yaml'
|
|
106
|
-
cfg = YAML.load_file(HERE + @yaml_config)[:generate_module]
|
|
107
|
-
@path_src = cfg[:defaults][:path_src] if @path_src.nil?
|
|
108
|
-
@path_inc = cfg[:defaults][:path_inc] if @path_inc.nil?
|
|
109
|
-
@path_tst = cfg[:defaults][:path_tst] if @path_tst.nil?
|
|
110
|
-
@update_svn = cfg[:defaults][:update_svn] if @update_svn.nil?
|
|
111
|
-
@extra_inc = cfg[:includes]
|
|
112
|
-
@boilerplates = cfg[:boilerplates]
|
|
113
|
-
else
|
|
114
|
-
@boilerplates = {}
|
|
115
|
-
end
|
|
116
85
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
{ :ext => '.h', :path => @path_inc, :template => TEMPLATE_INC, :inc => :inc, :boilerplate => @boilerplates[:inc] },
|
|
131
|
-
{ :ext => '.c', :path => @path_tst+'Test', :template => TEMPLATE_TST, :inc => :tst, :boilerplate => @boilerplates[:tst] },
|
|
132
|
-
]
|
|
133
|
-
|
|
134
|
-
#prepare the pattern for use
|
|
135
|
-
@patterns = PATTERNS[@pattern.downcase]
|
|
136
|
-
raise "ERROR: The design pattern specified isn't one that I recognize!" if @patterns.nil?
|
|
137
|
-
|
|
138
|
-
# Assemble the path/names of the files we need to work with.
|
|
139
|
-
files = []
|
|
140
|
-
TRIAD.each do |triad|
|
|
141
|
-
@patterns.each_pair do |pattern_file, pattern_traits|
|
|
142
|
-
files << {
|
|
143
|
-
:path => "#{triad[:path]}#{@module_name}#{pattern_file}#{triad[:ext]}",
|
|
144
|
-
:name => "#{@module_name}#{pattern_file}",
|
|
145
|
-
:template => triad[:template],
|
|
146
|
-
:boilerplate => triad[:boilerplate],
|
|
147
|
-
:includes => case(triad[:inc])
|
|
148
|
-
when :src then @includes[:src] | pattern_traits[:inc].map{|f| f % [@module_name]}
|
|
149
|
-
when :inc then @includes[:inc]
|
|
150
|
-
when :tst then @includes[:tst] | pattern_traits[:inc].map{|f| "Mock#{f}"% [@module_name]}
|
|
151
|
-
end
|
|
86
|
+
############################
|
|
87
|
+
def self.default_options
|
|
88
|
+
{
|
|
89
|
+
:pattern => "src",
|
|
90
|
+
:includes =>
|
|
91
|
+
{
|
|
92
|
+
:src => [],
|
|
93
|
+
:inc => [],
|
|
94
|
+
:tst => [],
|
|
95
|
+
},
|
|
96
|
+
:update_svn => false,
|
|
97
|
+
:boilerplates => {},
|
|
98
|
+
:test_prefix => 'Test',
|
|
152
99
|
}
|
|
153
100
|
end
|
|
154
|
-
end
|
|
155
101
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
102
|
+
############################
|
|
103
|
+
def self.grab_config(config_file)
|
|
104
|
+
options = self.default_options
|
|
105
|
+
unless (config_file.nil? or config_file.empty?)
|
|
106
|
+
require 'yaml'
|
|
107
|
+
yaml_guts = YAML.load_file(config_file)
|
|
108
|
+
options.merge!(yaml_guts[:unity] || yaml_guts[:cmock])
|
|
109
|
+
raise "No :unity or :cmock section found in #{config_file}" unless options
|
|
110
|
+
end
|
|
111
|
+
return(options)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
############################
|
|
115
|
+
def files_to_operate_on(module_name, pattern=nil)
|
|
116
|
+
#create triad definition
|
|
117
|
+
prefix = @options[:test_prefix] || 'Test'
|
|
118
|
+
triad = [ { :ext => '.c', :path => @options[:path_src], :template => TEMPLATE_SRC, :inc => :src, :boilerplate => @options[:boilerplates][:src] },
|
|
119
|
+
{ :ext => '.h', :path => @options[:path_inc], :template => TEMPLATE_INC, :inc => :inc, :boilerplate => @options[:boilerplates][:inc] },
|
|
120
|
+
{ :ext => '.c', :path => @options[:path_tst]+prefix, :template => TEMPLATE_TST, :inc => :tst, :boilerplate => @options[:boilerplates][:tst] },
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
#prepare the pattern for use
|
|
124
|
+
patterns = @patterns[(pattern || @options[:pattern] || 'src').downcase]
|
|
125
|
+
raise "ERROR: The design pattern '#{pattern}' specified isn't one that I recognize!" if patterns.nil?
|
|
126
|
+
|
|
127
|
+
# Assemble the path/names of the files we need to work with.
|
|
128
|
+
files = []
|
|
129
|
+
triad.each do |triad|
|
|
130
|
+
patterns.each_pair do |pattern_file, pattern_traits|
|
|
131
|
+
files << {
|
|
132
|
+
:path => "#{triad[:path]}#{module_name}#{pattern_file}#{triad[:ext]}",
|
|
133
|
+
:name => "#{module_name}#{pattern_file}",
|
|
134
|
+
:template => triad[:template],
|
|
135
|
+
:boilerplate => triad[:boilerplate],
|
|
136
|
+
:includes => case(triad[:inc])
|
|
137
|
+
when :src then @options[:includes][:src] | pattern_traits[:inc].map{|f| f % [module_name]}
|
|
138
|
+
when :inc then @options[:includes][:inc]
|
|
139
|
+
when :tst then @options[:includes][:tst] | pattern_traits[:inc].map{|f| "Mock#{f}"% [module_name]}
|
|
140
|
+
end
|
|
141
|
+
}
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
return files
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
############################
|
|
149
|
+
def generate(module_name, pattern=nil)
|
|
150
|
+
|
|
151
|
+
files = files_to_operate_on(module_name, pattern)
|
|
152
|
+
|
|
153
|
+
#Abort if any module already exists
|
|
154
|
+
files.each do |file|
|
|
155
|
+
raise "ERROR: File #{file[:name]} already exists. Exiting." if File.exist?(file[:path])
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Create Source Modules
|
|
159
|
+
files.each_with_index do |file, i|
|
|
160
|
+
File.open(file[:path], 'w') do |f|
|
|
161
|
+
f.write(file[:boilerplate] % [file[:name]]) unless file[:boilerplate].nil?
|
|
162
|
+
f.write(file[:template] % [ file[:name],
|
|
163
|
+
file[:includes].map{|f| "#include \"#{f}\"\n"}.join,
|
|
164
|
+
file[:name].upcase ]
|
|
165
|
+
)
|
|
166
|
+
end
|
|
167
|
+
if (@options[:update_svn])
|
|
168
|
+
`svn add \"#{file[:path]}\"`
|
|
169
|
+
if $?.exitstatus == 0
|
|
170
|
+
puts "File #{file[:path]} created and added to source control"
|
|
171
|
+
else
|
|
172
|
+
puts "File #{file[:path]} created but FAILED adding to source control!"
|
|
173
|
+
end
|
|
164
174
|
else
|
|
165
|
-
|
|
166
|
-
puts "File #{file} deleted"
|
|
175
|
+
puts "File #{file[:path]} created"
|
|
167
176
|
end
|
|
168
|
-
else
|
|
169
|
-
puts "File #{file} does not exist so cannot be removed."
|
|
170
177
|
end
|
|
178
|
+
puts 'Generate Complete'
|
|
171
179
|
end
|
|
172
|
-
puts "Destroy Complete"
|
|
173
|
-
exit
|
|
174
|
-
end
|
|
175
180
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
raise "ERROR: File #{file[:name]} already exists. Exiting." if File.exist?(file[:path])
|
|
179
|
-
end
|
|
181
|
+
############################
|
|
182
|
+
def destroy(module_name, pattern=nil)
|
|
180
183
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
files_to_operate_on(module_name, pattern).each do |filespec|
|
|
185
|
+
file = filespec[:path]
|
|
186
|
+
if File.exist?(file)
|
|
187
|
+
if @options[:update_svn]
|
|
188
|
+
`svn delete \"#{file}\" --force`
|
|
189
|
+
puts "File #{file} deleted and removed from source control"
|
|
190
|
+
else
|
|
191
|
+
FileUtils.remove(file)
|
|
192
|
+
puts "File #{file} deleted"
|
|
193
|
+
end
|
|
194
|
+
else
|
|
195
|
+
puts "File #{file} does not exist so cannot be removed."
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
puts "Destroy Complete"
|
|
189
199
|
end
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
200
|
+
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
############################
|
|
204
|
+
#Handle As Command Line If Called That Way
|
|
205
|
+
if ($0 == __FILE__)
|
|
206
|
+
destroy = false
|
|
207
|
+
options = { }
|
|
208
|
+
module_name = nil
|
|
209
|
+
|
|
210
|
+
# Parse the command line parameters.
|
|
211
|
+
ARGV.each do |arg|
|
|
212
|
+
case(arg)
|
|
213
|
+
when /^-d/ then destroy = true
|
|
214
|
+
when /^-u/ then options[:update_svn] = true
|
|
215
|
+
when /^-p(\w+)/ then options[:pattern] = $1
|
|
216
|
+
when /^-s(.+)/ then options[:path_src] = $1
|
|
217
|
+
when /^-i(.+)/ then options[:path_inc] = $1
|
|
218
|
+
when /^-t(.+)/ then options[:path_tst] = $1
|
|
219
|
+
when /^-y(.+)/ then options = UnityModuleGenerator.grab_config($1)
|
|
220
|
+
when /^(\w+)/
|
|
221
|
+
raise "ERROR: You can't have more than one Module name specified!" unless module_name.nil?
|
|
222
|
+
module_name = arg
|
|
223
|
+
when /^-(h|-help)/
|
|
224
|
+
ARGV = []
|
|
225
|
+
else
|
|
226
|
+
raise "ERROR: Unknown option specified '#{arg}'"
|
|
196
227
|
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
if (!ARGV[0])
|
|
231
|
+
puts [ "\nGENERATE MODULE\n-------- ------",
|
|
232
|
+
"\nUsage: ruby generate_module [options] module_name",
|
|
233
|
+
" -i\"include\" sets the path to output headers to 'include' (DEFAULT ../src)",
|
|
234
|
+
" -s\"../src\" sets the path to output source to '../src' (DEFAULT ../src)",
|
|
235
|
+
" -t\"C:/test\" sets the path to output source to 'C:/test' (DEFAULT ../test)",
|
|
236
|
+
" -p\"MCH\" sets the output pattern to MCH.",
|
|
237
|
+
" dh - driver hardware.",
|
|
238
|
+
" dih - driver interrupt hardware.",
|
|
239
|
+
" mch - model conductor hardware.",
|
|
240
|
+
" mvp - model view presenter.",
|
|
241
|
+
" src - just a single source module. (DEFAULT)",
|
|
242
|
+
" -d destroy module instead of creating it.",
|
|
243
|
+
" -u update subversion too (requires subversion command line)",
|
|
244
|
+
" -y\"my.yml\" selects a different yaml config file for module generation",
|
|
245
|
+
"" ].join("\n")
|
|
246
|
+
exit
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
raise "ERROR: You must have a Module name specified! (use option -h for help)" if module_name.nil?
|
|
250
|
+
if (destroy)
|
|
251
|
+
UnityModuleGenerator.new(options).destroy(module_name)
|
|
197
252
|
else
|
|
198
|
-
|
|
253
|
+
UnityModuleGenerator.new(options).generate(module_name)
|
|
199
254
|
end
|
|
255
|
+
|
|
200
256
|
end
|
|
201
257
|
|
|
202
|
-
|
|
258
|
+
|
|
@@ -95,7 +95,7 @@ class UnityTestRunnerGenerator
|
|
|
95
95
|
tests_and_line_numbers = []
|
|
96
96
|
|
|
97
97
|
source_scrubbed = source.clone
|
|
98
|
-
source_scrubbed = source_scrubbed.gsub(/"[^"]*"/, '') # remove things in strings
|
|
98
|
+
source_scrubbed = source_scrubbed.gsub(/"[^"\n]*"/, '') # remove things in strings
|
|
99
99
|
source_scrubbed = source_scrubbed.gsub(/\/\/.*$/, '') # remove line comments
|
|
100
100
|
source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments
|
|
101
101
|
lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Unity Configuration
|
|
2
2
|
* As of May 11th, 2016 at ThrowTheSwitch/Unity commit 837c529
|
|
3
|
+
* Update: August 25th, 2016
|
|
3
4
|
* See Also: Unity/docs/UnityConfigurationGuide.pdf
|
|
4
5
|
*
|
|
5
6
|
* Unity is designed to run on almost anything that is targeted by a C compiler.
|
|
@@ -53,31 +54,22 @@ extern "C"
|
|
|
53
54
|
* automatically.
|
|
54
55
|
**************************************************************************** */
|
|
55
56
|
|
|
56
|
-
/* The first
|
|
57
|
-
*
|
|
58
|
-
*
|
|
57
|
+
/* The first attempt to guess your types is to check `limits.h`. Some compilers
|
|
58
|
+
* that don't support `stdint.h` could include `limits.h`. If you don't
|
|
59
|
+
* want Unity to check this file, define this to make it skip the inclusion.
|
|
60
|
+
* Unity looks at UINT_MAX & ULONG_MAX, which were available since C89.
|
|
61
|
+
*/
|
|
62
|
+
/* #define UNITY_EXCLUDE_LIMITS_H */
|
|
63
|
+
|
|
64
|
+
/* The second thing that Unity does to guess your types is check `stdint.h`.
|
|
65
|
+
* This file defines `UINTPTR_MAX`, since C99, that Unity can make use of to
|
|
66
|
+
* learn about your system. It's possible you don't want it to do this or it's
|
|
59
67
|
* possible that your system doesn't support `stdint.h`. If that's the case,
|
|
60
68
|
* you're going to want to define this. That way, Unity will know to skip the
|
|
61
69
|
* inclusion of this file and you won't be left with a compiler error.
|
|
62
70
|
*/
|
|
63
71
|
/* #define UNITY_EXCLUDE_STDINT_H */
|
|
64
72
|
|
|
65
|
-
/* The second attempt to guess your types is to check `limits.h`. Some compilers
|
|
66
|
-
* that don't support `stdint.h` could include `limits.h` instead. If you don't
|
|
67
|
-
* want Unity to check this file either, define this to make it skip the
|
|
68
|
-
* inclusion.
|
|
69
|
-
*/
|
|
70
|
-
/* #define UNITY_EXCLUDE_LIMITS_H */
|
|
71
|
-
|
|
72
|
-
/* The third and final attempt to guess your types is to use the `sizeof()`
|
|
73
|
-
* operator. Even if the first two options don't work, this one covers most
|
|
74
|
-
* cases. There _is_ a rare compiler or two out there that doesn't support
|
|
75
|
-
* `sizeof()` in the preprocessing stage, though. For these, you have the
|
|
76
|
-
* ability to disable this feature as well.
|
|
77
|
-
*/
|
|
78
|
-
/* #define UNITY_EXCLUDE_SIZEOF */
|
|
79
|
-
|
|
80
|
-
|
|
81
73
|
/* ********************** MANUAL INTEGER TYPE DEFINITION ***********************
|
|
82
74
|
* If you've disabled all of the automatic options above, you're going to have
|
|
83
75
|
* to do the configuration yourself. There are just a handful of defines that
|