1313require 'pathname'
1414
1515# TEMPLATE_TST
16- TEMPLATE_TST ||= '#ifdef TEST
16+ TEMPLATE_TST ||= '#ifdef %5$s
1717
1818#include "unity.h"
1919
3232 TEST_IGNORE_MESSAGE("Need to Implement %1$s");
3333}
3434
35- #endif // TEST
35+ #endif // %5$s
3636' . freeze
3737
3838# TEMPLATE_SRC
@@ -108,7 +108,8 @@ def self.default_options
108108 update_svn : false ,
109109 boilerplates : { } ,
110110 test_prefix : 'Test' ,
111- mock_prefix : 'Mock'
111+ mock_prefix : 'Mock' ,
112+ test_define : 'TEST'
112113 }
113114 end
114115
@@ -134,7 +135,7 @@ def files_to_operate_on(module_name, pattern = nil)
134135 prefix = @options [ :test_prefix ] || 'Test'
135136 triad = [ { ext : '.c' , path : @options [ :path_src ] , prefix : '' , template : TEMPLATE_SRC , inc : :src , boilerplate : @options [ :boilerplates ] [ :src ] } ,
136137 { ext : '.h' , path : @options [ :path_inc ] , prefix : '' , template : TEMPLATE_INC , inc : :inc , boilerplate : @options [ :boilerplates ] [ :inc ] } ,
137- { ext : '.c' , path : @options [ :path_tst ] , prefix : prefix , template : TEMPLATE_TST , inc : :tst , boilerplate : @options [ :boilerplates ] [ :tst ] } ]
138+ { ext : '.c' , path : @options [ :path_tst ] , prefix : prefix , template : TEMPLATE_TST , inc : :tst , boilerplate : @options [ :boilerplates ] [ :tst ] , test_define : @options [ :test_define ] } ]
138139
139140 # prepare the pattern for use
140141 pattern = ( pattern || @options [ :pattern ] || 'src' ) . downcase
@@ -154,6 +155,7 @@ def files_to_operate_on(module_name, pattern = nil)
154155 path : ( Pathname . new ( "#{ cfg [ :path ] } #{ subfolder } " ) + filename ) . cleanpath ,
155156 name : submodule_name ,
156157 template : cfg [ :template ] ,
158+ test_define : cfg [ :test_define ]
157159 boilerplate : cfg [ :boilerplate ] ,
158160 includes : case ( cfg [ :inc ] )
159161 when :src then ( @options [ :includes ] [ :src ] || [ ] ) | ( pattern_traits [ :inc ] . map { |f | format ( f , module_name ) } )
@@ -212,7 +214,8 @@ def generate(module_name, pattern = nil)
212214 f . write ( file [ :template ] % [ file [ :name ] ,
213215 file [ :includes ] . map { |ff | "#include \" #{ ff } \" \n " } . join ,
214216 file [ :name ] . upcase . tr ( '-' , '_' ) ,
215- file [ :name ] . tr ( '-' , '_' ) ] )
217+ file [ :name ] . tr ( '-' , '_' ) ,
218+ file [ :test_define ] ] )
216219 end
217220 if @options [ :update_svn ]
218221 `svn add \" #{ file [ :path ] } \" `
0 commit comments