arduino_ci 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15e345b597108192a550ec12ee76a0e885ca6cf0
4
- data.tar.gz: 11175d4813c5a96512a69908ced560b04e0a3508
3
+ metadata.gz: 45608f459dc2eeb5eaca6d2d825561a806ba7fcb
4
+ data.tar.gz: c6c442695f3471518ae5abdbd4098629ecb868e0
5
5
  SHA512:
6
- metadata.gz: 3227370d70a4d319e79c3900e744732c6ed66fcd2cfe2e45347512ba1a13f14e77a2496e34b6711bd2d99fa4d926d24506b2eddded019222359e3e0c78115988
7
- data.tar.gz: e5c8b30ad8819d5b01c3efcacb35b90758ead156dd71f2bff6feddfd2f37a61c9de7033906d5501476e35dc505b0f9dc7d92ec1e405512418ed9d159bb1cb07e
6
+ metadata.gz: ef50f062dde7ce201362da1a9a1e225ff4f0bd868985dd118d44afa7d50c9bd01250aef7fbefe156d5948a732daa7131dbdc023911aa1d640a6fa07a514f75fd
7
+ data.tar.gz: 8578a23f2b8c4323279ad3b22950ee44aa991ab09593e666f936059192c5d8878fb69bb4335ad8aae3877cc7116a896654b364308d744d9959707ea214e752ff
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- # ArduinoCI Ruby gem (`arduino_ci`) [![Gem Version](https://badge.fury.io/rb/arduino_ci.svg)](https://rubygems.org/gems/arduino_ci) [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/0.1.15)
2
+ # ArduinoCI Ruby gem (`arduino_ci`) [![Gem Version](https://badge.fury.io/rb/arduino_ci.svg)](https://rubygems.org/gems/arduino_ci) [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/0.1.16)
3
3
 
4
4
  You want your Arduino library to be automatically built and tested every time someone contributes code to your project on GitHub, but the Arduino IDE lacks the ability to run unit tests. [Arduino CI](https://github.com/ianfixes/arduino_ci) provides that ability.
5
5
 
@@ -42,7 +42,7 @@ out.each { |l| puts d(l) }
42
42
  #define pgm_read_ptr_far(x) (x)
43
43
 
44
44
 
45
- #define pgm_read_byte(x) (x)
45
+ #define pgm_read_byte(addr) (*(const uint8_t *)(addr))
46
46
  #define pgm_read_word(x) (x)
47
47
  #define pgm_read_dword(x) (x)
48
48
  #define pgm_read_float(x) (x)
@@ -111,165 +111,166 @@ def display_files(pathname)
111
111
  non_hidden.each { |p| puts "#{margin}#{p}" }
112
112
  end
113
113
 
114
- # initialize command and config
115
- config = ArduinoCI::CIConfig.default.from_project_library
116
- @arduino_cmd = ArduinoCI::ArduinoInstallation.autolocate!
117
- inform("Located Arduino binary") { @arduino_cmd.binary_path.to_s }
114
+ def perform_unit_tests(config)
115
+ cpp_library = ArduinoCI::CppLibrary.new(Pathname.new("."), @arduino_cmd.lib_dir)
116
+
117
+ # check GCC
118
+ compilers = config.compilers_to_use
119
+ assure("The set of compilers (#{compilers.length}) isn't empty") { !compilers.empty? }
120
+ compilers.each do |gcc_binary|
121
+ attempt_multiline("Checking #{gcc_binary} version") do
122
+ version = cpp_library.gcc_version(gcc_binary)
123
+ next nil unless version
124
+
125
+ puts version.split("\n").map { |l| " #{l}" }.join("\n")
126
+ version
127
+ end
128
+ inform("libasan availability for #{gcc_binary}") { cpp_library.libasan?(gcc_binary) }
129
+ end
118
130
 
119
- # index the existing libraries
120
- attempt("Indexing libraries") { @arduino_cmd.index_libraries } unless @arduino_cmd.libraries_indexed
131
+ # Ensure platforms exist for unit test, and save their info in all_platform_info keyed by name
132
+ all_platform_info = {}
133
+ config.platforms_to_unittest.each { |p| all_platform_info[p] = assured_platform("unittest", p, config) }
121
134
 
122
- # initialize library under test
123
- installed_library_path = attempt("Installing library under test") do
124
- @arduino_cmd.install_local_library(Pathname.new("."))
125
- end
126
- if installed_library_path.exist?
127
- inform("Library installed at") { installed_library_path.to_s }
128
- else
129
- assure_multiline("Library installed successfully") do
130
- # print out the contents of the deepest directory we actually find
131
- @arduino_cmd.lib_dir.ascend do |path_part|
132
- next unless path_part.exist?
133
-
134
- break display_files(path_part)
135
+ # iterate boards / tests
136
+ if !cpp_library.tests_dir.exist?
137
+ inform_multiline("Skipping unit tests; no tests dir at #{cpp_library.tests_dir}") do
138
+ puts " In case that's an error, this is what was found in the library:"
139
+ display_files(cpp_library.tests_dir.parent)
140
+ true
141
+ end
142
+ elsif cpp_library.test_files.empty?
143
+ inform_multiline("Skipping unit tests; no test files were found in #{cpp_library.tests_dir}") do
144
+ puts " In case that's an error, this is what was found in the tests directory:"
145
+ display_files(cpp_library.tests_dir)
146
+ true
147
+ end
148
+ elsif config.platforms_to_unittest.empty?
149
+ inform("Skipping unit tests") { "no platforms were requested" }
150
+ else
151
+ config.platforms_to_unittest.each do |p|
152
+ cpp_library.test_files.each do |unittest_path|
153
+ unittest_name = unittest_path.basename.to_s
154
+ compilers.each do |gcc_binary|
155
+ attempt_multiline("Unit testing #{unittest_name} with #{gcc_binary}") do
156
+ exe = cpp_library.build_for_test_with_configuration(
157
+ unittest_path,
158
+ config.aux_libraries_for_unittest,
159
+ gcc_binary,
160
+ config.gcc_config(p)
161
+ )
162
+ puts
163
+ unless exe
164
+ puts "Last command: #{cpp_library.last_cmd}"
165
+ puts cpp_library.last_out
166
+ puts cpp_library.last_err
167
+ next false
168
+ end
169
+ cpp_library.run_test_file(exe)
170
+ end
171
+ end
172
+ end
135
173
  end
136
- false
137
- end
138
- end
139
- library_examples = @arduino_cmd.library_examples(installed_library_path)
140
- cpp_library = ArduinoCI::CppLibrary.new(installed_library_path, @arduino_cmd.lib_dir)
141
-
142
- # check GCC
143
- compilers = config.compilers_to_use
144
- assure("The set of compilers (#{compilers.length}) isn't empty") { !compilers.empty? }
145
- compilers.each do |gcc_binary|
146
- attempt_multiline("Checking #{gcc_binary} version") do
147
- version = cpp_library.gcc_version(gcc_binary)
148
- next nil unless version
149
-
150
- puts version.split("\n").map { |l| " #{l}" }.join("\n")
151
- version
152
174
  end
153
- inform("libasan availability for #{gcc_binary}") { cpp_library.libasan?(gcc_binary) }
154
175
  end
155
176
 
156
- # Ensure platforms exist for unit test, and save their info in all_platform_info keyed by name
157
- all_platform_info = {}
158
- config.platforms_to_unittest.each { |p| all_platform_info[p] = assured_platform("unittest", p, config) }
159
-
160
- # gather up all required boards for compilation so we can install them up front.
161
- # start with the "platforms to unittest" and add the examples
162
- # while we're doing that, get the aux libraries as well
163
- example_platform_info = {}
164
- board_package_url = {}
165
- aux_libraries = Set.new(config.aux_libraries_for_unittest + config.aux_libraries_for_build)
166
- # while collecting the platforms, ensure they're defined
167
- library_examples.each do |path|
168
- ovr_config = config.from_example(path)
169
- ovr_config.platforms_to_build.each do |platform|
170
- # assure the platform if we haven't already
171
- next if example_platform_info.key?(platform)
172
-
173
- platform_info = assured_platform("library example", platform, config)
174
- next if platform_info.nil?
175
-
176
- example_platform_info[platform] = all_platform_info[platform] = platform_info
177
- package = platform_info[:package]
178
- board_package_url[package] = ovr_config.package_url(package)
179
- end
180
- aux_libraries.merge(ovr_config.aux_libraries_for_build)
181
- end
177
+ def perform_compilation_tests(config)
182
178
 
183
- # with all platform info, we can extract unique packages and their urls
184
- # do that, set the URLs, and download the packages
185
- all_packages = all_platform_info.values.map { |v| v[:package] }.uniq.reject(&:nil?)
179
+ # index the existing libraries
180
+ attempt("Indexing libraries") { @arduino_cmd.index_libraries } unless @arduino_cmd.libraries_indexed
186
181
 
187
- # inform about builtin packages
188
- all_packages.select { |p| config.package_builtin?(p) }.each do |p|
189
- inform("Using built-in board package") { p }
190
- end
182
+ # initialize library under test
183
+ installed_library_path = attempt("Installing library under test") do
184
+ @arduino_cmd.install_local_library(Pathname.new("."))
185
+ end
186
+ if installed_library_path.exist?
187
+ inform("Library installed at") { installed_library_path.to_s }
188
+ else
189
+ assure_multiline("Library installed successfully") do
190
+ # print out the contents of the deepest directory we actually find
191
+ @arduino_cmd.lib_dir.ascend do |path_part|
192
+ next unless path_part.exist?
191
193
 
192
- # make sure any non-builtin package has a URL defined
193
- all_packages.reject { |p| config.package_builtin?(p) }.each do |p|
194
- assure("Board package #{p} has a defined URL") { board_package_url[p] }
195
- end
194
+ break display_files(path_part)
195
+ end
196
+ false
197
+ end
198
+ end
199
+ library_examples = @arduino_cmd.library_examples(installed_library_path)
200
+
201
+ # gather up all required boards for compilation so we can install them up front.
202
+ # start with the "platforms to unittest" and add the examples
203
+ # while we're doing that, get the aux libraries as well
204
+ example_platform_info = {}
205
+ board_package_url = {}
206
+ aux_libraries = Set.new(config.aux_libraries_for_unittest + config.aux_libraries_for_build)
207
+ # while collecting the platforms, ensure they're defined
208
+
209
+ library_examples.each do |path|
210
+ ovr_config = config.from_example(path)
211
+ ovr_config.platforms_to_build.each do |platform|
212
+ # assure the platform if we haven't already
213
+ next if example_platform_info.key?(platform)
214
+
215
+ platform_info = assured_platform("library example", platform, config)
216
+ next if platform_info.nil?
217
+
218
+ example_platform_info[platform] = platform_info
219
+ package = platform_info[:package]
220
+ board_package_url[package] = ovr_config.package_url(package)
221
+ end
222
+ aux_libraries.merge(ovr_config.aux_libraries_for_build)
223
+ end
196
224
 
197
- # set up all the board manager URLs.
198
- # we can safely reject nils now, they would be for the builtins
199
- all_urls = all_packages.map { |p| board_package_url[p] }.uniq.reject(&:nil?)
225
+ # with all platform info, we can extract unique packages and their urls
226
+ # do that, set the URLs, and download the packages
227
+ all_packages = example_platform_info.values.map { |v| v[:package] }.uniq.reject(&:nil?)
200
228
 
201
- unless all_urls.empty?
202
- assure("Setting board manager URLs") do
203
- @arduino_cmd.board_manager_urls = all_urls
229
+ # inform about builtin packages
230
+ all_packages.select { |p| config.package_builtin?(p) }.each do |p|
231
+ inform("Using built-in board package") { p }
204
232
  end
205
- end
206
233
 
207
- all_packages.each do |p|
208
- assure("Installing board package #{p}") do
209
- @arduino_cmd.install_boards(p)
234
+ # make sure any non-builtin package has a URL defined
235
+ all_packages.reject { |p| config.package_builtin?(p) }.each do |p|
236
+ assure("Board package #{p} has a defined URL") { board_package_url[p] }
210
237
  end
211
- end
212
238
 
213
- aux_libraries.each do |l|
214
- if @arduino_cmd.library_present?(l)
215
- inform("Using pre-existing library") { l.to_s }
216
- else
217
- assure("Installing aux library '#{l}'") { @arduino_cmd.install_library(l) }
218
- end
219
- end
239
+ # set up all the board manager URLs.
240
+ # we can safely reject nils now, they would be for the builtins
241
+ all_urls = all_packages.map { |p| board_package_url[p] }.uniq.reject(&:nil?)
220
242
 
221
- # iterate boards / tests
222
- last_board = nil
223
- if !cpp_library.tests_dir.exist?
224
- inform_multiline("Skipping unit tests; no tests dir at #{cpp_library.tests_dir}") do
225
- puts " In case that's an error, this is what was found in the library:"
226
- display_files(cpp_library.tests_dir.parent)
227
- true
243
+ unless all_urls.empty?
244
+ assure("Setting board manager URLs") do
245
+ @arduino_cmd.board_manager_urls = all_urls
246
+ end
228
247
  end
229
- elsif cpp_library.test_files.empty?
230
- inform_multiline("Skipping unit tests; no test files were found in #{cpp_library.tests_dir}") do
231
- puts " In case that's an error, this is what was found in the tests directory:"
232
- display_files(cpp_library.tests_dir)
233
- true
248
+
249
+ all_packages.each do |p|
250
+ assure("Installing board package #{p}") do
251
+ @arduino_cmd.install_boards(p)
252
+ end
234
253
  end
235
- elsif config.platforms_to_unittest.empty?
236
- inform("Skipping unit tests") { "no platforms were requested" }
237
- else
238
- config.platforms_to_unittest.each do |p|
239
- board = all_platform_info[p][:board]
240
- assure("Switching to board for #{p} (#{board})") { @arduino_cmd.use_board(board) } unless last_board == board
241
- last_board = board
242
- cpp_library.test_files.each do |unittest_path|
243
- unittest_name = unittest_path.basename.to_s
244
- compilers.each do |gcc_binary|
245
- attempt_multiline("Unit testing #{unittest_name} with #{gcc_binary}") do
246
- exe = cpp_library.build_for_test_with_configuration(
247
- unittest_path,
248
- config.aux_libraries_for_unittest,
249
- gcc_binary,
250
- config.gcc_config(p)
251
- )
252
- puts
253
- unless exe
254
- puts "Last command: #{cpp_library.last_cmd}"
255
- puts cpp_library.last_out
256
- puts cpp_library.last_err
257
- next false
258
- end
259
- cpp_library.run_test_file(exe)
260
- end
261
- end
254
+
255
+ aux_libraries.each do |l|
256
+ if @arduino_cmd.library_present?(l)
257
+ inform("Using pre-existing library") { l.to_s }
258
+ else
259
+ assure("Installing aux library '#{l}'") { @arduino_cmd.install_library(l) }
262
260
  end
263
261
  end
264
- end
265
262
 
266
- if config.platforms_to_build.empty?
267
- inform("Skipping builds") { "no platforms were requested" }
268
- elsif library_examples.empty?
269
- inform_multiline("Skipping builds; no examples found in #{installed_library_path}") do
270
- display_files(installed_library_path)
263
+ last_board = nil
264
+ if config.platforms_to_build.empty?
265
+ inform("Skipping builds") { "no platforms were requested" }
266
+ return
267
+ elsif library_examples.empty?
268
+ inform_multiline("Skipping builds; no examples found in #{installed_library_path}") do
269
+ display_files(installed_library_path)
270
+ end
271
+ return
271
272
  end
272
- else
273
+
273
274
  attempt("Setting compiler warning level") { @arduino_cmd.set_pref("compiler.warning_level", "all") }
274
275
 
275
276
  # switching boards takes time, so iterate board first
@@ -283,7 +284,7 @@ else
283
284
  end
284
285
 
285
286
  examples_by_platform.each do |platform, example_paths|
286
- board = all_platform_info[platform][:board]
287
+ board = example_platform_info[platform][:board]
287
288
  assure("Switching to board for #{platform} (#{board})") { @arduino_cmd.use_board(board) } unless last_board == board
288
289
  last_board = board
289
290
 
@@ -300,6 +301,16 @@ else
300
301
  end
301
302
  end
302
303
  end
304
+
303
305
  end
304
306
 
307
+ # initialize command and config
308
+ config = ArduinoCI::CIConfig.default.from_project_library
309
+
310
+ @arduino_cmd = ArduinoCI::ArduinoInstallation.autolocate!
311
+ inform("Located Arduino binary") { @arduino_cmd.binary_path.to_s }
312
+
313
+ perform_unit_tests(config)
314
+ perform_compilation_tests(config)
315
+
305
316
  terminate(true)
@@ -1,3 +1,3 @@
1
1
  module ArduinoCI
2
- VERSION = "0.1.15".freeze
2
+ VERSION = "0.1.16".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arduino_ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Katz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-04 00:00:00.000000000 Z
11
+ date: 2019-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os