Skip to content

Commit 4fb810b

Browse files
committed
better file listings
1 parent a8a054b commit 4fb810b

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
### Added
99

1010
### Changed
11+
- Centralized file listing code in `arduino_ci_remote.rb`
1112

1213
### Deprecated
1314

exe/arduino_ci_remote.rb

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'pathname'
55

66
WIDTH = 80
7+
FIND_FILES_INDENT = 4
78

89
@failure_count = 0
910
@passfail = proc { |result| result ? "✓" : "✗" }
@@ -83,6 +84,22 @@ def assured_platform(purpose, name, config)
8384
platform_definition
8485
end
8586

87+
# print out some files
88+
def display_files(pathname)
89+
# `find` doesn't follow symlinks, so we should instead
90+
realpath = pathname.symlink? ? pathname.readlink : pathname
91+
92+
# suppress directories and dotfile-based things
93+
all_files = realpath.find.select(&:file?)
94+
non_hidden = all_files.reject do |path|
95+
path.ascend.any? { |part| part.basename.to_s.start_with? "." }
96+
end
97+
98+
# print files with an indent
99+
margin = " " * FIND_FILES_INDENT
100+
non_hidden.each { |p| puts "#{margin}#{p}" }
101+
end
102+
86103
# initialize command and config
87104
config = ArduinoCI::CIConfig.default.from_project_library
88105
@arduino_cmd = ArduinoCI::ArduinoInstallation.autolocate!
@@ -98,7 +115,7 @@ def assured_platform(purpose, name, config)
98115
@arduino_cmd.lib_dir.ascend do |path_part|
99116
next unless path_part.exist?
100117

101-
break puts path_part.find.to_a.to_s
118+
break display_files(path_part)
102119
end
103120
false
104121
end
@@ -161,12 +178,14 @@ def assured_platform(purpose, name, config)
161178
last_board = nil
162179
if !cpp_library.tests_dir.exist?
163180
inform_multiline("Skipping unit tests; no tests dir at #{cpp_library.tests_dir}") do
164-
puts cpp_library.tests_dir.parent.find.to_a.to_s
181+
puts " In case that's an error, this is what was found in the library:"
182+
display_files(cpp_library.tests_dir.parent)
165183
true
166184
end
167185
elsif cpp_library.test_files.empty?
168186
inform_multiline("Skipping unit tests; no test files were found in #{cpp_library.tests_dir}") do
169-
puts cpp_library.tests_dir.find.to_a.to_s
187+
puts " In case that's an error, this is what was found in the tests directory:"
188+
display_files(cpp_library.tests_dir)
170189
true
171190
end
172191
elsif config.platforms_to_unittest.empty?
@@ -202,7 +221,7 @@ def assured_platform(purpose, name, config)
202221

203222
if library_examples.empty?
204223
inform_multiline("Skipping libraries; no examples found in #{installed_library_path}") do
205-
puts installed_library_path.find.to_a.to_s
224+
display_files(installed_library_path)
206225
end
207226
else
208227
attempt("Setting compiler warning level") { @arduino_cmd.set_pref("compiler.warning_level", "all") }

0 commit comments

Comments
 (0)