ceedling 0.24.0 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ceedling +6 -1
  3. data/docs/CeedlingPacket.md +9 -0
  4. data/lib/ceedling/generator.rb +2 -2
  5. data/lib/ceedling/generator_test_runner.rb +32 -1
  6. data/lib/ceedling/rakefile.rb +1 -1
  7. data/lib/ceedling/system_wrapper.rb +13 -10
  8. data/lib/ceedling/tool_executor.rb +2 -2
  9. data/lib/ceedling/version.rb +1 -1
  10. data/plugins/command_hooks/README.md +52 -0
  11. data/plugins/command_hooks/lib/command_hooks.rb +71 -0
  12. data/plugins/module_generator/lib/module_generator.rb +10 -4
  13. data/plugins/module_generator/module_generator.rake +2 -2
  14. data/spec/spec_system_helper.rb +16 -11
  15. data/spec/system/deployment_spec.rb +2 -2
  16. data/vendor/c_exception/vendor/unity/auto/generate_module.rb +77 -34
  17. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +1 -1
  18. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +2 -2
  19. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +3 -3
  20. data/vendor/c_exception/vendor/unity/src/unity.c +105 -105
  21. data/vendor/c_exception/vendor/unity/src/unity.h +8 -8
  22. data/vendor/c_exception/vendor/unity/src/unity_internals.h +139 -139
  23. data/vendor/c_exception/vendor/unity/test/tests/testunity.c +141 -142
  24. data/vendor/cmock/lib/cmock_generator.rb +2 -1
  25. data/vendor/cmock/test/c/TestCMockC.c +1 -1
  26. data/vendor/cmock/test/system/test_interactions/unity_64bit_support.yml +13 -13
  27. data/vendor/cmock/test/unit/cmock_generator_main_test.rb +4 -2
  28. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_module.rb +77 -34
  29. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +1 -1
  30. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +2 -2
  31. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +3 -3
  32. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.c +105 -105
  33. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.h +8 -8
  34. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity_internals.h +139 -139
  35. data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testunity.c +141 -142
  36. data/vendor/cmock/vendor/unity/auto/generate_module.rb +77 -34
  37. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +1 -1
  38. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +2 -2
  39. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +3 -3
  40. data/vendor/cmock/vendor/unity/src/unity.c +105 -105
  41. data/vendor/cmock/vendor/unity/src/unity.h +8 -8
  42. data/vendor/cmock/vendor/unity/src/unity_internals.h +139 -139
  43. data/vendor/cmock/vendor/unity/test/tests/testunity.c +141 -142
  44. data/vendor/unity/auto/generate_module.rb +77 -34
  45. data/vendor/unity/extras/fixture/src/unity_fixture.c +1 -1
  46. data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +2 -2
  47. data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +3 -3
  48. data/vendor/unity/src/unity.c +105 -105
  49. data/vendor/unity/src/unity.h +8 -8
  50. data/vendor/unity/src/unity_internals.h +139 -139
  51. data/vendor/unity/test/tests/testunity.c +141 -142
  52. metadata +4 -2
@@ -10,6 +10,7 @@
10
10
 
11
11
  require 'rubygems'
12
12
  require 'fileutils'
13
+ require 'pathname'
13
14
 
14
15
  #TEMPLATE_TST
15
16
  TEMPLATE_TST ||= %q[#include "unity.h"
@@ -35,7 +36,8 @@ TEMPLATE_SRC ||= %q[%2$s#include "%1$s.h"
35
36
 
36
37
  #TEMPLATE_INC
37
38
  TEMPLATE_INC ||= %q[#ifndef _%3$s_H
38
- #define _%3$s_H%2$s
39
+ #define _%3$s_H
40
+ %2$s
39
41
 
40
42
  #endif // _%3$s_H
41
43
  ]
@@ -65,19 +67,20 @@ class UnityModuleGenerator
65
67
 
66
68
  #Built in patterns
67
69
  @patterns = { 'src' => {'' => { :inc => [] } },
68
- 'dh' => {'Driver' => { :inc => ['%1$sHardware.h'] },
70
+ 'test'=> {'' => { :inc => [] } },
71
+ 'dh' => {'Driver' => { :inc => [create_filename('%1$s','Hardware.h')] },
69
72
  'Hardware' => { :inc => [] }
70
73
  },
71
- 'dih' => {'Driver' => { :inc => ['%1$sHardware.h', '%1$sInterrupt.h'] },
72
- 'Interrupt'=> { :inc => ['%1$sHardware.h'] },
74
+ 'dih' => {'Driver' => { :inc => [create_filename('%1$s','Hardware.h'), create_filename('%1$s','Interrupt.h')] },
75
+ 'Interrupt'=> { :inc => [create_filename('%1$s','Hardware.h')] },
73
76
  'Hardware' => { :inc => [] }
74
77
  },
75
78
  'mch' => {'Model' => { :inc => [] },
76
- 'Conductor'=> { :inc => ['%1$sModel.h', '%1$sHardware.h'] },
79
+ 'Conductor'=> { :inc => [create_filename('%1$s','Model.h'), create_filename('%1$s','Hardware.h')] },
77
80
  'Hardware' => { :inc => [] }
78
81
  },
79
82
  'mvp' => {'Model' => { :inc => [] },
80
- 'Presenter'=> { :inc => ['%1$sModel.h', '%1$sView.h'] },
83
+ 'Presenter'=> { :inc => [create_filename('%1$s','Model.h'), create_filename('%1$s','View.h')] },
81
84
  'View' => { :inc => [] }
82
85
  }
83
86
  }
@@ -96,6 +99,7 @@ class UnityModuleGenerator
96
99
  :update_svn => false,
97
100
  :boilerplates => {},
98
101
  :test_prefix => 'Test',
102
+ :mock_prefix => 'Mock',
99
103
  }
100
104
  end
101
105
 
@@ -113,30 +117,42 @@ class UnityModuleGenerator
113
117
 
114
118
  ############################
115
119
  def files_to_operate_on(module_name, pattern=nil)
120
+ #strip any leading path information from the module name and save for later
121
+ subfolder = File.dirname(module_name)
122
+ module_name = File.basename(module_name)
123
+
116
124
  #create triad definition
117
125
  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] },
126
+ triad = [ { :ext => '.c', :path => @options[:path_src], :prefix => "", :template => TEMPLATE_SRC, :inc => :src, :boilerplate => @options[:boilerplates][:src] },
127
+ { :ext => '.h', :path => @options[:path_inc], :prefix => "", :template => TEMPLATE_INC, :inc => :inc, :boilerplate => @options[:boilerplates][:inc] },
128
+ { :ext => '.c', :path => @options[:path_tst], :prefix => prefix, :template => TEMPLATE_TST, :inc => :tst, :boilerplate => @options[:boilerplates][:tst] },
121
129
  ]
122
130
 
123
131
  #prepare the pattern for use
124
- patterns = @patterns[(pattern || @options[:pattern] || 'src').downcase]
132
+ pattern = (pattern || @options[:pattern] || 'src').downcase
133
+ patterns = @patterns[pattern]
125
134
  raise "ERROR: The design pattern '#{pattern}' specified isn't one that I recognize!" if patterns.nil?
126
135
 
136
+ #single file patterns (currently just 'test') can reject the other parts of the triad
137
+ if (pattern == 'test')
138
+ triad.reject!{|v| v[:inc] != :tst }
139
+ end
140
+
127
141
  # Assemble the path/names of the files we need to work with.
128
142
  files = []
129
- triad.each do |triad|
143
+ triad.each do |cfg|
130
144
  patterns.each_pair do |pattern_file, pattern_traits|
145
+ submodule_name = create_filename(module_name, pattern_file)
146
+ filename = cfg[:prefix] + submodule_name + cfg[:ext]
131
147
  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]}
148
+ :path => (Pathname.new("#{cfg[:path]}#{subfolder}") + filename).cleanpath,
149
+ :name => submodule_name,
150
+ :template => cfg[:template],
151
+ :boilerplate => cfg[:boilerplate],
152
+ :includes => case(cfg[:inc])
153
+ when :src then (@options[:includes][:src] || []) | pattern_traits[:inc].map{|f| f % [module_name]}
154
+ when :inc then (@options[:includes][:inc] || [])
155
+ when :tst then (@options[:includes][:tst] || []) | pattern_traits[:inc].map{|f| "#{@options[:mock_prefix]}#{f}" % [module_name]}
140
156
  end
141
157
  }
142
158
  end
@@ -145,6 +161,27 @@ class UnityModuleGenerator
145
161
  return files
146
162
  end
147
163
 
164
+ ############################
165
+ def create_filename(part1, part2="")
166
+ if part2.empty?
167
+ case(@options[:naming])
168
+ when 'bumpy' then part1
169
+ when 'camel' then part1
170
+ when 'snake' then part1.downcase
171
+ when 'caps' then part1.upcase
172
+ else part1.downcase
173
+ end
174
+ else
175
+ case(@options[:naming])
176
+ when 'bumpy' then part1 + part2
177
+ when 'camel' then part1 + part2
178
+ when 'snake' then part1.downcase + "_" + part2.downcase
179
+ when 'caps' then part1.upcase + "_" + part2.upcase
180
+ else part1.downcase + "_" + part2.downcase
181
+ end
182
+ end
183
+ end
184
+
148
185
  ############################
149
186
  def generate(module_name, pattern=nil)
150
187
 
@@ -157,8 +194,9 @@ class UnityModuleGenerator
157
194
 
158
195
  # Create Source Modules
159
196
  files.each_with_index do |file, i|
197
+ FileUtils.mkdir_p(File.dirname(file[:path]), :verbose => false) # Create the path first if necessary.
160
198
  File.open(file[:path], 'w') do |f|
161
- f.write(file[:boilerplate] % [file[:name]]) unless file[:boilerplate].nil?
199
+ f.write("#{file[:boilerplate]}\n" % [file[:name]]) unless file[:boilerplate].nil?
162
200
  f.write(file[:template] % [ file[:name],
163
201
  file[:includes].map{|f| "#include \"#{f}\"\n"}.join,
164
202
  file[:name].upcase ]
@@ -210,13 +248,14 @@ if ($0 == __FILE__)
210
248
  # Parse the command line parameters.
211
249
  ARGV.each do |arg|
212
250
  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)
251
+ when /^-d/ then destroy = true
252
+ when /^-u/ then options[:update_svn] = true
253
+ when /^-p\"?(\w+)\"?/ then options[:pattern] = $1
254
+ when /^-s\"?(.+)\"?/ then options[:path_src] = $1
255
+ when /^-i\"?(.+)\"?/ then options[:path_inc] = $1
256
+ when /^-t\"?(.+)\"?/ then options[:path_tst] = $1
257
+ when /^-n\"?(.+)\"?/ then options[:naming] = $1
258
+ when /^-y\"?(.+)\"?/ then options = UnityModuleGenerator.grab_config($1)
220
259
  when /^(\w+)/
221
260
  raise "ERROR: You can't have more than one Module name specified!" unless module_name.nil?
222
261
  module_name = arg
@@ -234,12 +273,18 @@ if ($0 == __FILE__)
234
273
  " -s\"../src\" sets the path to output source to '../src' (DEFAULT ../src)",
235
274
  " -t\"C:/test\" sets the path to output source to 'C:/test' (DEFAULT ../test)",
236
275
  " -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)",
276
+ " dh - driver hardware.",
277
+ " dih - driver interrupt hardware.",
278
+ " mch - model conductor hardware.",
279
+ " mvp - model view presenter.",
280
+ " src - just a source module, header and test. (DEFAULT)",
281
+ " test - just a test file.",
242
282
  " -d destroy module instead of creating it.",
283
+ " -n\"camel\" sets the file naming convention.",
284
+ " bumpy - BumpyCaseFilenames.",
285
+ " camel - camelCaseFilenames.",
286
+ " snake - snake_case_filenames. (DEFAULT)",
287
+ " caps - CAPS_CASE_FILENAMES.",
243
288
  " -u update subversion too (requires subversion command line)",
244
289
  " -y\"my.yml\" selects a different yaml config file for module generation",
245
290
  "" ].join("\n")
@@ -254,5 +299,3 @@ if ($0 == __FILE__)
254
299
  end
255
300
 
256
301
  end
257
-
258
-
@@ -9,7 +9,7 @@
9
9
  #include "unity_fixture.h"
10
10
  #include "unity_internals.h"
11
11
 
12
- struct _UnityFixture UnityFixture;
12
+ struct UNITY_FIXTURE_T UnityFixture;
13
13
 
14
14
  /* If you decide to use the function pointer approach.
15
15
  * Build with -D UNITY_OUTPUT_CHAR=outputChar and include <stdio.h>
@@ -13,14 +13,14 @@ extern "C"
13
13
  {
14
14
  #endif
15
15
 
16
- struct _UnityFixture
16
+ struct UNITY_FIXTURE_T
17
17
  {
18
18
  int Verbose;
19
19
  unsigned int RepeatCount;
20
20
  const char* NameFilter;
21
21
  const char* GroupFilter;
22
22
  };
23
- extern struct _UnityFixture UnityFixture;
23
+ extern struct UNITY_FIXTURE_T UnityFixture;
24
24
 
25
25
  typedef void unityfunction(void);
26
26
  void UnityTestRunner(unityfunction* setup,
@@ -138,8 +138,8 @@ TEST(UnityFixture, FreeNULLSafety)
138
138
 
139
139
  TEST(UnityFixture, ConcludeTestIncrementsFailCount)
140
140
  {
141
- _U_UINT savedFails = Unity.TestFailures;
142
- _U_UINT savedIgnores = Unity.TestIgnores;
141
+ UNITY_UINT savedFails = Unity.TestFailures;
142
+ UNITY_UINT savedIgnores = Unity.TestIgnores;
143
143
  UnityOutputCharSpy_Enable(1);
144
144
  Unity.CurrentTestFailed = 1;
145
145
  UnityConcludeFixtureTest(); /* Resets TestFailed for this test to pass */
@@ -301,7 +301,7 @@ TEST(UnityCommandOptions, GroupOrNameFilterWithoutStringFails)
301
301
 
302
302
  TEST(UnityCommandOptions, GroupFilterReallyFilters)
303
303
  {
304
- _U_UINT saved = Unity.NumberOfTests;
304
+ UNITY_UINT saved = Unity.NumberOfTests;
305
305
  TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(4, unknownCommand));
306
306
  UnityIgnoreTest(NULL, "non-matching", NULL);
307
307
  TEST_ASSERT_EQUAL(saved, Unity.NumberOfTests);