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

PHPUnit - BaseCommandParser.php does not read stderr causing TapParser to crash #444

Closed
Roysten opened this issue May 22, 2014 · 5 comments

Comments

@Roysten
Copy link

Roysten commented May 22, 2014

I'm trying to get PHPUnit to work, but I just can't figure out how to configure PHPCI. Running PHPCI without phpci.yml works (successful build), however this does not run PHPUnit. To get PHPUnit to work, I created a very basic phpci.yml, like this:

build_settings:
    clone_depth: 1
    verbose: true
    ignore:
    - "vendor"
    - "tests"

setup:
    composer:
        action: "install"

test:
    php_unit:
        directory:
            - "app/tests/"

I also tried:

test:
    php_unit:

But it just doesn't work, I keep getting:

Working copy created: /�
RUNNING PLUGIN: php_unit
�PLUGIN STATUS: FAILED�

Also tried updating PHPUnit to the latest version, no change. What am I doing wrong?
Running PHPUnit from the vendor/bin folder works fine (so I can't really blame PHPUnit).

PHPCI is able to find the binary, when I enable the logging the log file contains:

[2014-05-23 10:49:04] RunCommand.INFO: RUNNING PLUGIN: php_unit {"buildID":"82"} []
[2014-05-23 10:49:04] RunCommand.DEBUG: Looking for binary: phpunit {"buildID":"82"} []
[2014-05-23 10:49:04] RunCommand.DEBUG: Found in vendor/bin: phpunit {"buildID":"82"} []
[2014-05-23 10:49:04] RunCommand.ERROR: PLUGIN STATUS: FAILED {"buildID":"82"} []
[2014-05-23 10:49:04] RunCommand.INFO: BUILD SUCCESSFUL! {"buildID":"82"} []
[2014-05-23 10:49:04] RunCommand.INFO: Removing build. {"buildID":"82"} []
@antonmarin
Copy link

I had the same problem. That happens because phpci tries to find phpunit in own root directory or in system (using which). To solve that problem you can reconstruct commandExecutor after build creation like:

$this->commandExecutor = new $executorClass(
    $this->buildLogger,
    $this->buildPath,
    $this->quiet,
    $this->verbose
);

at Builder.php:307
Doing so changes rootDir for commandExecutor from root of phpci to root of build

@Roysten
Copy link
Author

Roysten commented May 23, 2014

This doesn't solve my problem. PHPCI can find phpunit, it just doesn't run properly.

@antonmarin
Copy link

Seems like there is another reason...

@Roysten
Copy link
Author

Roysten commented May 23, 2014

OK, I figured it out. I was the problem (PHP newbie) myself: apparently test classes should have the same name as the file they are in. Whoops.
After I corrected my mistake, it still did not work. I copied most parts of the phpci.yml file on the wiki and used that. This phpci.yml contains the following:

test:
    php_unit:
        args: "--stderr"

which will make PHPUnit write all its output to the standard error. This causes an error:

Notice: Undefined offset: -1 [...]

The output of PHPUnit will not be read by BaseCommandExecutor.php. This causes TapParser.php to crash (since it's not a valid TAP format). So I would suggest removing this from the wiki (or let BaseCommandExecutor read stderr 👍 ).

@dancryer
Copy link
Owner

Okay, we've made it so that PHPCI will properly log any errors generated by commands (like PHPUnit, PHPCS, etc) in addition to trying to parse the actual output.

You shouldn't need to use the args: "--stderr" option any more, and in fact, doing so will likely cause the plugin to fail.

If this doesn't resolve the problems you've been seeing, please feel free to reopen this issue.

@dancryer dancryer added this to the Version 1.3 milestone Jul 30, 2014
@dancryer dancryer self-assigned this Jul 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants