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

HHVM: Class already declared: PHPUnit_Framework_Error #1684

Closed
splitbrain opened this issue Apr 17, 2015 · 20 comments
Closed

HHVM: Class already declared: PHPUnit_Framework_Error #1684

splitbrain opened this issue Apr 17, 2015 · 20 comments

Comments

@splitbrain
Copy link

I'm trying to get started with testing with HipHopVM, however I have trouble even get it to run:

$ hhvm --version
HipHop VM 3.6.1 (rel)
Compiler: 1428401411_698854969
Repo schema: 479647c3ad87f2e920ac085aa1424e2b8101da45

All the available phpunit versions throw the same error:

$ php phpunit.phar --version
PHPUnit 4.6.4 by Sebastian Bergmann and contributors.
$ hhvm phpunit.phar --version
Fatal error: Class already declared: PHPUnit_Framework_Error in phar://phpunit-4.6.4.phar/phpunit/Util/../Framework/Error.php on line 22

$ php phpunit-beta.phar --version
PHPUnit beta-2015-04-17 by Sebastian Bergmann and contributors.
$ hhvm phpunit-beta.phar --version
Fatal error: Class already declared: PHPUnit_Framework_Error in phar://phpunit-beta-2015-04-17.phar/phpunit/Util/../Framework/Error.php on line 22

$ php phpunit-alpha.phar --version
PHPUnit alpha-2015-04-17 by Sebastian Bergmann and contributors.
$ hhvm phpunit-alpha.phar --version
Fatal error: Class already declared: PHPUnit_Framework_Error in phar://phpunit-alpha-2015-04-17.phar/phpunit/Util/../Framework/Error.php on line 22

Any idea what's wrong?

@machee
Copy link

machee commented Apr 23, 2015

Having the same trouble with HHVM 3.6.1 and PHPUnit 4.6.1-4.6.4. PHPUnit 4.5.1 works for me as a work around.

https://phar.phpunit.de/phpunit-4.5.1.phar

I do wonder if master/nightly HHVM works with PHPUnit 4.6.4 but haven't tried it.

@thunderer
Copy link

Got the same error while running HHVM build in JoliCI (PHPUnit 4.6.4):

Step 8 : CMD /bin/bash -c -l "cd $WORKDIR && phpunit"
 ---> Running in bd1c9df892ae
 ---> 4a4d3958f69f
Removing intermediate container bd1c9df892ae
Successfully built 4a4d3958f69f

Fatal error: Class already declared: PHPUnit_Framework_Error in phar://phpunit-4.6.4.phar/phpunit/Util/../Framework/Error.php on line 22

Fatal error: Class already declared: PHPUnit_Framework_Error in phar://phpunit-4.6.4.phar/phpunit/Util/../Framework/Error.php on line 22

@SimplyCorey
Copy link

Same issue here.

Fatal error: Class already declared: PHPUnit_Framework_Error in phar://phpunit-     4.6.4.phar/phpunit/Util/../Framework/Error.php on line 22
The command "phpunit --bootstrap tests/bootstrap.php --configuration phpunit.xml tests" exited with 255.
Done. Your build exited with 1.

@koriym
Copy link

koriym commented Apr 28, 2015

Same issue here, too.

$ phpunit --coverage-text --coverage-clover=coverage.clover
Fatal error: Class already declared: PHPUnit_Framework_Error in phar://phpunit-4.6.4.phar/phpunit/Util/../Framework/Error.php on line 22
The command "phpunit --coverage-text --coverage-clover=coverage.clover" exited with 255.

@kinosang
Copy link

Get the same error with HHVM 3.6.1 on Travis CI

$ phpunit
Fatal error: Class already declared: PHPUnit_Framework_Error in phar://phpunit-4.6.4.phar/phpunit/Util/../Framework/Error.php on line 22
The command "phpunit" exited with 255.

@sebastianbergmann
Copy link
Owner

The PHAR works fine with PHP. If it does not work with HHVM then that would be an HHVM issue and not a PHPUnit issue.

@kinosang
Copy link

@sebastianbergmann It works well for me with HHVM on Travis CI yesterday. I don't know if it caused by the changes of my project or others.

@zachborboa
Copy link

+label: 2015-04 build update issue?

@spiritix
Copy link

This was working yesterday, seems to be related to the last Travis CI rollout.
travis-ci/travis-ci#3790

@philsturgeon
Copy link

I've implemented this workaround from @colinodell, and it just uses composer if its HHVM.

I think HHVM need to fix this, or Travis, but whatever, this got me green again.

@fredemmott
Copy link
Contributor

It looks like this is triggered by:

  • swapping from an autoload-based phar to a huge pile of requires at the top
  • PHPUnit_Framework_Error is now required twice, with different paths. My guess is that HHVM's failing to normalize the paths within the phar properly, and not realizing they're the same file.

@sebastianbergmann
Copy link
Owner

Thanks for looking into this, @fredemmott.

@stof
Copy link
Contributor

stof commented Apr 29, 2015

@sebastianbergmann the requirement added in #125 seems to rely on the include path being set. What about using absolute paths instead (__DIR__.'/../Framework/Error/Notice.php'). It may solve the issue with the double requirement.

@sebastianbergmann
Copy link
Owner

@stof Good point. Can you send a pull request?

@stof
Copy link
Contributor

stof commented Apr 29, 2015

hmm, actually, it has already been changed in a3dcfcb
So this looks weird

@stof
Copy link
Contributor

stof commented Apr 29, 2015

OK, the issue is that HHVM does not resolve paths properly inside phars, so the require_once are considering that they are 2 files: facebook/hhvm#5215. Maybe uding dirname() rather than .. would solve this

stof added a commit to stof/phpunit that referenced this issue Apr 29, 2015
…them in phars

This avoids loading the file twice on HHVM because it considers the 2 paths to be different even though they reference the same file when normalized.
Refs sebastianbergmann#1684
@stof
Copy link
Contributor

stof commented Apr 29, 2015

OK, here is a PR

@joni2back
Copy link

I just added new php file to my project (~20min ago) (joni2back/php-classic@bd09ad2) after a long time.
So, travis test fails testing hhvm travis.yml

Fatal error: Class already declared: PHPUnit_Framework_Error in phar://phpunit-4.6.4.phar/phpunit/Util/../Framework/Error.php on line 22
The command "phpunit --configuration phpunit.xml --coverage-text" exited with 255.

@sebastianbergmann
Copy link
Owner

@joni2back The fix will be in PHPUnit 4.6.6.

@fredemmott
Copy link
Contributor

@sebastianbergmann : yep - the pile of requires /should/ be a perfectly fine approach, and that not working is an HHVM bug. It looks like we include phar:// like any other stream, path normalization on streams is generally not a good idea, but we might need to special-case this :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests