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

Fixes the issue with paths in `groups` section when `codeception.yaml` is not in the root of the project #5674

Merged
merged 6 commits into from Sep 10, 2019

Conversation

@maks-rafalko
Copy link
Contributor

commented Sep 8, 2019

  • Fixes the issue with paths in groups section when codeception.yaml is not in the root of the project
  • Add an ability to use absolute path for groups key in codeception.yaml

Example:

Imagine, custom codeception.yaml is located inside tests/_data folder.

We run codeception as

codecept -g x -c tests/_data/codeception.yaml

And we have the following group:

groups:
    x:
        ../../tests/unit/SomeTest.php

Such path is resolved to /path/to/project/tests/_data/../../tests/unit/SomeTest.php
and GroupManager.php can not match this path with the real path:

/path/to/project/tests/unit/SomeTest.php

if ($filename == $testPattern) {
$groups[] = $group;
}

Applying realpath() solves the issue, because after that paths are the same and the code above successfully matches them.

Also, I've added an ability to use absolute paths:

groups:
    x:
        /path/to/project/tests/unit/SomeTest.php

We need it to integrate Codeception with Infection.


Related to infection/infection#45

Also, use `realpath()` to make it possible to correctly use paths to files
from the `codeception.yaml` located not in the root of the project.

Example:

Imagine, custom `codeception.yaml` is located inside `tests/_data` folder.

We run codeception as

```bash
codecept -g x -c tests/_data/codeception.yaml
```

And we have the following group:

```yaml
groups:
    x:
        ../../tests/unit/SomeTest.php
```

Such path is resolved to `/path/to/project/tests/_data/../../tests/unit/SomeTest.php`
and `GroupManager.php` can not match this path with the real path:

```
/path/to/project/tests/unit/SomeTest.php
```

Applying `realpath()` solves the issue.
@maks-rafalko

This comment has been minimized.

Copy link
Contributor Author

commented Sep 8, 2019

To be honest, have no idea how to fix the tests, because when I try to var_dump() anything in tests/unit/Codeception/Lib/GroupManagerTest.php, it's not being displayed to the console :|

I would appreciate any help / advice here.

@Naktibalda

This comment has been minimized.

Copy link
Member

commented Sep 8, 2019

@maks-rafalko try using codecept_debug instead of var_dump in tests and run codeception with -vv or -vvv flag to see it.

I think that these tests could be failing because they use made-up file names, so realfile returns false - https://github.com/Codeception/Codeception/blob/3.1/tests/unit/Codeception/Lib/GroupManagerTest.php#L15-L49

maks-rafalko added 2 commits Sep 8, 2019
… code to handle paths with method names
tests/data/UserTest.php Outdated Show resolved Hide resolved
maks-rafalko added 2 commits Sep 8, 2019
…anagerTest.php
@maks-rafalko

This comment has been minimized.

Copy link
Contributor Author

commented Sep 8, 2019

@Naktibalda I have resolved your comments and tests are green

@DavertMik

This comment has been minimized.

Copy link
Member

commented Sep 10, 2019

Thank you, @maks-rafalko !
Let's have it merged. I hope we will make a release very soon

@DavertMik DavertMik merged commit 9280cd9 into Codeception:3.1 Sep 10, 2019
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
semaphoreci The build passed on Semaphore.
Details
@maks-rafalko

This comment has been minimized.

Copy link
Contributor Author

commented Sep 10, 2019

Thank you both

@maks-rafalko maks-rafalko deleted the maks-rafalko:bugfix/paths-for-groups branch Oct 1, 2019
@maks-rafalko maks-rafalko referenced this pull request Oct 2, 2019
2 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.