nlamirault / phpunit.el

Emacs mode to phpunit and test command line tool
GNU General Public License v2.0
34 stars 19 forks source link

phpunit-group gives error: Search failed: "Available test group" #40

Open CarwynNelson opened 7 years ago

CarwynNelson commented 7 years ago

Hi,

I recently, thanks to help from zonuexe, managed to get emacs set up so that it would run unit tests through a docker container. Running the whole test suite, test classes and individual test functions works just fine and it's a treat to finally not have to switch to a terminal window to run my test suite. However when I try to run phpunit-group I get the following eroror message:

Search failed: "Available test group"

I've tracked it down to this function in the phpunit.el file (complete emacs-list noob by the way)

(defun phpunit--listing-groups ()
  "Return list of @group.

https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.group"
  (let ((phpunit-output (phpunit--execute "--list-groups")))
    (with-temp-buffer
      (insert phpunit-output)
      (goto-char (point-min))
      (search-forward "Available test group")
      (move-beginning-of-line 1)
      (next-line)
      (cl-loop
       for line in (s-split "\n" (buffer-substring-no-properties (point) (point-max)))
       if (s-starts-with? " - " line)
       collect (s-chop-prefix " - " line)))))

I had thought that maybe this was occurring because the docker command was not returning any available groups. I'm not sure this is the case anymore though, this is the output from running phpunit --list-groups from the docker container:

PHPUnit 4.8.28 by Sebastian Bergmann and contributors.

Available test group(s):
 - a
- bunch
- of
- groups
- here

Here is the output from emacs --version

GNU Emacs 26.0.50.2
Copyright (C) 2016 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

I have tried this on another project which does not require tests to be run from the docker container and it appears to be working correctly. Here is the output from phpunit --list-groups on that project:

PHPUnit 4.8.24-1-g1a1b632 by Sebastian Bergmann and contributors.

Available test group(s):
 - default
 - test

I can't really tell the difference between the two except for one of the projects has quite a lot of test groups and the other one doesn't.

Any help would be greatly appreciated :)

CarwynNelson commented 7 years ago

Just an update on this after some further testing.

I have turned off the tests that require the docker container so that I could run phpunit from my local machine and this is what I found. If I run the unit tests without the docker container then phpunit-group seems to work just fine - however if I try to run phunit-group through the docker container the command fails.

So I'm assuming that the bug should be easily reproducible by trying to run phpunit-group through a docker container.

Hope this helps.

zonuexe commented 7 years ago

hmm... I did not see the same problem as that. (I am a beginner, so I do not understand what Docker is doing.)

megurine % ./vendor/bin/phpunit --list-groups
PHPUnit 4.8.31 by Sebastian Bergmann and contributors.

Available test group(s):
 - USAMI Kenta <tadsan@zonu.me>
 - default
 - fizzbuzz
 - foobar
megurine % docker run -it --rm -v `pwd`:/work:ro -w /work hoge:fuga vendor/bin/phpunit --list-groups
PHPUnit 4.8.31 by Sebastian Bergmann and contributors.

Available test group(s):
 - USAMI Kenta <tadsan@zonu.me>
 - default
 - fizzbuzz
 - foobar

My Dockerfile is follows:

FROM php:7.0-fpm
RUN apt-get update && apt-get install -y \
        libicu-dev \
    && docker-php-ext-install -j$(nproc) intl
CarwynNelson commented 7 years ago

Hi @zonuexe

Thanks for the response! I've been quite busy so I haven't had the chance to try this with some other docker configurations to try and replicate the issue.

I'm planning to look into it further within the next few days so that I can provide some more information on why this may be happening.

Thanks :)