Skip to content

Implement dataset parallelization with -f flag - #755

Closed
danog wants to merge 11 commits into
paratestphp:7.xfrom
nicelocal:7.x
Closed

Implement dataset parallelization with -f flag#755
danog wants to merge 11 commits into
paratestphp:7.xfrom
nicelocal:7.x

Conversation

@danog

@danog danog commented May 2, 2023

Copy link
Copy Markdown

Brings back the feature that was removed in the phpunit 10 update.

@Slamdunk Slamdunk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for proposing this. A couple of changes are required 💪

Comment thread src/WrapperRunner/SuiteLoader.php Outdated
$files[$file] = null;

if ($test instanceof TestCase) {
$name = str_replace(' with data set ', '', $test->nameWithDataSet());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unfortunately this doesn't work for both numeric and string data names.
PHPUnit\Runner\Filter\Factory needs:

  1. testName#1 for numeric names
  2. testName with data set "foo" for string names

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

looks like we could just use $name = $test->nameWithDataSet());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Guite no: nameWithDataSet outputs testDataProvider1 with data set #0 for numeric names, and that doesn't work with --filter

Comment thread test/TestBase.php Outdated
putenv(Options::ENV_KEY_UNIQUE_TOKEN . '=' . $prevUniqueToken);
$_SERVER[Options::ENV_KEY_TOKEN] = $prevToken;
$_SERVER[Options::ENV_KEY_UNIQUE_TOKEN] = $prevUniqueToken;
$last = null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please restore the original code here, and add a new dedicated test for the --functional option, with both numeric data names and string data names

@Guite

Guite commented May 11, 2023

Copy link
Copy Markdown

Looking forward to this one.

@cuberinooo

Copy link
Copy Markdown

Would love to see this feature back again :)

@Slamdunk

Copy link
Copy Markdown
Member

Help @danog resolving the requested changes and we are ready to go 💪

@danog

danog commented May 11, 2023

Copy link
Copy Markdown
Author

Whoops sorry completely forgot about this PR, will apply the required changes this weekend!

Comment thread test/fixtures/function_parallelization_tests/FunctionalParallelizationTest.php Outdated
Comment thread composer.json
@Guite

Guite commented May 26, 2023

Copy link
Copy Markdown

If you think this is feature complete please leave a comment. I will then re-test it and report our experience.

@danog

danog commented May 26, 2023

Copy link
Copy Markdown
Author

Yeah it's ready, I just can't figure out why are the tests failing (with different errors when running on local, too)

$this->bareOptions['-f'] = true;

$runnerResult = $this->runRunner();
self::assertEquals(0, $runnerResult->exitCode);

@Slamdunk Slamdunk May 26, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Currently this test is poorly written: executing ./bin/paratest --no-configuration -f test/fixtures/function_parallelization_tests/FunctionalParallelizationTest.php only runs 3 tests instead of 6, because of #755 (comment)

Please:

  1. Add a specific assertion on the number of tests expected to be run, six
  2. Compose the test name with \PHPUnit\Framework\TestCase::dataName API, and use # for int and @ for string

@oprudkyi

oprudkyi commented Jun 5, 2023

Copy link
Copy Markdown

Hi @danog

I've tried to check PR, it seems the count is wrong

..........................................                        42 / 42 (100%)
. 43 / 42 (102%)
. 44 / 42 (104%)
. 45 / 42 (107%)
. 46 / 42 (109%)

@Slamdunk

Slamdunk commented Jun 6, 2023

Copy link
Copy Markdown
Member

@oprudkyi maybe see #742

@Slamdunk

Copy link
Copy Markdown
Member

This PR needed some few more tweaks that I addressed in #770 (I could have done it here, if the changes were presented as a separate branch in @danog fork):

  1. Fix for Implement dataset parallelization with -f flag #755 (comment)
  2. A fix for PHPT files
  3. A workaround for Implement dataset parallelization with --functional flag #770 (comment)

I've also removed the support for -f shortcut, leaving --functional only because -f may be used in the future by PHPUnit.

But all in all, thank you for this PR 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants