mikeerickson / phpunit-pretty-result-printer

PHPUnit Pretty Result Printer -- make your PHPUnit tests look pretty!
MIT License
1.2k stars 71 forks source link

Missing files #118

Closed bueltge closed 6 years ago

bueltge commented 6 years ago

At first thanks a lot for your library that me get a really fast overview about my tests. I use it since linger times.

Currently I have problems in a project, that use the library. Aftercomposer update the version 0.20.1 is active and I get always the error message

PHP Fatal error:  Uncaught Noodlehaus\Exception\FileNotFoundException: Configuration file: [/home/travis/build/bueltge/marksimple/vendor/codedungeon/phpunit-result-printer/phpunit-printer.yml] cannot be found in /home/travis/build/bueltge/marksimple/vendor/hassankhan/config/src/Config.php:173
Stack trace:
#0 /home/travis/build/bueltge/marksimple/vendor/hassankhan/config/src/Config.php(54): Noodlehaus\Config->getValidPath('/home/travis/bu...')
#1 /home/travis/build/bueltge/marksimple/vendor/codedungeon/phpunit-result-printer/src/PrinterTrait.php(76): Noodlehaus\Config->__construct('/home/travis/bu...')
#2 /home/travis/build/bueltge/marksimple/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(287): Codedungeon\PHPUnitPrettyResultPrinter\Printer->__construct(NULL, false, 'auto', false, 80, false)
#3 /home/travis/build/bueltge/marksimple/vendor/phpunit/phpunit/src/TextUI/Command.php(212): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true)
#4 /home/travis/build/bueltge/marksimple/vendor/phpunit/phpuni in /home/travis/build/bueltge/marksimple/vendor/hassankhan/config/src/Config.php on line 173
Fatal error: Uncaught Noodlehaus\Exception\FileNotFoundException: Configuration file: [/home/travis/build/bueltge/marksimple/vendor/codedungeon/phpunit-result-printer/phpunit-printer.yml] cannot be found in /home/travis/build/bueltge/marksimple/vendor/hassankhan/config/src/Config.php on line 173
Noodlehaus\Exception\FileNotFoundException: Configuration file: [/home/travis/build/bueltge/marksimple/vendor/codedungeon/phpunit-result-printer/phpunit-printer.yml] cannot be found in /home/travis/build/bueltge/marksimple/vendor/hassankhan/config/src/Config.php on line 173

Maybe you have a hint for me, always the init. php and the json file is missed.

The problem is still existent on local client and also on travis. That's my composer.json for the dependencies:

    "require-dev": {
        "phpunit/phpunit": "6.3.*",
        "codedungeon/phpunit-result-printer": "^0.20",
        "inpsyde/php-coding-standards": "^0.13",
        "antecedent/patchwork": "^2.1",
        "dg/composer-cleaner": "^2"
    },
mikeerickson commented 6 years ago

Quite puzzling as some of the files missing appear to also be PHPUnit files. Could you trying uninstall and reinstalling PHPUnit and result printer. Maybe a permissions issue as well.

bueltge commented 6 years ago

I have tried this i several different updates, no chance to get the missing files. I opened this issue because the problem is still existent on Travis, see the log file on this example project - https://travis-ci.org/bueltge/marksimple/jobs/429185866 So I think is not a permission problem, is on my local machine and also on Travis client.

However thanks for your fast reply!

mikeerickson commented 6 years ago

@bueltge my apologies for issue. I will get this resolved tomorrow when I return to work. Try to keep family time sacred on weekends 🤓

mikeerickson commented 6 years ago

@bueltge can you please try using the following command in terminal. I am really puzzled on this one. I have tried a variety of methods to reproduce this, but it always works

composer require codedungeon/phpunit-result-printer --update-with-all-dependencies

In addition, perhaps delete the existing package (and remove entry from composer.json)

rm -rf vendor/codedungeon/phpunit-result-printer

After deletion, then run the composer command above

bueltge commented 6 years ago

Hi @mikeerickson Thanks for your feedback.

At first I tried to remove the the entry from the composer.json "codedungeon/phpunit-result-printer": "^0.20" on require-dev and after a composer update the directory vendor/codedungeon/ is deleted. So that rm -rf vendor/codedungeon/.. is not possible.

Now I tried to add the package completely new with composer require codedungeon/phpunit-result-printer --update-with-all-dependencies. This add the package to require of my `composer.json.

the output of the temrinal:

/v/w/marksimple (master) $ composer require codedungeon/phpunit-result-printer --update-with-all-dependencies
Using version ^0.20.1 for codedungeon/phpunit-result-printer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 6 installs, 0 updates, 0 removals
  - Installing 2bj/phanybar (v1.0.0): Loading from cache
  - Installing codedungeon/php-cli-colors (1.10.7): Loading from cache
  - Installing symfony/polyfill-ctype (v1.9.0): Loading from cache
  - Installing symfony/yaml (v4.1.4): Loading from cache
  - Installing hassankhan/config (1.1.0): Loading from cache
  - Installing codedungeon/phpunit-result-printer (0.20.1): Loading from cache
symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)

The package is now on the local machine installed, however also without init.php and the json file, only this directory structure:

Thanks for an other idea?

mikeerickson commented 6 years ago

What is your operating system?

bueltge commented 6 years ago

Linux, Ubuntu 18.04 lte

mikeerickson commented 6 years ago

@bueltge I have published a new version 0.20.3 which is now passing all travis tests and I am able to install into the same configuration you have described above (using a docker container)

Can you please test this build and let me know if you still have issues.

bueltge commented 6 years ago

Hi @mikeerickson Now I found the time to play again, but always the same problem. Yes it updates to 0.20.3, but the files are also missed. Only the this directory structure

mikeerickson commented 6 years ago

My goodness, this is so bizarre. I am at a loss as to what could be interfering. If you install 0.20.1 does it work?

bueltge commented 6 years ago

No, update to the lower version 0.20.1 have the same result.

I have also try to create a completely new project, new directory and start from zero, only a composer.json include the require-dev definition. In this test I tried also to remove all files in vendor and all in .composer/cache. So should remove all local dependencies, caching topics. The result on composer install for your package

  - Installing hassankhan/config (0.11.2): Downloading (100%)         
  - Installing codedungeon/phpunit-result-printer (0.20.3): Downloading (connectDownloading (100%)   

After this the same problem, only the directory structure like above and missing the files outside this, also the init.php.

mikeerickson commented 6 years ago

If any of you are using the same machine configuration as defined by @bueltge could you please see if you are experiencing the same issue? I am really puzzled on this one as it works fine here

Environment where it appears to cause issues
Linux, Ubuntu 18.04 lte

I have tested using

bueltge commented 6 years ago

Hi @mikeerickson thanks for your time and willing to help. I check a lot fo thinks, but I can't find any problem. I checked also all packages there I use and in each package, the first directory below from vendor/username is always only a directory, never a single file. So that I mean you should all files include in src. In each directory of other projects is it only the same structure

I use composer version: 1.7.2 2018-08-16 16:57:12

As example from my side please see https://github.com/inpsyde/php-coding-standards/ Also in if I use this repo I get only

bueltge commented 6 years ago

Additional idea. I think I get always only the files in src, defined in your composer.json. Maybe you should add this two important files as require, see composer schema.

I mean like below:

  "autoload": {
    "psr-4": {
      "Codedungeon\\PHPUnitPrettyResultPrinter\\": "src/"
    },
    "files": [init.php, phpunit-printer.yml]
  },
mikeerickson commented 6 years ago

@bueltge I have adjusted the composer.json to include these references. If you could please test 0.21.0 https://github.com/mikeerickson/phpunit-pretty-result-printer/releases/tag/0.21.0 and let me know if it cures your issue, I would greatly appreciate it.

bueltge commented 6 years ago

It works! :tada:

Now, after a simple composer update are this two files are include the directory of the project codedungeon/phpunit-result-printer.

my terminal:

/v/w/marksimple (master) $ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Updating codedungeon/phpunit-result-printer (0.20.3 => 0.21.0): Downloading Downloading (100%)         
Writing lock file
Generating optimized autoload files
PHP CodeSniffer Config installed_paths set to ../../wp-coding-standards/wpcs/,../../automattic/phpcs-neutron-standard/,../../inpsyde/php-coding-standards/,../../wimg/php-compatibility/
Composer cleaner: Removed 10 files or directories.
/v/w/marksimple (master) $ vendor/bin/phpunit 

==> Configuring phpunit-pretty-result-printer

    [•  ] Gathering installation details
    [•• ] Printer class already configured in ./phpunit.xml.dist 
    [•••] Configuration ./phpunit-printer.yml already exists

==> Configuration Complete
options:
  cd-printer-hide-class: false
  cd-printer-simple-output: false
  cd-printer-show-config: true
  cd-printer-hide-namespace: false
  cd-printer-anybar: false
  cd-printer-anybar-port: 1738
markers:
  cd-pass: "✓ "
  cd-fail: "✖ "
  cd-error: "⚈ "
  cd-skipped: "→ "
  cd-incomplete: "∅ "

And the result inside my file browser: image

Really great, thanks a lot for your patience and quick trials.

Only a small problem. Now the Configuring phpunit-pretty-result-printer run always on each phpunit run. I think the init.php run always on each run of phpunit.

wells commented 6 years ago

v0.21 also creates a phpunit-printer.yml file in my application directory whenever php runs, whereas before it silently used a default configuration.

I can also confirm that it displays configuration on every php unit run on macOS.

~ phpunit

==> Configuring phpunit-pretty-result-printer

    [•  ] Gathering installation details
    [•• ] Printer class already configured in ./phpunit.xml
    [•••] Configuration ./phpunit-printer.yml already exists

==> Configuration Complete
options:
  cd-printer-hide-class: false
  cd-printer-simple-output: false
  cd-printer-show-config: true
  cd-printer-hide-namespace: false
  cd-printer-anybar: false
  cd-printer-anybar-port: 1738
markers:
  cd-pass: "✓ "
  cd-fail: "✖ "
  cd-error: "⚈ "
  cd-skipped: "→ "
  cd-incomplete: "∅ "
  cd-risky: "⌽ "
PHPUnit Pretty Result Printer 0.21.0 by Codedungeon and contributors.
mikeerickson commented 6 years ago

I have already seen this issue (that is an artifact of the addition of files in the files section of autoload. I have removed these items as that is NOT the cure to this problem (there has been a new version posted 0.21.1 which addresses this very issue)

These items are included everytime phpunit is executed which is NOT how it should work. So, the fix causes additional issues :-(

You can "fix" the above issue by removing the autoload - files items

mikeerickson commented 6 years ago

@bueltge BUT, I have a solution (just thought about this) Let me give it a whirl here and see what happens

bueltge commented 6 years ago

I think the solution on the way, before goal. No worries and thanks a lot.

mikeerickson commented 6 years ago

@bueltge OK, I think I have a working solution. Will you be around to test? What time is it where you live? I am in USA PST (it is 1231 right now)

bueltge commented 6 years ago

I'm in Europe, Germany, timezone Berlin. Currently 2131. I can test for now, also for the next 1h. But never after Sunday, 2 weeks holiday offline.

mikeerickson commented 6 years ago

OK, I will be posting a new build 0.22.0 now

mikeerickson commented 6 years ago

Note: The init command should be as follows (moved the init.php and phpunit-printer.yml files into src directory(

php ./vendor/codedungeon/phpunit-result-printer/src/init.php

bueltge commented 6 years ago

:tada: No problems with this version. All files are in srcand it works. The call via console to the init.php works also really well. Thanks a lot!

/v/w/marksimple (master) $ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Updating codedungeon/phpunit-result-printer (0.21.0 => 0.22.0): Downloading Downloading (100%)         
Writing lock file
Generating optimized autoload files
PHP CodeSniffer Config installed_paths set to ../../inpsyde/php-coding-standards/,../../wimg/php-compatibility/,../../wp-coding-standards/wpcs/,../../automattic/phpcs-neutron-standard/
Composer cleaner: Removed 10 files or directories.

Run of src/init.php

/v/w/marksimple (master) $ php ./vendor/codedungeon/phpunit-result-printer/src/init.php

==> Configuring phpunit-pretty-result-printer

    [•  ] Gathering installation details
    [•• ] Printer class already configured in ./phpunit.xml.dist 
    [•••] Configuration ./phpunit-printer.yml already exists

Resulting in tests image

mikeerickson commented 6 years ago

@bueltge Awesome! Thanks for confirmation and enjoy your holiday :-)

bueltge commented 6 years ago

Thanks a lot! Nice result before holidays and time to tag version 1.0.0 :+1: