dap-mode
dap-mode copied to clipboard
How to change default-directory with `dap-java`?
I have a projectile project with several git repos within 1 folder. When I run dap-java-run-test-method
in a test file, the test method is found and executed, however, it uses default-directory
as the projectile root.
* projectile-root
|--src
|----project1
|----project2
|----project3
|--------- path/to/test/JavaTest.java
|--------- path/to/test/resources/TestInput.json
In my tests, I have some functions which load files with relative paths from the git repo's top level directory. So this leads to test failures with dap-java-run-test-method
- is it possible to write some defadvice
to address this? I tried to do
(defun my/test()
(interactive)
(let* ((default-directory "my/desired/directory"))
(dap-java-run-test-method)))
this didn't work.
using lsp-jt-browser and lsp-jt-lens-mode (in combination with vanilla lsp lenses) will most likely work. Alternatively, you may write test wrapper(similar to dap-java-run-test-method) which does the right thing).
I tried doing this for dap-java-run-test-method, but then I had to do it in addition for dap-java-debug-test-method too. I'm wondering if this needs to be a function exposed somehow. I can probably write the function etc if I knew where...
in the mean time - setting :cwd "my/custom/dir
in each method worked