-
Notifications
You must be signed in to change notification settings - Fork 34
include ability to exclude certain directories from compilation #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I want to sleep on this but I still want to help you with the problem you described in #29 . Can we resolve that first (changing directories) and then resume here? Immediate thoughts on this PR:
|
@ianfixes The feature request of #29 is about excluding directories from the tree walk process when looking for CPP files. That is exactly what this ticket addresses. It so happens, that with that addition, my use-case is actually solved. I don't need to make separate arduino_ci installations for each library. My working demo is on https://github.com/dolfandringa/Bare-Arduino-Project I modified the tests so they explicitly test my new feature. Without my feature, the tests would fail because "excludeThis" contains code that would make the compilation fail. Documentation: I adjusted the README.md to document the feature. What else should I document? |
raise ArgumentError, 'base_dir is not a Pathname' unless base_dir.is_a? Pathname | ||
raise ArgumentError, 'arduino_lib_dir is not a Pathname' unless arduino_lib_dir.is_a? Pathname | ||
raise ArgumentError, 'exclude_dir is not an array of Pathnames' unless exclude_dirs.is_a?(Array) && | ||
exclude_dirs.each { |p| p.is_a? Pathname } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int* aNullPointer(void) { | ||
int* ret = nullptr; | ||
return ret; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contents of this directory appear to be a simple copy of files that already exist elsewhere in this project.
If the purpose of this file (and the .h
) is just to cause some form of compilation error, I'd prefer that its contents speak entirely to that. Just fill it with a syntax error in the form of
This file was placed here specifically to break unit test compilation.
If arduino_ci is working properly, it should exclude this file (as per
the .arduino-ci.yml configuration) and compilation should succeed.
And name it something like break-compilation.cpp
.
cpp_library = ArduinoCI::CppLibrary.new(cpp_lib_path, Pathname.new("my_fake_arduino_lib_dir")) | ||
cpp_library = ArduinoCI::CppLibrary.new(cpp_lib_path, | ||
Pathname.new("my_fake_arduino_lib_dir"), | ||
["excludeThis"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace ["excludeThis"]
with []
, or add tests to the spec file that specifically refer to the excludeThis
directory and/or the files it contains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To say this another way: I assume ["excludeThis"]
prevents a regression on the existing tests in this spec file. That's fine, but you should add a different test section that shows that without excluding a directory, cpp_library.cpp_files
contains the extra files.
The easiest way I can think of would be to give each context
section its own cpp_library =
line, instead of using a common one.
context "cpp_files without an exclude directory" do
cpp_library = ArduinoCI::CppLibrary.new(cpp_lib_path,
Pathname.new("my_fake_arduino_lib_dir"),
[])
it "finds all cpp files in directory" do
testsomething_cpp_files = [
Pathname.new("TestSomething/test-something.cpp"),
Pathname.new("TestSomething/excludeThis/break-compilation.cpp"),
]
relative_paths = cpp_library.cpp_files.map { |f| get_relative_dir(f) }
expect(relative_paths).to match_array(testsomething_cpp_files)
end
end
context "cpp_files with an exclude directory" do
cpp_library = ArduinoCI::CppLibrary.new(cpp_lib_path,
Pathname.new("my_fake_arduino_lib_dir"),
["excludeThis"])
it "finds cpp files in directory and ignores some" do
testsomething_cpp_files = [Pathname.new("TestSomething/test-something.cpp")]
relative_paths = cpp_library.cpp_files.map { |f| get_relative_dir(f) }
expect(relative_paths).to match_array(testsomething_cpp_files)
end
end
context "unit tests" do
cpp_library = ArduinoCI::CppLibrary.new(cpp_lib_path,
Pathname.new("my_fake_arduino_lib_dir"),
["excludeThis"])
@@ -37,11 +37,14 @@ class CppLibrary | |||
|
|||
# @param base_dir [Pathname] The path to the library being tested | |||
# @param arduino_lib_dir [Pathname] The path to the libraries directory | |||
def initialize(base_dir, arduino_lib_dir) | |||
def initialize(base_dir, arduino_lib_dir, exclude_dirs = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exclude_dirs
should not be an optional argument here. You'll need update all instances of CppLibrary.new
(i.e. the spec files) to explicitly pass in the empty array.
Thanks for contributing this, and I appreciate the attention you've paid to copying the existing style of the project. I have a few small fixes to request, and then this is good to merge. |
Merging to non-master branch as my requested edits are easy to make myself |
Exclude certain directories from exclusion in compilation
Issues Fixed