-
Notifications
You must be signed in to change notification settings - Fork 224
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
Add comprehensive tests for pygmt.clib.loading.clib_full_names #872
Conversation
e330857
to
89c84d2
Compare
89c84d2
to
5bb02a4
Compare
@weiji14 I'd appreciate it if you can give it a review. The latest CI runs (some are skipped by Please read the PR description first. For the point 4, I think it's possible to simulate this case by monkeypatching the
|
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 read the PR description first. For the point 4, I think it's possible to simulate this case by monkeypatching the
find_library
function, but I still don't know how to do it.
Just one quick comment for now on removal of a fixture. I'll need a bit of a think on how to handle the point 4 case.
There is still one rare case that is not tested. On Windows, if GMT's bin path is included in PATH, but GMT's library
gmt.dll
isn't, then thefind_library
function (which searches DLLs in PATH) won't find gmt.dll. Thus the length of the returned names list will be -1.
Why is the length of the returned list from clib_full_names
-1? Shouldn't it be 0?
Sorry, the description is confusing. For this case (i.e., In normal cases, the list of names would be:
In this rare case, |
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Ping @weiji14 to give it a review when possible. |
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.
There is still one rare case that is not tested. On Windows, if GMT's bin path is included in PATH, but GMT's library
gmt.dll
isn't, then thefind_library
function (which searches DLLs in PATH) won't find gmt.dll. Thus the length of the returned names list will be -1.Why is the length of the returned list from
clib_full_names
-1? Shouldn't it be 0?Sorry, the description is confusing. For this case (i.e.,
gmt.dll
andgmt.exe
are not in the same directory, and PATH includes GMT's bin path), the number of names will be one less compared to normal cases.In normal cases, the list of names would be:
["/path/from/gmt_library_path/gmt.dll", "/path/from/gmt-show-library/gmt.dll", "/path/from/ctypes-find-library/gmt.dll", "gmt.dll", "gmt_w64.dll", "gmt_w32.dll", ]
In this rare case,
"/path/from/ctypes-find-library/gmt.dll"
is not returned, becausefind_library
won't findgmt.dll
in PATH.
Sorry, I've been meaning to log on to Windows to test the special case but too many things on my plate at the moment. Up to you, but I can either approve this PR now as the other cases look covered (and we handle the special case one another time), or keep this PR open for a little longer.
The special case is very rare and I believe it would be difficult for you to reproduce the case. So I prefer to this option if the current tests look good. |
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.
Yeah, agree that it is quite rare, and probably only happens with a very complicated setup (but will see if someone complains). Good to merge then.
…icMappingTools#872) This PR adds comprehensive tests for the function pygmt.clib.loading.clib_full_names. See GenericMappingTools#872 for details. Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Description of proposed changes
This PR adds comprehensive tests for the function
pygmt.clib.loading.clib_full_names
. Following cases are tested usingmonkeypatch
.GMT_LIBRARY_PATH
PATH
Some notes:
gmt
command. Otherwise these tests fail. The assumption is valid for our current CI environments, so I prefer not to make the tests too complicated.clib_full_names()
returns a generator and the expected list of names. In these tests, the GMT library is not loaded.pygmt/clib/loading.py
by 2 more lines, thus now it's 💯gmt.dll
isn't, then thefind_library
function (which searches DLLs in PATH) won't findgmt.dll
. Thus the length of the returned names list will be -1.Fixes #
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash commands are:
/format
: automatically format and lint the code/test-gmt-dev
: run full tests on the latest GMT development version