Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions auto/generate_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
require 'pathname'

# TEMPLATE_TST
TEMPLATE_TST ||= '#ifdef TEST
TEMPLATE_TST ||= '#ifdef %5$s

#include "unity.h"

Expand All @@ -32,7 +32,7 @@
TEST_IGNORE_MESSAGE("Need to Implement %1$s");
}

#endif // TEST
#endif // %5$s
'.freeze

# TEMPLATE_SRC
Expand Down Expand Up @@ -108,7 +108,8 @@ def self.default_options
update_svn: false,
boilerplates: {},
test_prefix: 'Test',
mock_prefix: 'Mock'
mock_prefix: 'Mock',
test_define: 'TEST'
}
end

Expand All @@ -134,7 +135,7 @@ def files_to_operate_on(module_name, pattern = nil)
prefix = @options[:test_prefix] || 'Test'
triad = [{ ext: '.c', path: @options[:path_src], prefix: '', template: TEMPLATE_SRC, inc: :src, boilerplate: @options[:boilerplates][:src] },
{ ext: '.h', path: @options[:path_inc], prefix: '', template: TEMPLATE_INC, inc: :inc, boilerplate: @options[:boilerplates][:inc] },
{ ext: '.c', path: @options[:path_tst], prefix: prefix, template: TEMPLATE_TST, inc: :tst, boilerplate: @options[:boilerplates][:tst] }]
{ ext: '.c', path: @options[:path_tst], prefix: prefix, template: TEMPLATE_TST, inc: :tst, test_define: @options[:test_define], boilerplate: @options[:boilerplates][:tst] }]

# prepare the pattern for use
pattern = (pattern || @options[:pattern] || 'src').downcase
Expand All @@ -154,6 +155,7 @@ def files_to_operate_on(module_name, pattern = nil)
path: (Pathname.new("#{cfg[:path]}#{subfolder}") + filename).cleanpath,
name: submodule_name,
template: cfg[:template],
test_define: cfg[:test_define],
boilerplate: cfg[:boilerplate],
includes: case (cfg[:inc])
when :src then (@options[:includes][:src] || []) | (pattern_traits[:inc].map { |f| format(f, module_name) })
Expand Down Expand Up @@ -212,7 +214,8 @@ def generate(module_name, pattern = nil)
f.write(file[:template] % [file[:name],
file[:includes].map { |ff| "#include \"#{ff}\"\n" }.join,
file[:name].upcase.gsub(/-/, '_'),
file[:name].gsub(/-/, '_')])
file[:name].gsub(/-/, '_'),
file[:test_define]])
end
if @options[:update_svn]
`svn add \"#{file[:path]}\"`
Expand Down