fix(scripts): read the defaulted args in unity_test_summary - #850
Merged
mvandervoord merged 1 commit intoSep 9, 2026
Merged
Conversation
Commit e47ac34 ("Fix default path in unity test summarizer") moved the result-directory and root-path defaults off ARGV and onto the args array that ARGV.partition produces, but both readers were left on ARGV. The defaults are therefore computed and discarded: running the summarizer with no arguments raises NoMethodError on nil, and passing only a result directory leaves root nil so failures print without the path prefix the usage text promises. Passing an option such as --verbose also shifts the option string into ARGV[0] and breaks the result glob. Read args[0] and args[1] so the assigned defaults are the values used. Add test/tests/test_unity_test_summary.rb covering both defaults; it runs under the existing test:scripts task. Signed-off-by: manon <youdie006@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🍍
What
auto/unity_test_summary.rbcomputes defaults for the result directory and the root path, then reads the un-defaultedARGVinstead of the defaultedargs. The defaults are dead.auto/unity_test_summary.rb:126-136Why this is a regression, not a design choice
The repo's own history says the defaults were meant to be read. e47ac34 ("Fix default path in unity test summarizer", Mark VanderVoord, 2015-07-21) introduced
opts, args = ARGV.partition {...}and moved both defaults fromARGVontoargs, but left both readers pointed atARGV:Since
argsis whatARGV.partitionproduced,ARGVis never mutated any more, so the two||=lines have had no effect for the whole life of that commit.Effect
Measured on a directory holding one
*.testfail:ERROR: undefined method 'tr' for nil:NilClass+ usageDir.pwd./Dir.pwd./ /root/\root\--verbose ./ERROR: No *.testpass, *.testfail, or *.testresults files found in '--verbose**/*.test*'Two of those four are the documented usage —
usageprintsresult_file_directory/androot_path/as the argument list and the script defaults both, so calling it with fewer arguments is supposed to work. The option-partitioning case is broken for the same reason: with the option string still inARGV[0], the glob is built from--verbose.Please note the one behaviour change that is not an error-to-working transition: the second row. Given only a result directory, failure lines now carry the
Dir.pwdprefix thatargs[1] ||= "#{Dir.pwd}/"assigns. That is the value the line was written to produce; I am calling it out explicitly because it changes output for a currently-working invocation. Happy to restrict the change toargs[0]alone if you would rather keep that row byte-identical.Fix
Read
args[0]andargs[1].Test
test/tests/test_unity_test_summary.rb(new) runs the CLI in a sandbox directory holding one*.testfailand asserts the two defaults. It joins the existingtest:scriptstask and uses the same$generate_test_runner_tests/$generate_test_runner_failurestallies as its neighbours, so the task's count goes 69 -> 71.Verification I ran locally (Ruby 3.2.3):
auto/unity_test_summary.rbrestored frommaster, both FAIL.:127fails onlyUnityTestSummary_DefaultsResultDirectoryToCurrentDirectory; reverting only:136fails onlyUnityTestSummary_DefaultsRootPathToCurrentDirectory. Disjoint, so each assertion pins its own line.cd test && rake ciexits 0:71 Tests 0 Failures 0 Ignoredontest:scripts,3068 TOTAL TESTS 0 TOTAL FAILURES 56 IGNOREDoverall, and:style(rubocop 1.57.2, the version CI pins) reports no offenses on../auto.The path separator in the assertion is not platform-dependent:
get_detailsends with.gsub(/\//, '\\')unconditionally (auto/unity_test_summary.rb:98), so the test builds its expectation the same way.Changelog
Added under
### Unity 2.7.2->Significant Bugfixes:perdocs/CONTRIBUTING.md:101. No issue exists for this, so the line carries only the username. Note #821 also touchesdocs/UnityChangeLog.md; if that lands first this is a one-line rebase.Assisted-by: Claude Code:claude-opus-5