Skip to content

Commit 290c2a5

Browse files
committed
Fix breaking tests
1 parent 5da44d4 commit 290c2a5

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

exe/arduino_ci_remote.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,22 @@ def assured_platform(purpose, name, config)
8888
platform_definition
8989
end
9090

91+
# Return true if the file (or one of the dirs containing it) is hidden
92+
def file_is_hidden_somewhere?(path)
93+
path.ascend do |part|
94+
return true if part.basename.to_s.start_with? "."
95+
end
96+
false
97+
end
98+
9199
# print out some files
92100
def display_files(pathname)
93101
# `find` doesn't follow symlinks, so we should instead
94102
realpath = pathname.symlink? ? pathname.readlink : pathname
95103

96104
# suppress directories and dotfile-based things
97105
all_files = realpath.find.select(&:file?)
98-
non_hidden = all_files.reject do |path|
99-
path.ascend.any? { |part| part.basename.to_s.start_with? "." }
100-
end
106+
non_hidden = all_files.reject { |path| file_is_hidden_somewhere?(path) }
101107

102108
# print files with an indent
103109
margin = " " * FIND_FILES_INDENT

lib/arduino_ci/cpp_library.rb

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,34 @@ def initialize(base_dir, arduino_lib_dir)
5050
#
5151
# This assumes the vendor bundle will be at `vendor/bundle` and not some other location
5252
# @param path [Pathname] The path to check
53-
# @return [Array<Pathname>] The paths of the found files
53+
# @return [bool]
5454
def vendor_bundle?(path)
5555
# TODO: look for Gemfile, look for .bundle/config and get BUNDLE_PATH from there?
5656
base = @base_dir + "vendor"
5757
return false unless base.exist?
5858

59-
real = base.realpath
60-
path.ascend.any? { |part| part == base || part == real }
59+
vendor_bundle_aliases = [base, base.realpath]
60+
61+
# we could do this but some rubies don't return an enumerator for ascend
62+
# path.ascend.any? { |part| vendor_bundle_aliases.include?(part) }
63+
path.ascend do |part|
64+
return true if vendor_bundle_aliases.include?(part)
65+
end
66+
false
67+
end
68+
69+
# Guess whether a file is part of the tests/ dir (indicating library compilation should ignore it).
70+
#
71+
# @param path [Pathname] The path to check
72+
# @return [bool]
73+
def in_tests_dir?(path)
74+
tests_dir_aliases = [tests_dir, tests_dir.realpath]
75+
# we could do this but some rubies don't return an enumerator for ascend
76+
# path.ascend.any? { |part| tests_dir_aliases.include?(part) }
77+
path.ascend do |part|
78+
return true if tests_dir_aliases.include?(part)
79+
end
80+
false
6181
end
6282

6383
# Check whether libasan (and by extension -fsanitizer=address) is supported
@@ -94,11 +114,7 @@ def cpp_files_in(some_dir)
94114
# CPP files that are part of the project library under test
95115
# @return [Array<Pathname>]
96116
def cpp_files
97-
tests_dir_aliases = [tests_dir, tests_dir.realpath]
98-
cpp_files_in(@base_dir).reject do |p|
99-
# ignore anything in the vendor bundle or tests dir
100-
vendor_bundle?(p) || (p.ascend.any? { |part| tests_dir_aliases.include?(part) })
101-
end
117+
cpp_files_in(@base_dir).reject { |p| vendor_bundle?(p) || in_tests_dir?(p) }
102118
end
103119

104120
# CPP files that are part of the arduino mock library we're providing

spec/ci_config_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
uno = default_config.platform_definition("uno")
1010
expect(uno.class).to eq(Hash)
1111
expect(uno[:board]).to eq("arduino:avr:uno")
12-
expect(uno[:package]).to be nil
12+
expect(uno[:package]).to eq("arduino:avr")
1313
expect(uno[:gcc].class).to eq(Hash)
1414

1515
due = default_config.platform_definition("due")
@@ -47,7 +47,7 @@
4747
uno = combined_config.platform_definition("uno")
4848
expect(uno.class).to eq(Hash)
4949
expect(uno[:board]).to eq("arduino:avr:uno")
50-
expect(uno[:package]).to be nil
50+
expect(uno[:package]).to eq("arduino:avr")
5151
expect(uno[:gcc].class).to eq(Hash)
5252

5353
zero = combined_config.platform_definition("zero")
@@ -87,7 +87,7 @@
8787
uno = combined_config.platform_definition("uno")
8888
expect(uno.class).to eq(Hash)
8989
expect(uno[:board]).to eq("arduino:avr:uno")
90-
expect(uno[:package]).to be nil
90+
expect(uno[:package]).to eq("arduino:avr")
9191
expect(uno[:gcc].class).to eq(Hash)
9292

9393
zero = combined_config.platform_definition("zero")

0 commit comments

Comments
 (0)