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

@maks-rafalko maks-rafalko 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
Copy link
Contributor Author

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
Copy link
Member

@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

tests/data/UserTest.php Outdated Show resolved Hide resolved
@maks-rafalko
Copy link
Contributor Author

@Naktibalda I have resolved your comments and tests are green

@DavertMik
Copy link
Member

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
@maks-rafalko
Copy link
Contributor Author

Thank you both

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.

None yet

3 participants