@@ -50,14 +50,34 @@ def initialize(base_dir, arduino_lib_dir)
50
50
#
51
51
# This assumes the vendor bundle will be at `vendor/bundle` and not some other location
52
52
# @param path [Pathname] The path to check
53
- # @return [Array<Pathname>] The paths of the found files
53
+ # @return [bool]
54
54
def vendor_bundle? ( path )
55
55
# TODO: look for Gemfile, look for .bundle/config and get BUNDLE_PATH from there?
56
56
base = @base_dir + "vendor"
57
57
return false unless base . exist?
58
58
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
61
81
end
62
82
63
83
# Check whether libasan (and by extension -fsanitizer=address) is supported
@@ -94,11 +114,7 @@ def cpp_files_in(some_dir)
94
114
# CPP files that are part of the project library under test
95
115
# @return [Array<Pathname>]
96
116
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 ) }
102
118
end
103
119
104
120
# CPP files that are part of the arduino mock library we're providing
0 commit comments