Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clearing test output buffer #15

Merged
merged 1 commit into from Sep 6, 2020
Merged

Conversation

m-novikov
Copy link
Contributor

If we try to run a test without closing previous results buffer it will fail with error: Text is read-only in mini-buffer.

@wbolster
Copy link
Owner

hmmm, strange. repeated invocations work perfectly fine for me, and i use this all the time.

can you reproduce this in a clean environment? which emacs version?

@m-novikov
Copy link
Contributor Author

My emacs version is 26.1 (spaceemacs)
Reproducible in clean environment if comint-prompt-read-only variable is true.

@m-novikov
Copy link
Contributor Author

Maybe proper fix should add

(let ((comint-prompt-read-only nil))
   ...)

before running test process.
What do you think?

@mpanarin
Copy link

I experience exactly same issue with repeated test runs.

Using spacemacs/develop and emacs28

@wbolster
Copy link
Owner

ah, comint-prompt-read-only is nil by default which is why i didn't notice this myself.

@m-novikov re your comment about comint-prompt-read-only vs inhibit-read-only... not sure, what do you think is best?

totally forgot about this issue, would be happy to merge if someone tells me what the best variable is here...

@wbolster wbolster self-assigned this May 14, 2020
@wbolster wbolster added the help wanted Extra attention is needed label Jul 31, 2020
@pinetr2e
Copy link

pinetr2e commented Sep 4, 2020

Instead of 'erase-buffer', how about using 'comint-clear-buffer', which works regardless of comint-prompt-read-only.
Note that it should be called after the comint buffer is created like below:

diff --git a/python-pytest.el b/python-pytest.el
index 1f5ba4c..5b9d569 100644
--- a/python-pytest.el
+++ b/python-pytest.el
@@ -374,7 +374,6 @@ With a prefix ARG, allow editing."
           (user-error "Aborting; pytest still running")))
       (when process
         (delete-process process))
-      (erase-buffer)
       (unless (eq major-mode 'python-pytest-mode)
         (python-pytest-mode))
       (compilation-forget-errors)
@@ -387,6 +386,7 @@ With a prefix ARG, allow editing."
          nil t))
       (run-hooks 'python-pytest-setup-hook)
       (make-comint-in-buffer "pytest" buffer "sh" nil "-c" command)
+      (comint-clear-buffer)
       (run-hooks 'python-pytest-started-hook)
       (setq process (get-buffer-process buffer))
       (set-process-sentinel process #'python-pytest--process-sentinel)

@wbolster
Copy link
Owner

wbolster commented Sep 4, 2020

wouldn't that clear the buffer after starting the process? that's a race condition that can cause output to get lost i think? 🤔

@pinetr2e
Copy link

pinetr2e commented Sep 5, 2020

You are right. I did not consider that make-comint-in-buffer starts the process right away.
I just tried to find a simpler way but it seems that it was not so great.

By the way, the change in this PR, relying on inhibit-read-only seems to be fine as a proper way. For example, comint-clear-buffer is implemented based on inhibit-read-only in the same way and many other packages do the same.

(comint-prompt-read-only simply does not work and the usage is not designed to be like inhibit-read-only)

@wbolster wbolster merged commit d0a072b into wbolster:master Sep 6, 2020
@wbolster
Copy link
Owner

wbolster commented Sep 6, 2020

inhibit-read-only it is. finally merged... thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants