calva icon indicating copy to clipboard operation
calva copied to clipboard

"Toggle between implementation and test" command do not work for projects with children test paths

Open romulo-oliveira-nubank opened this issue 8 months ago • 1 comments

I'm migrating from IntelliJ recently and noticed that Toggle between implementation and test command is not working the same for projects that uses subfolders inside test path (example: test/unit/..., test/integration/...).

I have a Leiningen project that looks like the following:

.
├── project.clj
├── src
│ ├── my-project
│ │ ├── ...
│ │ ├── adapters
│ │ │ ├── command.clj
│ │ ├── ...
└── test
    ├── helpers
    │ ├── ...
    ├── integration
    │ ├── integration
    │ │ ├── ...
    └── unit
        └── my-project
            ├── adapters
            │ ├── command_test.clj
            ├── ...
            │ ├── ...

What I expected when I'm in a function inside my-project.adapters.command namespace and hit Toggle between implementation and test command is to go to my-project.adapters.command-test and vice-versa. Regardless of how they are in src/test folders.

What happens is that the editor asks to create a test file test/my_project/adapters/command_test.clj (when test/unit/my-project/adapters/command_test.clj already exists. When when I'm in the test file it asks to create a source in src/unit/my-project/adapters/command.clj (when src/my-project/adapters.command.clj already exists).

This issue is a request to support these use cases. I'd expect to search using namespaces (which match in the examples I mentioned) and not necessarily test file path. Consider following leiningen's :test-paths config.

Here's what my leiningen project.clj defined test paths looks like:

  :test-paths ["test/unit/"
               "test/integration/"]

romulo-oliveira-nubank avatar Jul 04 '25 13:07 romulo-oliveira-nubank

Hello. Sorry for radio silence. Thanks for reaching out! This sounds like a good thing for Calva to support. We have similar use cases for fiddle files where we allow for more flexibility. Maybe we can re-use some of that code for this. (Or maybe not, but mentioning it because whoever starts working on this should be aware.)

PEZ avatar Aug 12 '25 15:08 PEZ