Skip to content

Fix :header_file NameError in runner generator - #858

Open
APX403 wants to merge 1 commit into
ThrowTheSwitch:masterfrom
APX403:header-file-name-error
Open

APX403 wants to merge 1 commit into
ThrowTheSwitch:masterfrom
APX403:header-file-name-error

Conversation

@APX403

@APX403 APX403 commented Oct 20, 2026

Copy link
Copy Markdown

🍍

On master, generating a runner with :header_file (or --header_file= on the command line) stops with a NameError:

$ ruby auto/generate_test_runner.rb test/testdata/testRunnerGeneratorSmall.c /tmp/runner.c --header_file=/tmp/runner.h
auto/generate_test_runner.rb:120:in 'block in UnityTestRunnerGenerator#generate': undefined local variable or method 'headers' for an instance of UnityTestRunnerGenerator (NameError)

      create_h_file(output, @options[:header_file], tests, headers, used_mocks)
                                                           ^^^^^^^
	from auto/generate_test_runner.rb:119:in 'IO.open'
	from auto/generate_test_runner.rb:119:in 'UnityTestRunnerGenerator#generate'
	from auto/generate_test_runner.rb:83:in 'UnityTestRunnerGenerator#run'
	from auto/generate_test_runner.rb:689:in '<main>'

The runner has already been written at that point and includes the header, which is left empty.

4ad1309 renamed the include list in run() to headers and changed the create_h_file() call in generate() to the new name, but generate() still receives the list as its testfile_includes parameter. The call now passes that parameter again.

The new HeaderFile entry in RUNNER_TESTS generates a runner with :header_file, then builds and runs it like the other entries. 2.7.0 is not affected, so I did not add a changelog entry.

4ad1309 renamed the include list in run() to headers and changed the
create_h_file() call in generate() to match, but generate() still
receives that list as its testfile_includes parameter. Any run with
:header_file or --header_file stops with a NameError after the runner
has been written, leaving an empty header that the runner includes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant