Closed mister-good-deal closed 2 years ago
What happens if you run pest outside the docker env?
@nunomaduro Seems like the --coverage
option is not even parsed.
The tests runs (with some failures because I didn't install all the services in my local env only PHP8-1 with composer and xdebug) and then nohing.
./vendor/bin/pest --coverage
output
...
Tests: 11 failed, 45 passed, -2 pending
Time: 1.86s
If I run specific sucessfull tests on a group I have the following
./vendor/bin/pest --coverage --group=Account
PASS Tests\Feature\Commands\AccountAddTest
✓ Account add command is successful with ('https://www.linkedin.com/in/t...ccount')
✓ Account add command is successful with ('http://www.linkedin.com/in/te...t56846')
✓ Account add command is successful with ('www.linkedin.com/in/vzrevzre')
✓ Account add command is successful with ('https://fr.linkedin.com/in/test')
✓ Account add command is successful with ('http://fr.linkedin.com/in/testvds')
✓ Account add command is successful with ('fr.linkedin.com/in/poezfpezf')
✓ Accounts were correctly added to the list file
✓ Account add command fails with ('linkedin.com/in/test-account')
✓ Account add command fails with ('https://www.linkedin.com/test...t56846')
✓ Account add command fails with ('https://www.inkedin.com/in/vzrevzre')
✓ Account add command fails with ('https://frr.linkedin.com/in/poezfpezf')
✓ Account add command fails with ('https://de.linkedin.com/in/test')
✓ Accounts were not added to the list file
PASS Tests\Feature\Commands\AccountDisplayTest
✓ Account display command is successful
✓ Account display command return the correct output
PASS Tests\Feature\Commands\AccountRemoveTest
✓ Account remove command is successful with (5)
✓ Account remove command is successful with (0)
✓ Account remove command is successful with (2)
✓ Account remove command is successful with ('1')
✓ Account remove command is successful with ('3')
✓ Accounts were correctly removed from the list file
✓ Account remove command fails with (-2)
✓ Account remove command fails with (-3)
✓ Account remove command fails with ('123')
✓ Account remove command fails with ('abc')
✓ Account remove command fails with (8)
✓ Account remove command fails with (9)
Tests: 27 passed
Time: 0.97s
The "--coverage" option does not exist.
list [--raw] [--format FORMAT] [--short] [--] [<namespace>]
And if i change the argument order the command ends with the following
output
/vendor/bin/pest --group=Account --coverage
...
Tests: 27 passed
Time: 0.97s
The "--group" option does not exist.
list [--raw] [--format FORMAT] [--short] [--] [<namespace>]
I run it using docker (lando), and have no such issue. Works both from CLI and from phpstorm. Can you explain step by step, how you are running the command? Is it run through docker run
or similar?
I have a docker-compose.yaml
file with couple of services like ElasticSearch / Kibana and a php 8 alpine env with the following
Dockerfile
FROM php:8.1-alpine
ENV DEBIAN_FRONTEND noninteractive
# Setup server timezone
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone
# Install dev tools
RUN apk add --update bash bash-completion
# Configure bash completion
RUN mkdir /etc/bash_completion.d
SHELL ["/bin/bash", "-c"]
# Use docker-php-entension-installer to install composer and xdebug https://github.com/mlocati/docker-php-extension-installer
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
# Install PHP Composer
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions @composer
WORKDIR /app
# Install Composer deps
ADD . /app
RUN composer install
# Add bash auto completion for app cli
RUN ./app completion bash > /etc/bash_completion.d/symphony.sh
Then I start the services in background with docker-compose up -d
.
Finally I login into the php container with docker exec -it -e SHELL=bash php-container-cli bash
in a terminal and I can run my commands in the Symfony php console app.
Oh maybe the problem is the entrypoint script :
# Hack for not shutting down the cli
tail -f /dev/null
It all sounds exactly how I would do it. One question. What does this mean?
I can run my commands in the Symfony php console app.
Are you running some symfony command before running pest ?
Any chance you could make a tiny example repo on github that we can try out to recreate the error?
@sinnbeck
I can run my commands in the Symfony php console app.
Just meaning after login to the php container in a console I call ./app my-command
to use the php Symfony application.
The app file is a php file starting with a shebang #!/usr/bin/env php
and containing app launcher logic.
But I don't call the app before launching the tests, I run ./vendor/bin/pest
right after entering the php container.
Strange thing is that all tests are running good but there is this strange --coverage
option that fails.
I'll try to create a minimal reproducible example in a public repo and I'll post the link there.
There it is => minimal-reproducible-example
@ZiperRom1 That is indeed strange! I can recreate it with your docker image and I even tested it with lando. In all of my own apps (running laravel instead of symfony) it works.. I will try and get it working but I am quite unsure what the problem is. Perhaps someone can test it outside of docker?
Ok I found the error. @nunomaduro This might be a problem with pest due to a wrong error message or similar?
@ZiperRom1 Open phpunit.xml and remove
<directory suffix=".php">./app</directory>
from <coverage>
and it starts working
You rock! Thank you, I was banging my head to find out what config settings I was missing...
Indeed a tiny sand dust in a config file resulting in a strange behaviour.
Hi,
Docker env
PHP 8.1.6 Pest 1.21.2 PHPUnit 9.5.20 xdebug 3.1.4
xdebug.mode=develop,debug,coverage
Bug
When I run
./vendor/bin/pest --coverage
all the tests are being run but at the end I haveThe "--coverage" option does not exist.
output.Sample output