Skip to content

Commit

Permalink
fixed bugs introduced by cli refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandervoord committed Apr 10, 2024
1 parent 9edef24 commit 8e374b9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
27 changes: 12 additions & 15 deletions lib/ceedling/debugger_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ def gdb_output_collector(shell_result)

# Concatenate test results from single test runs, which not crash
# to create proper output for further parser
if test_output =~ /([\S]+):(\d+):([\S]+):(IGNORE|PASS|FAIL:)(.*)/
test_output = "#{Regexp.last_match(1)}:#{Regexp.last_match(2)}:#{Regexp.last_match(3)}:#{Regexp.last_match(4)}#{Regexp.last_match(5)}"
m = test_output.match? /([\S]+):(\d+):([\S]+):(IGNORE|PASS|FAIL:)(.*)/
if m
test_output = "#{m[1]}:#{m[2]}:#{m[3]}:#{m[4]}#{m[5]}"
if test_output =~ /:PASS/
test_case_result_collector[:passed] += 1
elsif test_output =~ /:IGNORE/
Expand All @@ -137,27 +138,23 @@ def gdb_output_collector(shell_result)
end
else
# <-- Parse Segmentatation Fault output section -->

# Withdraw test_name from gdb output
test_name = if test_output =~ /<(.*)>/
Regexp.last_match(1)
else
''
end

# Collect file_name and line in which Segmentation fault have his beginning
if test_output =~ /#{test_name}\s\(\)\sat\s(.*):(\d+)\n/

# Collect file_name and line in which Segmentation faulted test is beginning
m = test_output.match? /#{test_case_name}\s*\(\)\sat\s(.*):(\d+)\n/
if m
# Remove path from file_name
file_name = Regexp.last_match(1).to_s.split('/').last.split('\\').last
file_name = m[1].to_s.split('/').last.split('\\').last
# Save line number
line = Regexp.last_match(2)
line = m[2]

# Replace:
# - '\n' by @new_line_tag to make gdb output flat
# - ':' by @colon_tag to avoid test results problems
# to enable parsing output for default generator_test_results regex
test_output = test_output.gsub("\n", @new_line_tag).gsub(':', @colon_tag)
test_output = "#{file_name}:#{line}:#{test_name}:FAIL: #{test_output}"
test_output = "#{file_name}:#{line}:#{test_case_name}:FAIL: #{test_output}"
else
test_output = "ERR:1:#{test_case_name}:FAIL: Segmentation Fault"
end

# Mark test as failure
Expand Down
2 changes: 1 addition & 1 deletion lib/ceedling/rakefile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_failures_handler()
@ceedling[:plugin_manager].print_plugin_failures
ops_done = SystemWrapper.time_stopwatch_s()
log_runtime( 'operations', start_time, ops_done, CEEDLING_APPCFG[:stopwatch] )
test_failures_handler() if @ceedling[:task_invoker].test_invoked?
test_failures_handler() if (@ceedling[:task_invoker].test_invoked? || @ceedling[:task_invoker].invoked?(/^gcov:/))
rescue => ex
ops_done = SystemWrapper.time_stopwatch_s()
log_runtime( 'operations', start_time, ops_done, CEEDLING_APPCFG[:stopwatch] )
Expand Down
8 changes: 4 additions & 4 deletions spec/gcov/gcov_test_cases_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def can_test_projects_with_gcov_with_success
FileUtils.cp test_asset_path("example_file.c"), 'src/'
FileUtils.cp test_asset_path("test_example_file_success.c"), 'test/'

output = `bundle exec ruby -S ceedling gcov:all`
output = `bundle exec ruby -S ceedling gcov:all 2>&1`
expect($?.exitstatus).to match(0) # Since a test either pass or are ignored, we return success here
expect(output).to match(/TESTED:\s+\d/)
expect(output).to match(/PASSED:\s+\d/)
Expand Down Expand Up @@ -211,10 +211,10 @@ def can_create_gcov_html_report_from_crashing_test_runner_with_enabled_debug_and
output_rd = File.read('./build/gcov/results/test_example_file_sigsegv.fail')
expect(output_rd =~ /test_add_numbers_will_fail \(\) at test\/test_example_file_sigsegv.c\:14/ )
expect(output).to match(/TESTED:\s+2/)
expect(output).to match(/PASSED:\s+1/)
expect(output).to match(/FAILED:\s+1/)
expect(output).to match(/PASSED:\s+(?:0|1)/)
expect(output).to match(/FAILED:\s+(?:1|2)/)
expect(output).to match(/IGNORED:\s+0/)
expect(output).to match(/example_file.c \| Lines executed:50.00% of 4/)
expect(output).to match(/example_file.c \| Lines executed:5?0.00% of 4/)

expect(output).to match(/Generating HTML coverage report in 'build\/artifacts\/gcov\/gcovr'\.\.\./)
expect(output).to match(/Done/)
Expand Down
2 changes: 1 addition & 1 deletion spec/system/deployment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
it "should be testable" do
@c.with_context do
Dir.chdir "temp_sensor" do
@output = `bundle exec ruby -S ceedling test:all`
@output = `bundle exec ruby -S ceedling test:all 2>&1`
expect(@output).to match(/TESTED:\s+47/)
expect(@output).to match(/PASSED:\s+47/)
end
Expand Down

0 comments on commit 8e374b9

Please sign in to comment.