jorgenschaefer / emacs-buttercup

Behavior-Driven Emacs Lisp Testing
GNU General Public License v3.0
364 stars 44 forks source link

Missing colors in compilation buffer #171

Closed Alexander-Miller closed 4 years ago

Alexander-Miller commented 4 years ago

I would like to have the same output (or at least something close) in Emacs compilation buffers as I have when running buttercup from the shell: https://imgur.com/a/U9a3pzE

But as you can see the colors for the individual tests are missing. I use the following code to translate ansi colors:

(defun colorize-compilation ()
  (let ((inhibit-read-only t))
    (ansi-color-apply-on-region compilation-filter-start (point))))
(add-hook 'compilation-filter-hook #'colorize-compilation)

It does work in general since the 0 failed part is correctly made green.

Also without this hook I only see escape sequences to reset the color, but not to set it: https://imgur.com/a/x2qStz8, so I'm not sure whether this is a bug report or a feature request, but it'd be great if it was possible to make left and right look the same in these pictures.

snogge commented 4 years ago

@Alexander-Miller, can you see if #172 works for you? I still see the first one or two color codes as garbage output:

Running 146 specs.

The buttercup-failed signal
  can be raised (13.75ms)

The buttercup-pending signal
  can be raised (0.07ms)
snogge commented 4 years ago

On second though, the ANSI codes that are not interpreted probably depends on how the input happens to be processed by the compilation process and is passed to it's input filer compilation-filter. This commit has no way to guarantee that the codes are interpreted correcvtly, it just makes them available to compilation-filter which is then free to screw it up.

snogge commented 4 years ago

But this fix and running compile in comint-mode seems to do the trick.

Alexander-Miller commented 4 years ago

can you see if #172 works for you?

No, I don't see any difference at all.

running compile in comint-mode

That did not have any effect either.

snogge commented 4 years ago

You do not see the opening escape sequences either?

This is odd. I use the same compilation-filter-hook as you and it makes a difference for me. What version of Emacs are you using?

Alexander-Miller commented 4 years ago

You do not see the opening escape sequences either?

Not in my output, no. If you want to run the same command as I you can just clone treemacs and run make test.

What version of Emacs are you using?

Emacs 26.3 on Manjaro.

snogge commented 4 years ago

The treemacs tests are colorized - with the same caveats as above - on Emacs master. I'll have to test on Emacs 26.3 too.

snogge commented 4 years ago

I've just tested the treemacs tests on Emacs 26.3 (built locally) on Debian 10. The output is colorized with some exceptions as above. Are you sure you included the patch in #172? I've not merged it to master yet.

snogge commented 4 years ago

And with

(defun colorize-compilation-buffer ()
  (let ((inhibit-read-only t))
    (ansi-color-apply-on-region (save-excursion 
                                   (goto-char compilation-filter-start) 
                                   (line-beginning-position))
                                 (point))))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)

the last remaining ANSI codes will also be processed.

Alexander-Miller commented 4 years ago

My bad - I made a stupid mistake - I should've updated the buttercup in my .cask instead of the one downloaded by my package manager.

Using your branch in the right spot makes the colors look as in the terminal :+1: