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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use EXPECT instead of EXPECTF when possible #3133

Closed
wants to merge 2 commits into from
Closed

Use EXPECT instead of EXPECTF when possible #3133

wants to merge 2 commits into from

Conversation

carusogabriel
Copy link
Contributor

@carusogabriel carusogabriel commented Feb 19, 2018

While refactoring some tests, I've noticed that some of them used EXPECTF without any regular expression or symbol to change. In those cases, EXPECT would be preferred, as its logic in run-tests.php is a lot simpler than EXPECTF.

After some logic, I could verify that it was common across all tests, so I've created a verification in run-tests.php to warning us when this happens, so we can improve it 馃槃

EXPECTF logic in run-tests.php is considerable, so let's avoid it.
@nikic
Copy link
Member

nikic commented Feb 20, 2018

Merged EXPECTF->EXPECT changes via ded3d98 to avoid bit-rot.

I did not merge the second commit, as there's a typo in the variable name which prevents it from ever triggering. I didn't fix this as I'd like to have a CI run on that change, to make sure we don't add any warnings.

Two good follow-up changes would be:

  • Remove support for stuff like %unicode|string%.
  • Change CRLF newlines in tests to LF. I had issues merging this patch because of this.

@nikic nikic closed this Feb 20, 2018
@@ -2123,7 +2123,11 @@ function run_test($php, $file, $env)
@unlink($test_file);
}

if (!$leaked && !$failed_headers) {
// check if EXPECT isn't better
if (isset($section_test['EXPECTF']) && preg_match('/%a|%e|%i|%u|%b|%c|%d|%e|%f|%r|%s|%w|%x/i', $wanted) === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here: $section_test instead of $section_text.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikic Should I fix it and rePR?

@carusogabriel carusogabriel deleted the expectf branch February 20, 2018 21:18
@carusogabriel
Copy link
Contributor Author

Remove support for stuff like %unicode|string%.

@nikic Sure should be easy to do it!

Change CRLF newlines in tests to LF. I had issues merging this patch because of this.

You mean https://stackoverflow.com/a/1552782/4595097? Is so, I'll figure out how to do it 馃槃

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

Successfully merging this pull request may close these issues.

None yet

2 participants