I have a set of tests that involve loading files from the file-system and I would like to use the current filename to locate the test files relative to the test file.
The below code shows the pattern I am trying, but unfortunately when I run the test using M-x ert
, it fails with (wrong-type-argument stringp nil)
, because both the load-file-name
and buffer-file-name
are nil
. How should I approach this?
(ert-deftest closing-braces ()
(find-file (concat (file-name-directory
(or load-file-name buffer-file-name))
"ClosingBrace.file"))
...
)