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

Allow relative path for tmpDir config setting. #151

Merged
merged 6 commits into from
Feb 6, 2018

Conversation

maks-rafalko
Copy link
Member

@maks-rafalko maks-rafalko commented Feb 3, 2018

  • Allow relative path for tmpDir config setting.
  • Fix bug with e2e tests with checking $PHPDBG env var.
  • Update documentation with new relative feature (infection/site@f5462d3)

@maks-rafalko maks-rafalko added this to the 0.8.0 milestone Feb 3, 2018
*
* @return bool
*/
public function isAbsolutePath(string $file): bool
Copy link
Member

Choose a reason for hiding this comment

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

is this a time to add a new dependency? :D

Copy link
Member Author

Choose a reason for hiding this comment

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

lol, expected question. I still don't know.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's time to, it's the 3rd method we are copy-pasting from it :) Besides it's not like filesystem is a huge dependency, it's quite slim and don't change much

Copy link
Member

Choose a reason for hiding this comment

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

@borNfreee let's do this. If you don't want to do it in the current PR let's do it as separate.

Copy link
Member Author

Choose a reason for hiding this comment

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

got it, I will do it in this PR

@sidz
Copy link
Member

sidz commented Feb 3, 2018

could you please check travis ^^?

return $this->config->tmpDir ?? sys_get_temp_dir();
$tmpDir = $this->config->tmpDir ?? sys_get_temp_dir();

if ($this->filesystem->isAbsolutePath($tmpDir)) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd say that we don't need to execute this line for sys_get_temp_dir.

so it's actually only when $this->config->tmpDir is not empty

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if [[ $PHPDBG=1 ]]
if [ "$PHPDBG" = "1" ]
Copy link
Member

Choose a reason for hiding this comment

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

what was the issue? on linux it works fine

Copy link
Member Author

Choose a reason for hiding this comment

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

on macos it was always true

Copy link
Member

Choose a reason for hiding this comment

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

I couldn't reproduce it, might be a different shell (I'm using zsh), but in any case it's better to compare strings in bash

Copy link
Member Author

Choose a reason for hiding this comment

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

if [[ $PHPDBG=1 ]] does not work on Terminal app in MacOS (while works on zsh). See image below. Also, if [[ $PHPDBG=1 ]] is not the same as if [[ $PHPDBG = 1 ]]

phpdbg

@maks-rafalko
Copy link
Member Author

maks-rafalko commented Feb 3, 2018

could you please check travis ^^?

seems like something wrong with PHPCSFixer. New version has been downloaded on Travis and it wants to remove blank line after license, while we have

'header_comment' => [
            'commentType' => 'PHPDoc',
            'header' => $header,
            'location' => 'after_open',
            'separate' => 'bottom', <-------
        ],

Conflict between header_comment.separate style and no_blank_lines_after_phpdoc :|

@@ -251,6 +258,17 @@ function ($excludeDir) use ($srcDir) {

public function getTmpDir(): string
{
return $this->config->tmpDir ?? sys_get_temp_dir();

Copy link
Member

Choose a reason for hiding this comment

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

remove additional new line

@@ -251,6 +258,17 @@ function ($excludeDir) use ($srcDir) {

public function getTmpDir(): string
{
return $this->config->tmpDir ?? sys_get_temp_dir();

if (empty($this->config->tmpDir)) {
Copy link
Member

Choose a reason for hiding this comment

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

maybe we need to throw an exception for case when "tmpDir": "" instead of use sys_temp_dir? what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's better to continue working if we can rather than throw an exception.

I mean even if we throw an exception here, Infection should fall back to sys_temp_dir since this is not critical mistake and does not block mutation testing. WDYT?

Copy link
Member

@sidz sidz Feb 3, 2018

Choose a reason for hiding this comment

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

imho to be user friendly we need to show warning message in this case if we don't want to throw an exception. (it's not easy to do it right now)
so feel free to leave it as is

p.s. could we update documentation to include this case?

Copy link
Member Author

Choose a reason for hiding this comment

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

forgot about it, will do, thank you

@maks-rafalko
Copy link
Member Author

Created an issue in PHPCSFixer repo about failures on Travis with the new downloaded 2.10.1 version: PHP-CS-Fixer/PHP-CS-Fixer#3503

*
* @return bool
*/
public function isAbsolutePath(string $file): bool
Copy link
Member

Choose a reason for hiding this comment

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

I think it's time to, it's the 3rd method we are copy-pasting from it :) Besides it's not like filesystem is a huge dependency, it's quite slim and don't change much

@@ -0,0 +1,20 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

we're using 4 spaces in other files aren't we?

"Namespace_\\Test\\": "tests/"
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

missing line return

backupStaticAttributes="false"
bootstrap="./vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
Copy link
Member

Choose a reason for hiding this comment

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

aren't those the default? You can easily find out with phpstorm and adding xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.4/phpunit.xsd" e.g. https://github.com/humbug/box/blob/master/phpunit.xml.dist#L3


use Namespace_\SourceClass;

class SourceClassTest extends \PHPUnit\Framework\TestCase
Copy link
Member

Choose a reason for hiding this comment

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

Not a big deal but I find better to be consistent and import this class with a use statement?

@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if [[ $PHPDBG=1 ]]
if [ "$PHPDBG" = "1" ]
Copy link
Member

Choose a reason for hiding this comment

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

I couldn't reproduce it, might be a different shell (I'm using zsh), but in any case it's better to compare strings in bash

@maks-rafalko
Copy link
Member Author

maks-rafalko commented Feb 5, 2018

All comments addressed, including documentation. Please review again 😋

I decided to keep IOException since a like named constructors implemented in our version

@@ -0,0 +1,12 @@
{
"timeout": 25,
Copy link
Member

Choose a reason for hiding this comment

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

4 spaces :P

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@maks-rafalko maks-rafalko merged commit c0cd06c into master Feb 6, 2018
@maks-rafalko maks-rafalko deleted the relative-tmp-dir branch February 6, 2018 19:28
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