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

fix(test): exit code of lime test -- add proof of current behaviour #371

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

alquerci
Copy link
Contributor

@alquerci alquerci commented Apr 9, 2024

@alquerci alquerci force-pushed the fix-test-exit-code-of-lime-test-add-proof-of-current-behaviour branch from fc4dbef to 04d0339 Compare April 9, 2024 22:53
@alquerci alquerci changed the title [WIP] fix(test): exit code of lime test -- add proof of current behaviour fix(test): exit code of lime test -- add proof of current behaviour Apr 9, 2024
@alquerci alquerci marked this pull request as ready for review April 9, 2024 22:54
Copy link
Collaborator

@connorhu connorhu left a comment

Choose a reason for hiding this comment

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

Clear and understandable. Thank you!

@@ -1186,8 +1199,7 @@ public function process($files)
EOF;
file_put_contents($tmp_file, $tmp);
ob_start();
// see http://trac.symfony-project.org/ticket/5437 for the explanation on the weird "cd" thing
Copy link
Collaborator

Choose a reason for hiding this comment

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

[PATCH] lime.php not working on windows when there are spaces in php interpreter path

lime.php, line 541

passthru(sprintf('%s "%s" 2>&1', $this->php_cli, $file), $return);

the command fails if the path to php interpreter contains spaces, this obviously prevent all test to run.

In order to work with executables in directories with spaces it should be

passthru(sprintf('"%s" "%s" 2>&1', $this->php_cli, $file), $return);

but this fails too on windows: system/exec/passthru all fail when more than two arguments are quoted (it seems a php bug but I couldn't find any reference apart from some comments on the system function page)

In order to work on windows it should be written as

passthru(sprintf('""%s" "%s"" 2>&1', $this->php_cli, $file), $return);

this works on windows but still fails on linux (note the double "double quotes": I need to quote the entire command not just the executable and the argument)

The only workaround I could find was something I found on the comments of the system function that is adding a "nop" command call before the quoted command

passthru(sprintf('cd & "%s" "%s" 2>&1', $this->php_cli, $file), $return);


$test = new lime_test();

parse_error
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file should be excluded from everywhere that parses php files. At this moment php-cs-fixer, but later phpstan, rector etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

php-cs-fixer exclude all files that contain "vendor" on its path.

This means that the directory "test/unit/vendor" is ignored.

Fixing that, will requires a structural correction, that is out of scope of this PR.

@connorhu What can I do on the scope of this PR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed, you are right! For the other tools, it was just a reminder to myself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

$harness = $this->makeHarness();

$harness->register([
__DIR__."/fixtures/$name.php",
Copy link
Collaborator

@connorhu connorhu Apr 10, 2024

Choose a reason for hiding this comment

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

Suggested change
__DIR__."/fixtures/$name.php",
__DIR__.'/fixtures/'.$name.'.php',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The $name variable need to be interpreted.

Using single quotes change the behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here, I had think about passing the file path (concrete) or the name (intent).

I choose to pass the intent.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry my bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The action here is to include directory "test/unit/vendor" on php-cs-fixer configuration, then execute the fixer.

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 in 3 steps

See #371 (comment)

Comment on lines +4 to +5
require_once __DIR__.'/tools/TestCase.php';
require_once __DIR__.'/tools/lime_no_colorizer.php';
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the filename case policy in this directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as class name.

@alquerci alquerci requested a review from connorhu April 10, 2024 19:10
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.

2 participants