-
-
Notifications
You must be signed in to change notification settings - Fork 132
StreamSelectLoop: Test suite uses signal constant names in data provider #67
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
Conversation
I'm currently undecided so I won't vote yet. Can we really pass values for these missing constants or should we rather make sure the tests are skipped in this case? |
The tests are skipped when pcntl is not loaded. The problem is that the constants are used in a data provider and PHPUnit will allways call the data provider before the test is skipped from within. An alternative solution would be to do the checks in the data provider and provide defaults. This way one can get rid of notices without defining constants. |
IMHO it makes more sense to make sure the data provider is only invoked if the extension is actually available. If this is not possible, then I would suggest using signal constant names only and accessing values only through the What do you think? |
Using
I changed the code to do the checks in the data provider. I am not aware of any way to prevent the data provider from being called by PHPUnit. Another solution would be to do the signal testing in another test class and do the check in the setup method but that is too much work IMHO. |
From the PHPUnit docs (second blue box):
Also related: sebastianbergmann/phpunit#836 This current solution looks like a good compromise, so i'm 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've recently run into the same while running the test suite on windows, so 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay to me, but consider my comment below anyway 👍
tests/StreamSelectLoopTest.php
Outdated
['SIGTERM', SIGTERM], | ||
['SIGUSR1', defined('SIGUSR1') ? SIGUSR1 : 10], | ||
['SIGHUP', defined('SIGHUP') ? SIGHUP : 1], | ||
['SIGTERM', defined('SIGTERM') ? SIGTERM : 15], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks okay to me. My suggestion would have been to only return the constant names here and then use constant()
to access their values within the test instead. This way we would not have to provide any defaults at all and could still skip the tests (possibly via defined()
). What do you think about this?
Ping @martinschroeder, what do you think about the above suggestion? Also, may I ask you to rebase this on the new "0.4" branch so we get this in for the upcoming v0.4.3 release? |
I've updated the base branch, can you force-push a rebased version? 👍 |
I rebased the PR and changed the data provider to use signal constant names as suggested. |
Define constants
SIGUSR1
,SIGHUP
andSIGTERM
if they are not defined yet. The signal constants are used in data providerStreamSelectLoopTest::signalProvider()
and cause a notice when the pcntl extension is not loaded.