Skip to content

run-tests.php: class for test file loading #6678

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

Closed
wants to merge 1 commit into from

Conversation

MaxSem
Copy link
Contributor

@MaxSem MaxSem commented Feb 10, 2021

This moves a bunch of code outside of run_tests(), making it a bit
more manageable. Additionally, accessors provide better readability
than isset() and friends.

This is a minimal patch that moves the code but does not refactor
much. For the sake of reviewing experience, it does not involve
further refactoring which could include:

  • Removing setSection()
  • Fixing up the mess with hasSection() vs. sectionNotEmpty(), only
    one of which is really needed.
  • Moving more repetitive code into the new class.
    All of this will be done with later commits.

Verification:

  • compared test results with and without this patch
  • ./run-tests.php ext/phar --repeat 2 produces no failures.

$tested = $test->getName();

if ($num_repeats > 1 && $test->hasSection('FILE_EXTERNAL')) {
return skip_test($tested, $tested_file, $shortname, 'Test with FILE_EXTERNAL might not be repeatable');
Copy link
Member

@nikic nikic Feb 15, 2021

Choose a reason for hiding this comment

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

Did you verify that this still works (--repeat 2 on ext/phar should do it I think)? IIRC the FILE_EXTERNAL section gets dropped during processing and can't be checked here anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed by removing the unset(), it's not needed for anything.

if ($this->hasSection('REDIRECTTEST')) {
if ($inRedirect) {
throw new BorkageException("Can't redirect a test from within a redirected test");
}
Copy link
Member

Choose a reason for hiding this comment

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

Early return here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

run-tests.php Outdated

public function getSection(string $name): string
{
return $this->sections[$name] ?? throw new Exception("Section $name not found");
Copy link
Member

Choose a reason for hiding this comment

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

This is only valid in PHP 8.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

This moves a bunch of code outside of run_tests(), making it a bit
more manageable. Additionally, accessors provide better readability
than isset() and friends.

This is a minimal patch that moves the code but does not refactor
much. For the sake of reviewing experience, it does not involve
further refactoring which could include:
* Removing setSection()
* Fixing up the mess with hasSection() vs. sectionNotEmpty(), only
  one of which is really needed.
* Moving more repetitive code into the new class.
All of this will be done with later commits.
@php-pulls php-pulls closed this in 9140c90 Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants