Skip to content

Commit be95d0c

Browse files
committed
Print unit test stack traces if encountered
1 parent 2af1a4c commit be95d0c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
- `LibraryProperties` to read metadata from Arduino libraries
1515
- `CppLibrary.library_properties_path`, `CppLibrary.library_properties?`, `CppLibrary.library_properties` to expose library properties of a Cpp library
1616
- `CppLibrary.arduino_library_dependencies` to list the dependent libraries specified by the library.properties file
17+
- `CppLibrary.print_stack_dump` prints stack trace dumps (on Windows specifically) to the console if encountered
1718

1819
### Changed
1920
- Move repository from https://github.com/ianfixes/arduino_ci to https://github.com/Arduino-CI/arduino_ci

lib/arduino_ci/cpp_library.rb

+19-2
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,31 @@ def build_for_test_with_configuration(test_file, aux_libraries, gcc_binary, ci_g
421421
executable
422422
end
423423

424+
# print any found stack dumps
425+
# @param executable [Pathname] the path to the test file
426+
def print_stack_dump(executable)
427+
possible_dumpfiles = [
428+
executable.sub_ext(executable.extname + ".stackdump")
429+
]
430+
possible_dumpfiles.select(&:exist?).each do |dump|
431+
puts "========== Stack dump from #{dump}:"
432+
File.foreach(dump) { |line| print " #{line}" }
433+
end
434+
end
435+
424436
# run a test file
425-
# @param [Pathname] the path to the test file
437+
# @param executable [Pathname] the path to the test file
426438
# @return [bool] whether all tests were successful
427439
def run_test_file(executable)
428440
@last_cmd = executable
429441
@last_out = ""
430442
@last_err = ""
431-
Host.run_and_output(executable.to_s.shellescape)
443+
ret = Host.run_and_output(executable.to_s.shellescape)
444+
445+
# print any stack traces found during a failure
446+
print_stack_dump(executable) unless ret
447+
448+
ret
432449
end
433450

434451
end

0 commit comments

Comments
 (0)