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

"FAILURES!" = Pass #104

Closed
nunoperalta opened this issue Dec 8, 2021 · 2 comments
Closed

"FAILURES!" = Pass #104

nunoperalta opened this issue Dec 8, 2021 · 2 comments

Comments

@nunoperalta
Copy link

nunoperalta commented Dec 8, 2021

I run PHPUnit in Docker (I develop on Windows), with these settings:

Workspace settings:

		"phpunit.php": "",
		"phpunit.phpunit": "C:\\node\\npm.cmd",
		"phpunit.args": ["run", "build-runtests", "--"],
		"phpunit.relativeFilePath": true,
		"phpunit.remoteCwd": "/opt/app/",
		"phpunit.files": "myapp/tests/*Test.php",

packages.json:

"build-runtests": "gulp build-debug && docker-compose run --rm --entrypoint 'php' myapp /opt/app/myapp/tests/run_phpunit.php",

My run_phpunit.php basically runs the test(s), prints the output, and returns a proper return code (would be "1" if tests fail).
I confirm that it's definitely returning the right error code.

The problem I have with this is that if there are tests that fail, I'm still seeing a green success icon:

image

After several experiments, I realized that as long as the output contains "FAILURES!", the test will be successful.

run_phpunit.php:

    echo "FAILURES!";
    exit(1);

image

run_phpunit.php:

    echo "SUCCESS!";
    exit(1);

image

I'm using testdox="true" in my phpunit.xml, btw.

Somehow, it appears to me that this extension is looking at the output, rather than relying on the exit code,
and there's a bug in the way it looks at the output.

To fix this, I'm changing my run_phpunit.php so that if there are failures, it will replace "FAILURES!" with something else...

run_phpunit.php:

    $rc = null;
    $cmd_output_ar = array();
    exec($cmd, $cmd_output_ar, $rc);
    $output = implode("\n", $cmd_output_ar);
    echo str_replace('FAILURES!', '', $output);

image

@recca0120
Copy link
Owner

try verions 3.0

@nunoperalta
Copy link
Author

Thank you very much! That seems to be fixed.

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

2 participants