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

Adds --passthru and --passthru-php options. Adds --verbose option. #361

Merged
merged 4 commits into from Jan 25, 2019

Conversation

paslandau
Copy link

Fixes #360 and #354

Copy link
Member

@andreasschroth andreasschroth left a comment

Choose a reason for hiding this comment

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

I left a few comments, maybe you can have a look first, before I merge it.

And thanks for the great PR, it's an often requested, very useful feature.

*
* @return $this
*/
public function run(string $binary, array $options = [], array $environmentVariables = [])
public function run(string $binary, array $options = [], array $environmentVariables = [], string $passthru = null, string $passthruPhp = null)
Copy link
Member

Choose a reason for hiding this comment

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

Imo, the param type declaration needs to be ?string, otherwise it wouldn't be possible to pass (theoretically, when method is called in PHP code) null as $passthru and then set $passthruPhp.

Copy link
Author

Choose a reason for hiding this comment

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

The ? prefix was introduced in 7.1 (7.0 didn't have nullable types). We were stuck on 7.0 for quite some time so I'm still used to doing it like that ;)

But I just checked the composer.json of paratest and the PHP version is >= 7.1 so I'll fix that.

*
* @return string
*/
protected function getFullCommandlineString($binary, $options, string $passthru = null, string $passthruPhp = null)
Copy link
Member

Choose a reason for hiding this comment

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

Same here, I think param type needs to be ?string for $passthru and $passthruPhp.

* @param array $options command line options
* @param string $binary executable binary name
* @param array $options command line options
* @param null $passthru
Copy link
Member

Choose a reason for hiding this comment

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

I guess this should be string|null?

{
// The order we add stuff into $arguments is important
$arguments = [$binary];
// Note:
// the arguments MUST come last and we need to "somehow"
// mere the passthru string in there.
Copy link
Member

Choose a reason for hiding this comment

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

Typo? Should be "merge", right?

// Note:
// '--log-junit' '/tmp/PT_LKnfzA'
// is appended by default where PT_LKnfzA is randomly generated - so we remove it from the resulting command
$command = preg_replace("# '--log-junit' '[^']+?'#", '', $command);
Copy link
Member

Choose a reason for hiding this comment

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

OK nice, very strict way to test the result. 👍 (Personally I guess I would have just used assertContains here.)

Copy link
Author

Choose a reason for hiding this comment

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

I would actually like to make the '--log-junit' '/tmp/PT_LKnfzA part configurable in ExecutableTest but that would probably be a bigger refactoring :)

As for "strictness": I try to avoid "contains" as it opens up the assertion for "unwanted" side effects + in this case I would need two assertions instead of one.

@paslandau
Copy link
Author

@andreasschroth

If this gets merged I would add a small write-up to the docu on how to get code code coverage running with paratest:

  • preparing the phpunit.xml (incorrect whiltelist is often a problem)
  • using php dbg
  • using xdebug
  • using phpunit's --prepend filter

@andreasschroth andreasschroth merged commit 5608d0a into paratestphp:master Jan 25, 2019
@andreasschroth
Copy link
Member

Thanks a lot @paslandau for the PR, perfect now! Got merged.

Better docs would be awesome as I can see some devs having problems how to get it properly set up.

If you plan further PRs with new features, please let me know, otherwise I would tag a new version soon (maybe after the docs write-up?).

@paslandau
Copy link
Author

paslandau commented Jan 25, 2019

@andreasschroth docs done => #362 located under docs/code-coverage.md

Should be the last one for now - would appreciate a new version!

/edit
Ok, one more #363 - but now I'm done :P

@andreasschroth
Copy link
Member

@paslandau Thank you! Awesome work. I just tagged Version 2.2.0, so everyone can make use of the latest improvements.

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

Successfully merging this pull request may close these issues.

None yet

2 participants