Skip to content

Commit 731e657

Browse files
committed
Print unit test stack traces if encountered
1 parent 03e3009 commit 731e657

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

CHANGELOG.md

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

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

lib/arduino_ci/cpp_library.rb

+21-2
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,33 @@ 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+
system("ls")
428+
[executable + ".stackdump"].each do |dump|
429+
puts "========== Stack dump from #{dump}:"
430+
if dump.exist?
431+
File.foreach(dump) { |line| print " #{line}" }
432+
else
433+
puts "File does not seem to exist: #{dump}"
434+
end
435+
end
436+
end
437+
424438
# run a test file
425-
# @param [Pathname] the path to the test file
439+
# @param executable [Pathname] the path to the test file
426440
# @return [bool] whether all tests were successful
427441
def run_test_file(executable)
428442
@last_cmd = executable
429443
@last_out = ""
430444
@last_err = ""
431-
Host.run_and_output(executable.to_s.shellescape)
445+
ret = Host.run_and_output(executable.to_s.shellescape)
446+
447+
# print any stack traces found during a failure
448+
print_stack_dump(executable) unless ret
449+
450+
ret
432451
end
433452

434453
end

0 commit comments

Comments
 (0)