OCUnit2JUnit icon indicating copy to clipboard operation
OCUnit2JUnit copied to clipboard

Error when handling nil values in handle_end_test_suite

Open ghost opened this issue 7 years ago • 0 comments

We keep running into the following error sporadically in our build. 17:02:38 /usr/local/lib/ruby/gems/2.3.0/gems/ocunit2junit-1.4/bin/ocunit2junit:160:in `-': nil can't be coerced into Fixnum (TypeError) 17:02:38 from /usr/local/lib/ruby/gems/2.3.0/gems/ocunit2junit-1.4/bin/ocunit2junit:160:in `handle_end_test_suite' 17:02:38 from /usr/local/lib/ruby/gems/2.3.0/gems/ocunit2junit-1.4/bin/ocunit2junit:99:in `block in parse_input' 17:02:38 from /usr/local/lib/ruby/gems/2.3.0/gems/ocunit2junit-1.4/bin/ocunit2junit:55:in `each' 17:02:38 from /usr/local/lib/ruby/gems/2.3.0/gems/ocunit2junit-1.4/bin/ocunit2junit:55:in `each' 17:02:38 from /usr/local/lib/ruby/gems/2.3.0/gems/ocunit2junit-1.4/bin/ocunit2junit:55:in `parse_input' 17:02:38 from /usr/local/lib/ruby/gems/2.3.0/gems/ocunit2junit-1.4/bin/ocunit2junit:43:in `initialize' 17:02:38 from /usr/local/lib/ruby/gems/2.3.0/gems/ocunit2junit-1.4/bin/ocunit2junit:236:in `new' 17:02:38 from /usr/local/lib/ruby/gems/2.3.0/gems/ocunit2junit-1.4/bin/ocunit2junit:236:in `<top (required)>' 17:02:38 from /usr/local/bin/ocunit2junit:23:in `load' 17:02:38 from /usr/local/bin/ocunit2junit:23:in `<main>'

It happens when end_time is nil in handle_end_test_suite. def handle_end_test_suite(test_name,end_time) unless @ended_current_test_suite current_file = File.open("#{TEST_REPORTS_FOLDER}/TEST-#{test_name}.xml", 'w') host_name = string_to_xml Socket.gethostname test_name = string_to_xml test_name test_duration = (end_time - @cur_start_time).to_s total_tests = @total_failed_test_cases + @total_passed_test_cases

We have tried to resolve this by adding a if statement before the arithmetic operation. end_time=0 if end_time.nil?

will this work or break something else?

ghost avatar Jun 07 '17 09:06 ghost