From be87d790c7f11c14053f57d9bad1bb3cbd5667f2 Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Mon, 28 Oct 2019 10:32:22 -0400 Subject: [PATCH] Add verifyTest option to go with resetTest. Fix docs. --- auto/generate_test_runner.rb | 11 ++++++++++- docs/UnityConfigurationGuide.md | 2 +- extras/fixture/rakefile_helper.rb | 10 +++++----- src/unity.h | 12 ++++++++++++ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index ea75f4c..bd55537 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -37,6 +37,7 @@ class UnityTestRunnerGenerator setup_name: 'setUp', teardown_name: 'tearDown', test_reset_name: 'resetTest', + test_verify_name: 'verifyTest', main_name: 'main', # set to :auto to automatically generate each time main_export_decl: '', cmdline_args: false, @@ -304,7 +305,7 @@ class UnityTestRunnerGenerator end def create_reset(output) - output.puts("\n/*=======Test Reset Option=====*/") + output.puts("\n/*=======Test Reset Options=====*/") output.puts("void #{@options[:test_reset_name]}(void);") output.puts("void #{@options[:test_reset_name]}(void)") output.puts('{') @@ -314,6 +315,13 @@ class UnityTestRunnerGenerator output.puts(' CMock_Init();') output.puts(" #{@options[:setup_name]}();") output.puts('}') + output.puts("void #{@options[:test_verify_name]}(void);") + output.puts("void #{@options[:test_verify_name]}(void)") + output.puts('{') + output.puts(' CMock_Verify();') + output.puts(' CMock_Destroy();') + output.puts(' CMock_Init();') + output.puts('}') end def create_run_test(output) @@ -463,6 +471,7 @@ if $0 == __FILE__ ' --main_name="" - redefine main func name to something else', ' --test_prefix="" - redefine test prefix from default test|spec|should', ' --test_reset_name="" - redefine resetTest func name to something else', + ' --test_verify_name="" - redefine verifyTest func name to something else', ' --suite_setup="" - code to execute for setup of entire suite', ' --suite_teardown="" - code to execute for teardown of entire suite', ' --use_param_tests=1 - enable parameterized tests (disabled by default)', diff --git a/docs/UnityConfigurationGuide.md b/docs/UnityConfigurationGuide.md index bdfb853..e8e415f 100644 --- a/docs/UnityConfigurationGuide.md +++ b/docs/UnityConfigurationGuide.md @@ -429,7 +429,7 @@ will allow you to specify how Unity will treat these assertions. #### `UNITY_SUPPORT_VARIADIC_MACROS` -This will force Unity to support variadic macros when using it's own built-in +This will force Unity to support variadic macros when using its own built-in RUN_TEST macro. This will rarely be necessary. Most often, Unity will automatically detect if the compiler supports variadic macros by checking to see if it's C99+ compatible. In the event that the compiler supports variadic macros, but is primarily diff --git a/extras/fixture/rakefile_helper.rb b/extras/fixture/rakefile_helper.rb index cad220a..91dafaf 100644 --- a/extras/fixture/rakefile_helper.rb +++ b/extras/fixture/rakefile_helper.rb @@ -55,11 +55,11 @@ def build_compiler_fields defines = if $cfg['compiler']['defines']['items'].nil? '' else - if $is_windows - decl = 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)' - else - decl = 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)' - end + decl = if $is_windows + 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)' + else + 'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)' + end squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + [decl]) end options = squash('', $cfg['compiler']['options']) diff --git a/src/unity.h b/src/unity.h index f97d141..afda5d9 100644 --- a/src/unity.h +++ b/src/unity.h @@ -40,6 +40,18 @@ void tearDown(void); void suiteSetUp(void); int suiteTearDown(int num_failures); +/*------------------------------------------------------- + * Test Reset and Verify + *-------------------------------------------------------*/ + +/* These functions are intended to be called before during tests in order + * to support complex test loops, etc. Both are NOT built into Unity. Instead + * the test runner generator will create them. resetTest will run teardown and + * setup again, verifying any end-of-test needs between. verifyTest will only + * run the verification. */ +void resetTest(void); +void verifyTest(void); + /*------------------------------------------------------- * Configuration Options *-------------------------------------------------------