开发者

Why is PHPUnit in Hudson CI using my localhost path AND my actual filepath?

开发者 https://www.devze.com 2023-01-07 04:05 出处:网络
EDIT 3: Solved. See below. EDIT 2: I think Chadwick\'s on the right track with his comment. Hudson/PHPUnit is taking the localhost (the Hudson workspace) AND my local file structure and using both to

EDIT 3: Solved. See below.

EDIT 2: I think Chadwick's on the right track with his comment. Hudson/PHPUnit is taking the localhost (the Hudson workspace) AND my local file structure and using both to run the unit tests. So it's redeclaring everything that was already declared. Why is this happening and how can I change it?

I've since reported this issue on Hudson's JIRA Server. If I get a resolution there, I'll post here. Otherwise, any help would be appreciated since my builds are going nowhere now.

My build keeps failing and I can't for the life of me understand why. Here's what I get back.

phpunit:
[exec] PHP Fatal error:  Cannot redeclare generate_options() (previously declared in
<http://localhost:8080/job/Goals/ws/Goals/includes/functions/registration_fns.php>:5) in /Users
/joshsmith/Sites/Goals/Goals/includes/functions/registration_fns.php on line 32

But this particular function starts at line 5 and ends at line 32! So what in the world is going on here?

And just so you know PHPUnit works on its own outside of Hudson. Here's my terminal output from a successful test run:

Macintosh:goals joshsmith$ phpunit alltests.class
PHPUnit 3.4.14 by Sebastian Bergmann.

.............................

Time: 14 seconds, Memory: 9.75Mb

OK (29 tests, 67 assertions)

Can anyone help me figure this craziness out?

EDIT: Under Chadwick's suggestion, I tried renami开发者_运维百科ng the function in case it were trying to redeclare a function internal to Hudson. This didn't work, and is clearly some other obscure issue.


This has been solved. It was an issue where I had hardcoded the paths in a single initializer file. As a result, they were being redeclared by PHPUnit.


It sounds like generate_options() is declared both in your registration_fns.php file and in some file by Hudson. PHP function names are global, so this is an inherent risk of combining code from a third party.

One way around it is to rename one of the functions (and of course all calls to it) - you can modify the Hudson code where it is declared, or modify your own, but personally I recommend changing your own. Should you upgrade Hudson in the future, you'd likely have to modify it again.

Since PHP 5.3, you also have the option of using namespaces.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号