fix(generator): Call teardown without begin/end

The omit-begin/end path generated a snake_case call, but the custom
hook is defined as suiteTearDown. Generated C therefore failed strict
C99 compilation.

Constraint: Preserve app-owned Unity lifecycle setup and cleanup
Rejected: Rename suiteTearDown | public docs use this hook name
Confidence: high
Scope-risk: narrow
Directive: Match calls to the emitted teardown hook name
Tested: Targeted regression, strict C99 compile, host run, Ruby syntax
Not-tested: Full scripts suite beyond existing Windows EACCES
This commit is contained in:
94xhn
2026-07-15 06:21:28 +08:00
parent 76e0803cb4
commit 94672ec34b
3 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -533,7 +533,7 @@ class UnityTestRunnerGenerator
output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty?
if @options[:has_suite_teardown]
if @options[:omit_begin_end]
output.puts(' (void) suite_teardown(0);')
output.puts(' (void) suiteTearDown(0);')
else
output.puts(' return suiteTearDown(UNITY_END());')
end
+1
View File
@@ -30,6 +30,7 @@ Significant Bugfixes:
- display of failures fixed on ARM processors, particularly with arrays (#807)
- fixed each-equal assertion for memory (#797)
- fix many warnings.
- Test runner generator calls custom suite teardown when begin/end calls are omitted. @94xhn
Other:
+20
View File
@@ -1303,6 +1303,26 @@ def verify_number(expected, expression, output)
end
end
should 'GenerateSuiteTeardownWhenBeginAndEndAreOmitted' do
runner_name = OUT_FILE + 'SuiteTeardownWithoutBeginEnd_runner.c'
UnityTestRunnerGenerator.new(
:test_prefix => 'test',
:suite_teardown => ' return num_failures;',
:omit_begin_end => true,
).run('testdata/testRunnerGenerator.c', runner_name)
runner = File.read(runner_name)
correct_call = runner.include?('(void) suiteTearDown(0);')
incorrect_call = runner.include?('(void) suite_teardown(0);')
if correct_call && !incorrect_call
report 'Runner_GenerateSuiteTeardownWhenBeginAndEndAreOmitted:PASS'
else
report 'Runner_GenerateSuiteTeardownWhenBeginAndEndAreOmitted:FAIL'
$generate_test_runner_failures += 1
end
$generate_test_runner_tests += 1
end
RUNNER_TESTS.each do |testset|
basename = File.basename(testset[:testfile], C_EXTENSION)
testset_name = "Runner_#{basename}_#{testset[:name]}"