1

I have a python project, it has tests and I can execute them from the command line. I just read about .dir-locals.el in the projectile documentation and I want to execute tests from inside emacs using projectile.

So I create a .dir-locals.el file like:

((nil .
      (
       (projectile-project-test-cmd . "pytest --color=no")
       )))

The variable is set, but when do C-c p P (or M-x projectile-test-project) It asks for the command with Test command: (If I type there pytest --color=no, it will execute perfectly)

The documentation says that it is possible to avoid the question setting the variable compilation-read-command to no nil.

((nil .
      ((compilation-read-command . nil)
       (projectile-project-test-cmd . "pytest --color=no")
       )))

But if I do that, C-c p P stops asking, but it doesn't execute the tests, it executes a Compilation (!)

This is the result:

-*- mode: compilation; default-directory: "~/tmp/tsp/" -*-
Compilation started at Sat Oct 31 02:05:42



Compilation finished at Sat Oct 31 02:05:42

Would you mind to point me what I am doing wrong?

2

According to the docstring of projectile-test-command, this function first check projectile-test-cmd-map for the last command. It is likely you inadvertently invoked an empty "" command in that emacs session, and that empty command was stored inside the hash-table. The problem will probably disappear when you restart emacs or invoke (clrhash projectile-test-cmd-map) to clear the hash-table.

It's worth mentioning though, according to the doc, compilation-read-command maybe risky if used as a file-local variable. So I'm not sure if it's a good idea to put this in your .dir-locals.el. Perhaps it's better to set it globally (or set inside emacs customization interface).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.