Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions auto/unity_test_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def parse_test_summary(summary)
begin
# look in the specified or current directory for result files
args[0] ||= './'
targets = "#{ARGV[0].tr('\\', '/')}**/*.test*"
targets = "#{args[0].tr('\\', '/')}**/*.test*"
results = Dir[targets]

raise "No *.testpass, *.testfail, or *.testresults files found in '#{targets}'" if results.empty?
Expand All @@ -133,7 +133,7 @@ def parse_test_summary(summary)

# set the root path
args[1] ||= "#{Dir.pwd}/"
uts.root = ARGV[1]
uts.root = args[1]

# run the summarizer
puts uts.run
Expand Down
1 change: 1 addition & 0 deletions docs/UnityChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Prior to 2008, the project was an internal project and not released to the publi
Significant Bugfixes:

- Default `UNITY_INCLUDE_EXEC_TIME` macros compile as ISO C99, are statement-safe, and accept `-Wsign-conversion` (#838)
- `unity_test_summary.rb` honors its own default result directory and root path again. @youdie006

### Unity 2.7.0 (July 2026)

Expand Down
58 changes: 58 additions & 0 deletions test/tests/test_unity_test_summary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# =========================================================================
# Unity - A Test Framework for C
# ThrowTheSwitch.org
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================

require 'fileutils'
require_relative '../../auto/colour_reporter'

# the 'test:scripts' rake task tallies these, so only initialize them if we are loaded first
$generate_test_runner_tests ||= 0
$generate_test_runner_failures ||= 0
$unity_test_summary_failures = 0

SUMMARY_SCRIPT = File.expand_path('../../auto/unity_test_summary.rb', __dir__)
SUMMARY_SANDBOX = File.expand_path('../sandbox/test_summary', __dir__)
SUMMARY_RESULTS = <<~RESULTS
test/test_a.c:12:test_thing:PASS
test/test_b.c:34:test_broken:FAIL: Expected 1 Was 2
test/test_c.c:56:test_skipped:IGNORE: not ready

-----------------------
3 Tests 1 Failures 1 Ignored
RESULTS

def summary_test(name, passed)
if passed
report "#{name}:PASS"
else
report "#{name}:FAIL"
$generate_test_runner_failures += 1
$unity_test_summary_failures += 1
end
$generate_test_runner_tests += 1
end

FileUtils.rm_rf(SUMMARY_SANDBOX)
FileUtils.mkdir_p(SUMMARY_SANDBOX)
File.write(File.join(SUMMARY_SANDBOX, 'test_sample.testfail'), SUMMARY_RESULTS)

begin
Dir.chdir(SUMMARY_SANDBOX) do
# with no arguments at all, the result files are looked for in the current directory
output = `ruby "#{SUMMARY_SCRIPT}" 2>&1`
summary_test('UnityTestSummary_DefaultsResultDirectoryToCurrentDirectory',
$?.success? && output.include?('3 TOTAL TESTS 1 TOTAL FAILURES 1 IGNORED'))

# with only a result directory given, the root path defaults to the current directory
expected = "#{Dir.pwd}/test/test_b.c:34".tr('/', '\\')
output = `ruby "#{SUMMARY_SCRIPT}" ./ 2>&1`
summary_test('UnityTestSummary_DefaultsRootPathToCurrentDirectory', output.include?(expected))
end
ensure
FileUtils.rm_rf(SUMMARY_SANDBOX)
end

raise "There were #{$unity_test_summary_failures} failures while testing unity_test_summary.rb" if $unity_test_summary_failures > 0
Loading