From a07d07cd1a2726b6d798f5b0bb3d9123dd63ab59 Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Tue, 1 Aug 2017 21:49:38 +0300 Subject: [PATCH 1/5] Allow specifying custom header declaration The user can specify UNITY_OUTPUT_CHAR_HEADER_DECLARATION and UNITY_OUTPUT_FLUSH_HEADER_DECLARATION when he would like to declare UNITY_OUTPUT_CHAT or UNITY_OUTPUT_FLUSH respectivly --- examples/unity_config.h | 10 ++++++---- src/unity_internals.h | 14 +++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/examples/unity_config.h b/examples/unity_config.h index 355d9bf..da3c2af 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -201,10 +201,12 @@ * `stdout` option. You decide to route your test result output to a custom * serial `RS232_putc()` function you wrote like thus: */ -/* #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) */ -/* #define UNITY_OUTPUT_FLUSH() RS232_flush() */ -/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */ -/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */ +/* #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) */ +/* #define UNITY_OUTPUT_CHAR_HEADER_DECLARATION RS232_putc(int) */ +/* #define UNITY_OUTPUT_FLUSH() RS232_flush() */ +/* #define UNITY_OUTPUT_FLUSH_HEADER_DECLARATION RS232_flush(void) */ +/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */ +/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */ /* For some targets, Unity can make the otherwise required `setUp()` and * `tearDown()` functions optional. This is a nice convenience for test writers diff --git a/src/unity_internals.h b/src/unity_internals.h index c08db95..9504451 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -246,8 +246,8 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT; #define UNITY_OUTPUT_CHAR(a) (void)putchar(a) #else /* If defined as something else, make sure we declare it here so it's ready for use */ - #ifndef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION -extern void UNITY_OUTPUT_CHAR(int); + #ifdef UNITY_OUTPUT_CHAR_HEADER_DECLARATION +extern void UNITY_OUTPUT_CHAR_HEADER_DECLARATION; #endif #endif @@ -255,22 +255,22 @@ extern void UNITY_OUTPUT_CHAR(int); #ifdef UNITY_USE_FLUSH_STDOUT /* We want to use the stdout flush utility */ #include -#define UNITY_OUTPUT_FLUSH (void)fflush(stdout) +#define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) #else /* We've specified nothing, therefore flush should just be ignored */ -#define UNITY_OUTPUT_FLUSH +#define UNITY_OUTPUT_FLUSH() #endif #else /* We've defined flush as something else, so make sure we declare it here so it's ready for use */ -#ifndef UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION -extern void UNITY_OUTPUT_FLUSH(void); +#ifdef UNITY_OUTPUT_FLUSH_HEADER_DECLARATION +extern void UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION; #endif #endif #ifndef UNITY_OUTPUT_FLUSH #define UNITY_FLUSH_CALL() #else -#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH +#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH() #endif #ifndef UNITY_PRINT_EOL From 59182c4ea963103915a4e0290edfee18e2ef3e7c Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Tue, 1 Aug 2017 22:56:52 +0300 Subject: [PATCH 2/5] Add UNITY_OUTPUT_CHAR_HEADER_DECLARATION to tests Makefile defines --- test/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Makefile b/test/Makefile index 03b59bc..9de7a49 100644 --- a/test/Makefile +++ b/test/Makefile @@ -14,6 +14,7 @@ CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstri #DEBUG = -O0 -g CFLAGS += $(DEBUG) DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy +DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\) DEFINES += -D UNITY_SUPPORT_64 -D UNITY_INCLUDE_DOUBLE SRC = ../src/unity.c tests/testunity.c build/testunityRunner.c INC_DIR = -I ../src From b3de931d697e40987d180730a441f9c7ce062784 Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Tue, 1 Aug 2017 23:36:13 +0300 Subject: [PATCH 3/5] Add UNITY_OUTPUT_CHAR_HEADER_DECLARATION to fixture tests Makefile defines --- extras/fixture/test/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/extras/fixture/test/Makefile b/extras/fixture/test/Makefile index 80e124f..e6c6255 100644 --- a/extras/fixture/test/Makefile +++ b/extras/fixture/test/Makefile @@ -6,6 +6,7 @@ endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror CFLAGS += $(DEBUG) DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar +DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\) SRC = ../src/unity_fixture.c \ ../../../src/unity.c \ unity_fixture_Test.c \ From ad373024f28b1efbfca6f5178f9ee4c612d5b4d6 Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Fri, 4 Aug 2017 14:40:34 +0300 Subject: [PATCH 4/5] Add UNITY_OUTPUT_CHAR_HEADER_DECLARATION to tests rakefile_helper.rb --- test/rakefile_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rakefile_helper.rb b/test/rakefile_helper.rb index be5bf3e..1fd60c5 100644 --- a/test/rakefile_helper.rb +++ b/test/rakefile_helper.rb @@ -91,7 +91,7 @@ module RakefileHelpers defines = if $cfg['compiler']['defines']['items'].nil? '' else - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + inject_defines) + squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\)'] + inject_defines) end options = squash('', $cfg['compiler']['options']) includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) From e56378e4376fe1764cc42ad05f1a42f24cb11404 Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Fri, 4 Aug 2017 14:43:14 +0300 Subject: [PATCH 5/5] Add UNITY_OUTPUT_CHAR_HEADER_DECLARATION to fixture tests rakefile_helper.rb --- extras/fixture/rakefile_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb index 5aa8e56..c45b239 100644 --- a/extras/fixture/rakefile_helper.rb +++ b/extras/fixture/rakefile_helper.rb @@ -53,7 +53,7 @@ module RakefileHelpers defines = if $cfg['compiler']['defines']['items'].nil? '' else - squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar']) + squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)']) end options = squash('', $cfg['compiler']['options']) includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])