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

Getting "unrecognized option --no-ansi" from phpunit #44

Open
samuell opened this issue Oct 9, 2013 · 10 comments
Open

Getting "unrecognized option --no-ansi" from phpunit #44

samuell opened this issue Oct 9, 2013 · 10 comments
Labels

Comments

@samuell
Copy link

samuell commented Oct 9, 2013

I'm trying to debug my MediaWiki extension, by requiring the MediaWiki testcases.

After getting everything seemingly set up correct

(I do this:

global $IP;
$IP = __DIR__ . '/../../../../../';
define( 'MEDIAWIKI', true );

# Get MWInit class
require_once( "$IP/includes/Init.php" );

# Start the autoloader, so that extensions can derive classes from core files
require_once( "$IP/includes/AutoLoader.php" );

# Load the profiler
require_once( "$IP/includes/profiler/Profiler.php" );

# Load up some global defines.
require_once( "$IP/includes/Defines.php" );

# Some more stuff
#require_once( "$IP/includes/WebStart.php" );
require_once( "$IP/includes/GlobalFunctions.php" );
require_once( "$IP/tests/phpunit/MediaWikiPHPUnitCommand.php" );
require_once( "$IP/tests/phpunit/phpunit.php" );

class RDFImportTest extends MediaWikiTestCase {

    function setUp() {}
    function tearDown() {}

    /**
     * Simple test to see that the PHPUnit test framework
     * (And the MakeGood Eclipse plugin) is correctly set up.
     */
    public function testPhpUnitSetup() {
        $this->assertTrue(true);
    }

}

... I still get this error:

#!/usr/bin/env php
PHPUnit 3.6.10 by Sebastian Bergmann.

unrecognized option --no-ansi

I have grepped through the MediaWiki tests code with:

grep -inr "no-ansi" *

... and have found no reference. OTOH, I found this string in the sources for the MakeGood plugin, in my eclipse plugins folder, so I'm suspecting that that is where this flag is set.

I'm running:

  • Lubuntu 13.04 64 bit
  • PHP 5.4.9
  • PHPUnit 3.6.10
@matsu-hide8
Copy link
Member

This error is raised by using the phpunit.php of the MediaWiki.
Before the MakeGood runs tests, the execution of PHP is terminated by the MediaWiki.

Please change the code not to use it.
(And require the MediaWikiTestCase.php.)

@Ciantic
Copy link

Ciantic commented Dec 17, 2013

I'm getting this error as well. PHPUnit 3.7.28. Is MakeGood using an option that is not recognized anymore?

P.S. I have project which has nothing to do with MediaWiki, I suspect the makegood tries to pass some command line args for phpunit with no reason, no-ansi option has never been in PHPUnit.

@Ciantic
Copy link

Ciantic commented Dec 17, 2013

The problem is in testrunner.php I suspect, I sniffed the command line from the Process Explorer in Windows:

php.exe -c ...\php.ini -d asp_tags=off -d short_open_tag=off \..makegood...\testrunner.php" --no-ansi phpunit --log-junit=....xml --log-junit-realtime --phpunit-config=...

It's not setting --no-ansi to phpunit, but to testrunner.php?

@Ciantic
Copy link

Ciantic commented Dec 17, 2013

Yes, this HACK fixes the problem:

  1. Open the \plugins\com.piece_framework.makegood.stagehandtestrunner_2.5.0.v201311031709\resources\php\bin\testrunner.php

  2. Insert these two lines after the namespace definition:

    array_splice($argv, 1, 1);
    array_splice($_SERVER['argv'], 1, 1);
    

These lines removes the --no-ansi from the command line arguments, you can check this by var_dump($_SERVER['argv']); exit; when the version changes.

@WesWedding
Copy link

Without delving into what MakeGood is doing with --no-ansi, the reason Wordpress in particular can't use MakeGood without a hacky solution (I modified PHPUnit directly so that it ignored unrecognized command line options) is that the Wordpress-tests booststrap.php passes the entire command line to PHPUnit_Util_Getopt::getopt, probably under the assumption that PHPunit is being run directly. The Wordpress-tests boostrap.php is required to run tests in a Wordpress environment.

So, I guess the question is: Is this a Wordpress problem or a MakeGood problem?

@WesWedding
Copy link

I submitted a bug/patch to Wordpress (http://core.trac.wordpress.org/ticket/26725). The problem Ciantic and I had is really because Wordpress does funky things when it bootstraps its test environment, and not really MakeGood's fault.

@iteman
Copy link
Member

iteman commented Dec 27, 2013

Thank you @Stickywes.

MakeGood uses own testrunner command instead of the phpunit command to launch a test run. The testrunner command has own command line arguments and options. So PHPUnit cannot recognize our command line.

@TRPB
Copy link

TRPB commented Apr 30, 2014

I'm not using wordpress but have the same issue. Unfortunately, if I try the array_splice hack above I get the error:

#!/usr/bin/env php
PHPUnit 3.7.32 by Sebastian Bergmann.

Cannot open file "--log-junit=/tmp/com.piece_framework.makegood.launch/MakeGood1398899990790.xml".

Clearly the file name should not have the --log-junit= prefix. The phpunit documentation ( http://phpunit.de/manual/3.7/en/textui.html ) suggests it should be --log-junit not, --log-junit= but removing the equals sign makes no difference and test still cannot be run. I've been struggling for quite some time to get MakeGood working and nothing I do seems to help.

@iteman
Copy link
Member

iteman commented May 1, 2014

@TomBZombie An error "unrecognized option --no-ansi" will be raised only if PHPUnit_TextUI_Command::handleArguments() is called in the test run. Since MakeGood never use PHPUnit_TextUI_Command as the command line parser for PHPUnit, I think that PHPUnit_TextUI_Command::handleArguments() would be called by your test environment.

@abrarkhan1234
Copy link

Getting the same issue for Eclipse Luna, unable to find the code for the plugin which @Ciantic has suggested needs to be tweaked. Can you advise how I can find it?

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

No branches or pull requests

7 participants