From 8f6a7ad770a9be54b5c957c3cd844d4ca1b5e883 Mon Sep 17 00:00:00 2001 From: greg-williams Date: Fri, 7 Nov 2008 14:36:10 +0000 Subject: [PATCH] - Modified generate_test_runner.rb to generate unit test main() with int main(void) instead of void main(void) in order to work with GCC - Removed unused methods from unity_test_summary.rb git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@6 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e --- auto/generate_test_runner.rb | 3 ++- auto/unity_test_summary.rb | 44 ------------------------------------ 2 files changed, 2 insertions(+), 45 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 68afb09..d20d83b 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -142,7 +142,7 @@ class UnityTestRunnerGenerator def create_main(output, module_name, tests) output.puts() output.puts() - output.puts("void main(void)") + output.puts("int main(void)") output.puts("{") output.puts("#{@tab}Unity.TestFile = \"#{module_name}\";") output.puts("#{@tab}UnityBegin();") @@ -155,6 +155,7 @@ class UnityTestRunnerGenerator output.puts() output.puts("#{@tab}UnityEnd();") + output.puts("#{@tab}return 0;") output.puts("}") end diff --git a/auto/unity_test_summary.rb b/auto/unity_test_summary.rb index b8fdb61..947f940 100644 --- a/auto/unity_test_summary.rb +++ b/auto/unity_test_summary.rb @@ -79,7 +79,6 @@ class UnityTestSummary def set_root_path(path) @root = path - puts "root_path = " + @root end protected @@ -147,49 +146,6 @@ class UnityTestSummary end def here; File.expand_path(File.dirname(__FILE__)); end - - def valid_file(fname) - raise "Can't find file #{fname}" unless File.exists?(fname) - fname - end - - def valid_dir(dirname) - raise "Can't find dir #{dirname}" unless File.exists?(dirname) - dirname - end - - def search_file_and_replace(file_name, pattern, replacement) - text = File.read(valid_file(file_name)) - text.gsub!(pattern, replacement) - File.open(file_name, "w") do |f| f.write text end - end - - def create_file_from_template(dest_file, template_file) - raise "#{dest_file} already exists; remove it first" if File.exists?(dest_file) - - template_file = valid_file("#{here}/rscript_template.rb") - template = ERB.new(File.read(template_file)) - - File.open(dest_file,"w") do |f| - f.write template.result(binding) - end - end - - def humanize(lower_case_and_underscored_word) - lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize - end - - def camelize(lower_case_and_underscored_word) - lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase } - end - - def titleize(word) - humanize(underscore(word)).gsub(/\b([a-z])/) { $1.capitalize } - end - - def underscore(camel_cased_word) - camel_cased_word.to_s.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase - end end