From b3bc196ab3aef3061b16b636e9144ad400bba3d2 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Tue, 21 Jun 2016 10:01:34 -0400 Subject: [PATCH] making new flush routines work under all defined conditions. --- auto/generate_module.rb | 32 ++++++++++++++++---------------- src/unity.c | 9 +++------ src/unity_internals.h | 10 ++++++++-- test/targets/clang_strict.yml | 2 ++ 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/auto/generate_module.rb b/auto/generate_module.rb index 3db1a98..8e233ec 100644 --- a/auto/generate_module.rb +++ b/auto/generate_module.rb @@ -2,7 +2,7 @@ # Unity Project - A Test Framework for C # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams # [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================== # This script creates all the files with start code necessary for a new module. # A simple module only requires a source file, header file, and test file. @@ -32,20 +32,20 @@ HELP_TEXT = [ "\nGENERATE MODULE\n-------- ------", #Built in patterns PATTERNS = { 'src' => {'' => { :inc => [] } }, - 'dh' => {'Driver' => { :inc => ['%1$sHardware.h'] }, - 'Hardware' => { :inc => [] } + 'dh' => {'Driver' => { :inc => ['%1$sHardware.h'] }, + 'Hardware' => { :inc => [] } }, - 'dih' => {'Driver' => { :inc => ['%1$sHardware.h', '%1$sInterrupt.h'] }, + 'dih' => {'Driver' => { :inc => ['%1$sHardware.h', '%1$sInterrupt.h'] }, 'Interrupt'=> { :inc => ['%1$sHardware.h'] }, - 'Hardware' => { :inc => [] } + 'Hardware' => { :inc => [] } }, - 'mch' => {'Model' => { :inc => [] }, + 'mch' => {'Model' => { :inc => [] }, 'Conductor'=> { :inc => ['%1$sModel.h', '%1$sHardware.h'] }, - 'Hardware' => { :inc => [] } + 'Hardware' => { :inc => [] } }, - 'mvp' => {'Model' => { :inc => [] }, + 'mvp' => {'Model' => { :inc => [] }, 'Presenter'=> { :inc => ['%1$sModel.h', '%1$sView.h'] }, - 'View' => { :inc => [] } + 'View' => { :inc => [] } } } @@ -63,7 +63,7 @@ void tearDown(void) void test_%1$s_NeedToImplement(void) { - TEST_IGNORE(); + TEST_IGNORE_MESSAGE("Need to Implement %1$s"); } ] @@ -91,7 +91,7 @@ ARGV.each do |arg| when /^(\w+)/ raise "ERROR: You can't have more than one Module name specified!" unless @module_name.nil? @module_name = arg - when /^-(h|-help)/ + when /^-(h|-help)/ puts HELP_TEXT exit else @@ -126,7 +126,7 @@ end @includes.merge!(@extra_inc) unless @extra_inc.nil? #create triad definition -TRIAD = [ { :ext => '.c', :path => @path_src, :template => TEMPLATE_SRC, :inc => :src, :boilerplate => @boilerplates[:src] }, +TRIAD = [ { :ext => '.c', :path => @path_src, :template => TEMPLATE_SRC, :inc => :src, :boilerplate => @boilerplates[:src] }, { :ext => '.h', :path => @path_inc, :template => TEMPLATE_INC, :inc => :inc, :boilerplate => @boilerplates[:inc] }, { :ext => '.c', :path => @path_tst+'Test', :template => TEMPLATE_TST, :inc => :tst, :boilerplate => @boilerplates[:tst] }, ] @@ -159,7 +159,7 @@ if @destroy file = filespec[:path] if File.exist?(file) if @update_svn - `svn delete \"#{file}\" --force` + `svn delete \"#{file}\" --force` puts "File #{file} deleted and removed from source control" else FileUtils.remove(file) @@ -182,13 +182,13 @@ end files.each_with_index do |file, i| File.open(file[:path], 'w') do |f| f.write(file[:boilerplate] % [file[:name]]) unless file[:boilerplate].nil? - f.write(file[:template] % [ file[:name], - file[:includes].map{|f| "#include \"#{f}\"\n"}.join, + f.write(file[:template] % [ file[:name], + file[:includes].map{|f| "#include \"#{f}\"\n"}.join, file[:name].upcase ] ) end if (@update_svn) - `svn add \"#{file[:path]}\"` + `svn add \"#{file[:path]}\"` if $?.exitstatus == 0 puts "File #{file[:path]} created and added to source control" else diff --git a/src/unity.c b/src/unity.c index 4a99208..a93bf86 100644 --- a/src/unity.c +++ b/src/unity.c @@ -9,10 +9,7 @@ /* If omitted from header, declare overrideable prototypes here so they're ready for use */ #ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION -int UNITY_OUTPUT_CHAR(int); -#endif -#ifdef UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION -int UNITY_OUTPUT_FLUSH(void); +void UNITY_OUTPUT_CHAR(int); #endif /* Helpful macros for us to use here */ @@ -338,7 +335,7 @@ void UnityConcludeTest(void) Unity.CurrentTestFailed = 0; Unity.CurrentTestIgnored = 0; UNITY_PRINT_EOL(); - UNITY_OUTPUT_FLUSH(); + UNITY_FLUSH_CALL(); } /*-----------------------------------------------*/ @@ -1298,7 +1295,7 @@ int UnityEnd(void) #endif } UNITY_PRINT_EOL(); - UNITY_OUTPUT_FLUSH(); + UNITY_FLUSH_CALL(); UNITY_OUTPUT_COMPLETE(); return (int)(Unity.TestFailures); } diff --git a/src/unity_internals.h b/src/unity_internals.h index 03d196f..e46c7e2 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -299,9 +299,9 @@ extern void UNITY_OUTPUT_CHAR(int); #endif #ifndef UNITY_OUTPUT_FLUSH -/* Default to using putchar, which is defined in stdio.h */ +/* Default to using fflush, which is defined in stdio.h */ #include -#define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) +#define UNITY_OUTPUT_FLUSH (void)fflush(stdout) #else /* If defined as something else, make sure we declare it here so it's ready for use */ #ifndef UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION @@ -309,6 +309,12 @@ extern void UNITY_OUTPUT_FLUSH(void); #endif #endif +#ifndef UNITY_OUTPUT_FLUSH +#define UNITY_FLUSH_CALL() +#else +#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH +#endif + #ifndef UNITY_PRINT_EOL #define UNITY_PRINT_EOL() UNITY_OUTPUT_CHAR('\n') #endif diff --git a/test/targets/clang_strict.yml b/test/targets/clang_strict.yml index 3ce354e..221424d 100644 --- a/test/targets/clang_strict.yml +++ b/test/targets/clang_strict.yml @@ -60,6 +60,8 @@ compiler: - UNITY_INCLUDE_DOUBLE - UNITY_SUPPORT_TEST_CASES - UNITY_SUPPORT_64 + - UNITY_OUTPUT_FLUSH + - UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION object_files: prefix: '-o' extension: '.o'