Skip to content

Commit 1d336f6

Browse files
committed
Fix broken standardized failure output. Fix formatting issues
1 parent 54fb72f commit 1d336f6

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

auto/generate_module.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class UnityModuleGenerator
5353
def initialize(options = nil)
5454
@options = UnityModuleGenerator.default_options
5555
case options
56-
when NilClass then @options
56+
when NilClass then nil # leave @options unchanged
5757
when String then @options.merge!(UnityModuleGenerator.grab_config(options))
5858
when Hash then @options.merge!(options)
5959
else raise 'If you specify arguments, it should be a filename or a hash of options'
@@ -158,10 +158,10 @@ def files_to_operate_on(module_name, pattern = nil)
158158
template: cfg[:template],
159159
test_define: cfg[:test_define],
160160
boilerplate: cfg[:boilerplate],
161-
includes: case (cfg[:inc])
162-
when :src then (@options[:includes][:src] || []) | (pattern_traits[:inc].map { |f| format(f, module_name) })
161+
includes: case cfg[:inc]
162+
when :src then (@options[:includes][:src] || []) | pattern_traits[:inc].map { |f| format(f, module_name) }
163163
when :inc then @options[:includes][:inc] || []
164-
when :tst then (@options[:includes][:tst] || []) | (pattern_traits[:inc].map { |f| format("#{@options[:mock_prefix]}#{f}", module_name) })
164+
when :tst then (@options[:includes][:tst] || []) | pattern_traits[:inc].map { |f| format("#{@options[:mock_prefix]}#{f}", module_name) }
165165
end
166166
}
167167
end
@@ -182,7 +182,7 @@ def neutralize_filename(name, start_cap: true)
182182
############################
183183
def create_filename(part1, part2 = '')
184184
name = part2.empty? ? part1 : "#{part1}_#{part2}"
185-
case (@options[:naming])
185+
case @options[:naming]
186186
when 'bumpy' then neutralize_filename(name, start_cap: false).delete('_')
187187
when 'camel' then neutralize_filename(name).delete('_')
188188
when 'snake' then neutralize_filename(name).downcase

auto/generate_test_runner.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def initialize(options = nil)
1111
@options = UnityTestRunnerGenerator.default_options
1212
case options
1313
when NilClass
14-
@options
14+
nil # leave @options unchanged
1515
when String
1616
@options.merge!(UnityTestRunnerGenerator.grab_config(options))
1717
when Hash
@@ -72,7 +72,7 @@ def run(input_file, output_file, options = nil)
7272
source = source.force_encoding('ISO-8859-1').encode('utf-8', replace: nil)
7373
tests = find_tests(source)
7474
headers = find_includes(source)
75-
testfile_includes = @options[:use_system_files] ? (headers[:local] + headers[:system]) : (headers[:local])
75+
testfile_includes = @options[:use_system_files] ? (headers[:local] + headers[:system]) : headers[:local]
7676
used_mocks = find_mocks(testfile_includes)
7777
testfile_includes = (testfile_includes - used_mocks)
7878
testfile_includes.delete_if { |inc| inc =~ /(unity|cmock)/ }
@@ -446,7 +446,7 @@ def create_shuffle_tests(output)
446446

447447
def create_main(output, filename, tests, used_mocks)
448448
output.puts("\n/*=======MAIN=====*/")
449-
main_name = @options[:main_name].to_sym == :auto ? "main_#{filename.gsub('.c', '')}" : (@options[:main_name]).to_s
449+
main_name = @options[:main_name].to_sym == :auto ? "main_#{filename.gsub('.c', '')}" : @options[:main_name].to_s
450450
if @options[:cmdline_args]
451451
if main_name != 'main'
452452
output.puts("#{@options[:main_export_decl]} int #{main_name}(int argc, char** argv);")
@@ -462,12 +462,12 @@ def create_main(output, filename, tests, used_mocks)
462462
output.puts(" UnityPrint(\"#{filename.gsub('.c', '').gsub(/\\/, '\\\\\\')}.\");")
463463
output.puts(' UNITY_PRINT_EOL();')
464464
tests.each do |test|
465-
if (!@options[:use_param_tests]) || test[:args].nil? || test[:args].empty?
465+
if !@options[:use_param_tests] || test[:args].nil? || test[:args].empty?
466466
output.puts(" UnityPrint(\" #{test[:test]}\");")
467467
output.puts(' UNITY_PRINT_EOL();')
468468
else
469469
test[:args].each do |args|
470-
output.puts(" UnityPrint(\" #{test[:test]}(#{args.gsub('"','').gsub("\n",'')})\");")
470+
output.puts(" UnityPrint(\" #{test[:test]}(#{args.gsub('"', '').gsub("\n", '')})\");")
471471
output.puts(' UNITY_PRINT_EOL();')
472472
end
473473
end
@@ -505,7 +505,7 @@ def create_main(output, filename, tests, used_mocks)
505505
output.puts
506506
idx = 0
507507
tests.each do |test|
508-
if (!@options[:use_param_tests]) || test[:args].nil? || test[:args].empty?
508+
if !@options[:use_param_tests] || test[:args].nil? || test[:args].empty?
509509
output.puts(" run_test_params_arr[#{idx}].func = #{test[:test]};")
510510
output.puts(" run_test_params_arr[#{idx}].name = \"#{test[:test]}\";")
511511
output.puts(" run_test_params_arr[#{idx}].line_num = #{test[:line_number]};")

examples/example_3/rakefile_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def build_linker_fields
113113
def link_it(exe_name, obj_list)
114114
linker = build_linker_fields
115115
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]}"
116-
cmd_str += " #{(obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj}" }).join(' ')}"
116+
cmd_str += " #{obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj}" }.join(' ')}"
117117
cmd_str += " #{$cfg['linker']['bin_files']['prefix']} "
118118
cmd_str += $cfg['linker']['bin_files']['destination']
119119
cmd_str += exe_name + $cfg['linker']['bin_files']['extension']

src/unity.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const char UNITY_PROGMEM UnityStrFail[] = "FAIL";
3535
const char UNITY_PROGMEM UnityStrIgnore[] = "IGNORE";
3636
#endif
3737
static const char UNITY_PROGMEM UnityStrNull[] = "NULL";
38-
static const char UNITY_PROGMEM UnityStrSpacer[] = ". ";
38+
static const char UNITY_PROGMEM UnityStrSpacer[] = UNITY_FAILURE_DETAIL_SEPARATOR;
3939
static const char UNITY_PROGMEM UnityStrExpected[] = " Expected ";
4040
static const char UNITY_PROGMEM UnityStrWas[] = " Was ";
4141
static const char UNITY_PROGMEM UnityStrGt[] = " to be greater than ";

src/unity_internals.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
432432
#define UNITY_PRINT_EXEC_TIME() do { /* nothing*/ } while (0)
433433
#endif
434434

435+
#ifndef UNITY_FAILURE_DETAIL_SEPARATOR
436+
#define UNITY_FAILURE_DETAIL_SEPARATOR ":"
437+
#endif
438+
435439
/*-------------------------------------------------------
436440
* Footprint
437441
*-------------------------------------------------------*/

test/rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ namespace :style do
157157
end
158158

159159
task :clean do
160-
File.delete(".rubocop_todo.yml") if File.exists?(".rubocop_todo.yml")
160+
File.delete(".rubocop_todo.yml") if File.exist?(".rubocop_todo.yml")
161161
end
162162
end
163163

0 commit comments

Comments
 (0)