mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 00:15:58 +01:00
Option to omit UnityBegin/UnityEnd calls in generate_test_runner
By passing --omit_begin_end=1 to generate_test_runner.rb, the script will now omit calls to UnityBegin and UnityEnd when running tests in a suite. This allows multiple suites to be executed in a row, and then have an overall summary of the tests which were executed across all suites.
This commit is contained in:
@@ -41,6 +41,7 @@ class UnityTestRunnerGenerator
|
|||||||
main_name: 'main', # set to :auto to automatically generate each time
|
main_name: 'main', # set to :auto to automatically generate each time
|
||||||
main_export_decl: '',
|
main_export_decl: '',
|
||||||
cmdline_args: false,
|
cmdline_args: false,
|
||||||
|
omit_begin_end: false,
|
||||||
use_param_tests: false
|
use_param_tests: false
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@@ -376,14 +377,19 @@ class UnityTestRunnerGenerator
|
|||||||
output.puts(' return parse_status;')
|
output.puts(' return parse_status;')
|
||||||
output.puts(' }')
|
output.puts(' }')
|
||||||
else
|
else
|
||||||
|
main_return = @options[:omit_begin_end] ? 'void' : 'int'
|
||||||
if main_name != 'main'
|
if main_name != 'main'
|
||||||
output.puts("#{@options[:main_export_decl]} int #{main_name}(void);")
|
output.puts("#{@options[:main_export_decl]} #{main_return} #{main_name}(void);")
|
||||||
end
|
end
|
||||||
output.puts("int #{main_name}(void)")
|
output.puts("#{main_return} #{main_name}(void)")
|
||||||
output.puts('{')
|
output.puts('{')
|
||||||
end
|
end
|
||||||
output.puts(' suiteSetUp();') if @options[:has_suite_setup]
|
output.puts(' suiteSetUp();') if @options[:has_suite_setup]
|
||||||
output.puts(" UnityBegin(\"#{filename.gsub(/\\/, '\\\\\\')}\");")
|
if @options[:omit_begin_end]
|
||||||
|
output.puts(" UnitySetTestFile(\"#{filename.gsub(/\\/, '\\\\\\')}\");")
|
||||||
|
else
|
||||||
|
output.puts(" UnityBegin(\"#{filename.gsub(/\\/, '\\\\\\')}\");")
|
||||||
|
end
|
||||||
tests.each do |test|
|
tests.each do |test|
|
||||||
if (!@options[:use_param_tests]) || test[:args].nil? || test[:args].empty?
|
if (!@options[:use_param_tests]) || test[:args].nil? || test[:args].empty?
|
||||||
output.puts(" run_test(#{test[:test]}, \"#{test[:test]}\", #{test[:line_number]});")
|
output.puts(" run_test(#{test[:test]}, \"#{test[:test]}\", #{test[:line_number]});")
|
||||||
@@ -398,9 +404,13 @@ class UnityTestRunnerGenerator
|
|||||||
output.puts
|
output.puts
|
||||||
output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty?
|
output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty?
|
||||||
if @options[:has_suite_teardown]
|
if @options[:has_suite_teardown]
|
||||||
output.puts(' return suiteTearDown(UnityEnd());')
|
if @options[:omit_begin_end]
|
||||||
|
output.puts(' (void) suite_teardown(0);')
|
||||||
|
else
|
||||||
|
output.puts(' return suiteTearDown(UnityEnd());')
|
||||||
|
end
|
||||||
else
|
else
|
||||||
output.puts(' return UnityEnd();')
|
output.puts(' return UnityEnd();') if not @options[:omit_begin_end]
|
||||||
end
|
end
|
||||||
output.puts('}')
|
output.puts('}')
|
||||||
end
|
end
|
||||||
@@ -473,6 +483,7 @@ if $0 == __FILE__
|
|||||||
' --suite_setup="" - code to execute for setup of entire suite',
|
' --suite_setup="" - code to execute for setup of entire suite',
|
||||||
' --suite_teardown="" - code to execute for teardown of entire suite',
|
' --suite_teardown="" - code to execute for teardown of entire suite',
|
||||||
' --use_param_tests=1 - enable parameterized tests (disabled by default)',
|
' --use_param_tests=1 - enable parameterized tests (disabled by default)',
|
||||||
|
' --omit_begin_end=1 - omit calls to UnityBegin and UnityEnd (disabled by default)',
|
||||||
' --header_file="" - path/name of test header file to generate too'].join("\n")
|
' --header_file="" - path/name of test header file to generate too'].join("\n")
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1824,6 +1824,12 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
|
|||||||
UnityConcludeTest();
|
UnityConcludeTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------*/
|
||||||
|
void UnitySetTestFile(const char* filename)
|
||||||
|
{
|
||||||
|
Unity.TestFile = filename;
|
||||||
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------*/
|
/*-----------------------------------------------*/
|
||||||
void UnityBegin(const char* filename)
|
void UnityBegin(const char* filename)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -477,6 +477,7 @@ extern struct UNITY_STORAGE_T Unity;
|
|||||||
|
|
||||||
void UnityBegin(const char* filename);
|
void UnityBegin(const char* filename);
|
||||||
int UnityEnd(void);
|
int UnityEnd(void);
|
||||||
|
void UnitySetTestFile(const char* filename);
|
||||||
void UnityConcludeTest(void);
|
void UnityConcludeTest(void);
|
||||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum);
|
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user