9
9
# terminate after printing any debug info. TODO: capture debug info
10
10
def terminate
11
11
puts "Failures: #{ @failure_count } "
12
+ unless failure_count . zero?
13
+ puts "Last message: #{ @arduino_cmd . last_msg } "
14
+ puts "========== Stdout:"
15
+ puts @arduino_cmd . last_out
16
+ puts "========== Stderr:"
17
+ puts @arduino_cmd . last_err
18
+ end
12
19
retcode = @failure_count . zero? ? 0 : 1
13
20
exit ( retcode )
14
21
end
@@ -41,11 +48,11 @@ def assure(message, &block)
41
48
42
49
# initialize command and config
43
50
config = ArduinoCI ::CIConfig . default . from_project_library
44
- arduino_cmd = ArduinoCI ::ArduinoInstallation . autolocate!
51
+ @ arduino_cmd = ArduinoCI ::ArduinoInstallation . autolocate!
45
52
46
53
# initialize library under test
47
- installed_library_path = assure ( "Installing library under test" ) { arduino_cmd . install_local_library ( "." ) }
48
- library_examples = arduino_cmd . library_examples ( installed_library_path )
54
+ installed_library_path = assure ( "Installing library under test" ) { @ arduino_cmd. install_local_library ( "." ) }
55
+ library_examples = @ arduino_cmd. library_examples ( installed_library_path )
49
56
50
57
# gather up all required boards so we can install them up front.
51
58
# start with the "platforms to unittest" and add the examples
@@ -64,34 +71,34 @@ def assure(message, &block)
64
71
all_packages = all_platforms . values . map { |v | v [ :package ] } . uniq . reject ( &:nil? )
65
72
all_urls = all_packages . map { |p | config . package_url ( p ) } . uniq . reject ( &:nil? )
66
73
assure ( "Setting board manager URLs" ) do
67
- arduino_cmd . set_pref ( "boardsmanager.additional.urls" , all_urls . join ( "," ) )
74
+ @ arduino_cmd. set_pref ( "boardsmanager.additional.urls" , all_urls . join ( "," ) )
68
75
end
69
76
70
77
all_packages . each do |p |
71
78
assure ( "Installing board package #{ p } " ) do
72
- arduino_cmd . install_boards ( p )
79
+ @ arduino_cmd. install_boards ( p )
73
80
end
74
81
end
75
82
76
83
aux_libraries . each do |l |
77
- assure ( "Installing aux library '#{ l } '" ) { arduino_command . install_library ( l ) }
84
+ assure ( "Installing aux library '#{ l } '" ) { @arduino_cmd . install_library ( l ) }
78
85
end
79
86
80
- attempt ( "Setting compiler warning level" ) { arduino_cmd . set_pref ( "compiler.warning_level" , "all" ) }
87
+ attempt ( "Setting compiler warning level" ) { @ arduino_cmd. set_pref ( "compiler.warning_level" , "all" ) }
81
88
82
89
library_examples . each do |example_path |
83
90
ovr_config = config . from_example ( example_path )
84
91
ovr_config . platforms_to_build . each do |p |
85
92
board = all_platforms [ p ] [ :board ]
86
- assure ( "Switching to board for #{ p } (#{ board } )" ) { arduino_cmd . use_board ( board ) }
93
+ assure ( "Switching to board for #{ p } (#{ board } )" ) { @ arduino_cmd. use_board ( board ) }
87
94
example_name = File . basename ( example_path )
88
- attempt ( "Verifying #{ example_name } " ) { arduino_cmd . verify_sketch ( example_path ) }
95
+ attempt ( "Verifying #{ example_name } " ) { @ arduino_cmd. verify_sketch ( example_path ) }
89
96
end
90
97
end
91
98
92
99
config . platforms_to_test . each do |p |
93
100
board = all_platforms [ p ] [ :board ]
94
- assure ( "Switching to board for #{ p } (#{ board } )" ) { arduino_cmd . use_board ( board ) }
101
+ assure ( "Switching to board for #{ p } (#{ board } )" ) { @ arduino_cmd. use_board ( board ) }
95
102
cpp_library . test_files . each do |unittest_path |
96
103
unittest_name = File . basename ( unittest_path )
97
104
attempt ( "Unit testing #{ unittest_name } " ) { cpp_library . test ( unittest_path ) }
0 commit comments