I'm trying to use ERT to test the ycmd package, and part of what I need to do is pass bodies of code to the ycmd server and ask for completion candidates. I'd like to be able to keep these bodies of code in separate files, partly for organization and partly because that makes it simpler to determine the position in the code for which I would like to do completion.
However, I can't figure out the right way to address these files when the test is running. The crux of what I want to do is read the contents of a file which is in a location relative to the elisp file which defines the test. How can I do this?
(I've tried load-file-name
, and it appears that this might work for batch mode testing. However, it doesn't work for interactive testing inside emacs, so at best it's an incomplete solution.)