Skip to content

Commit 58d73fa

Browse files
committed
ignore things in vendor bundle
1 parent 90808df commit 58d73fa

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2020
- All test files were reporting "not ok" in TAP output. Now they are OK iff all asserts pass.
2121
- Directories with a C++ extension in their name could cause problems. Now they are ignored.
2222
- `CppLibrary` had trouble with symlinks. It shoudn't anymore.
23+
- `CppLibrary` had trouble with vendor bundles. It might in the future, but I have a better fix ready to go if it's an issue.
2324

2425
### Security
2526

lib/arduino_ci/cpp_library.rb

+17-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ def initialize(base_dir)
3535
@last_msg = ""
3636
end
3737

38+
# Guess whether a file is part of the vendor bundle (indicating we should ignore it).
39+
#
40+
# This assumes the vendor bundle will be at `vendor/bundle` and not some other location
41+
# @param path [String] The path to check
42+
# @return [Array<String>] The paths of the found files
43+
def vendor_bundle?(path)
44+
# TODO: look for Gemfile, look for .bundle/config and get BUNDLE_PATH from there?
45+
base = File.join(@base_dir, "vendor")
46+
real = File.join(File.realpath(@base_dir), "vendor")
47+
return true if path.start_with?(base)
48+
return true if path.start_with?(real)
49+
false
50+
end
51+
3852
# Get a list of all CPP source files in a directory and its subdirectories
3953
# @param some_dir [String] The directory in which to begin the search
4054
# @return [Array<String>] The paths of the found files
@@ -52,6 +66,7 @@ def cpp_files
5266
cpp_files_in(@base_dir).reject do |p|
5367
next true if File.dirname(p).include?(tests_dir)
5468
next true if File.dirname(p).include?(real_tests_dir)
69+
next true if vendor_bundle?(p)
5570
end
5671
end
5772

@@ -84,7 +99,8 @@ def test_files
8499
def header_dirs
85100
real = File.realpath(@base_dir)
86101
all_files = Find.find(real).reject { |path| File.directory?(path) }
87-
files = all_files.select { |path| HPP_EXTENSIONS.include?(File.extname(path)) }
102+
unbundled = all_files.reject { |path| vendor_bundle?(path) }
103+
files = unbundled.select { |path| HPP_EXTENSIONS.include?(File.extname(path)) }
88104
ret = files.map { |path| File.dirname(path) }.uniq
89105
puts "header_dirs found #{files}\n returning #{ret}"
90106
ret

0 commit comments

Comments
 (0)