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

Newer PHPUnit versions don't allow for non-existing directories in testsuites #65

Closed
jissereitsma opened this issue Apr 26, 2022 · 5 comments

Comments

@jissereitsma
Copy link
Contributor

In the phpunit.xml file shipped with the ExtDN Integration Tests, there are multiple different directories mentioned for the testsuite. In my personal case, the first folder matches my tests. The other ones are simply included "just in case".

    <testsuites>
        <testsuite name="IntegrationTests">
            <directory suffix="Test.php">../../../vendor/%COMPOSER_NAME%/Test/Integration</directory>
            <directory suffix="Test.php">../../../vendor/%COMPOSER_NAME%/tests/Integration</directory>
            <directory suffix="Test.php">../../../vendor/%COMPOSER_NAME%/tests/integration</directory>
            <directory suffix="Test.php">../../../vendor/%COMPOSER_NAME%/src/Test/Integration</directory>
            <directory suffix="Test.php">../../../vendor/%COMPOSER_NAME%/src/tests/Integration</directory>
            <directory suffix="Test.php">../../../vendor/%COMPOSER_NAME%/src/tests/integration</directory>
        </testsuite>
    </testsuites>

Unfortunately, newer versions of PHPUnit (todo: which ones? well, newer ones, at least with Magento 2.4.4 under PHP 8.1) give a failure when one of these folders is missing. My solution is now to use the PHPUNIT_FILE input or env variables to bring in a new PHUnit file where I remove all non-relevant files. But this is getting annoying.

One possible (breaking) fix would be to let go of the testsuites entirely, simply passing the sources to PHPUnit as an argument. In entrypoint.sh this would change the following last line:

cd $MAGENTO_ROOT/dev/tests/integration && ../../../vendor/bin/phpunit -c phpunit.xml

to:

cd $MAGENTO_ROOT/dev/tests/integration && ../../../vendor/bin/phpunit -c phpunit.xml $GITHUB_WORKSPACE

Another fix would be to remove all lines except the top one. but this would break at least the workflow of @fooman .

Yet another fix would be to make it simpler to override the PHPUnit file. Instead of requiring the PHPUnit variable to be defined in your workflow, we could simply check for a relevant file in the .github/workflows/ folder. But that sounds a bit too magical for me.

@jissereitsma
Copy link
Contributor Author

Ping @fooman @sprankhub

@fredden
Copy link
Contributor

fredden commented Apr 26, 2022

Is it just the directories that need to exist, or do they each need to contain files? Perhaps a mkdir -p would appease the new check.

@fooman
Copy link
Contributor

fooman commented Apr 27, 2022

I think we should be able to adjust this on the fly to make this useful across a range of different ways of adding tests. Just created a PR #66 which should loop over whatever we supply in phpunit.xml and remove any entries which don't exist.

@jissereitsma
Copy link
Contributor Author

@fredden That sounds like an uglier solution. @fooman his PR fixes this on a more fundamental level. I'm going to test this out in the upcoming days.

@jissereitsma
Copy link
Contributor Author

The solution works for me. +1 for closing this.

In the mean time I'm also copying the same solution to unit tests as well.

@fooman fooman closed this as completed Apr 27, 2022
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

3 participants