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 key separator #308

Merged

Conversation

titouanmathis
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
Fixed tickets #307

This PR introduces a more specific separator for the tests keys to avoid matching a potential folder name. The separator is changed from @ to @@@@ as it has more chance to not match anything in the test file absolute path. Maybe this value could be more complex?

@owenvoke
Copy link
Member

owenvoke commented Jun 3, 2021

Could probably do something like @@pest@@ as the separator. Although, it's unlikely @@@@ would be taken anyway. Interesting use of @ in your directories, not seen that before. 👍🏻

@lukeraymonddowning
Copy link
Member

I agree with @owenvoke that if we're making it specific, we might as well make it really specific.

@lukeraymonddowning
Copy link
Member

lukeraymonddowning commented Jun 3, 2021

@nunomaduro @owenvoke

This raises another interesting point.

Screenshot 2021-06-03 at 09 22 07

Note that the runner doesn't include the @ symbol. This makes sense, because it is removed in the TestCaseFactory on line 188 so that it can be a valid namespace. Do we include an 'escaped' replacement value for certain valid path symbols, such as '@' to 'AtSymbol'?

I'm not saying that we necessarily should, but its definitely a point worth raising.

@lukeraymonddowning
Copy link
Member

lukeraymonddowning commented Jun 3, 2021

For the separator, how about using >>>? > is a reserved symbol on Windows computers, so it is pretty much guaranteed that there will not be a directory including that symbol, but it also still conveys the idea of relationship between the test case and the individual test.

This then also solves the unlikely but possible situation of a folder with 4 '@' symbols.

@titouanmathis
Copy link
Contributor Author

>>> should work and its connotation of the relationship is definitely a plus. I tested a line break as a separator, it seems to work as well, but I am not sure of its compatibility.

Let me know what you prefer, I will update my PR.

@lukeraymonddowning
Copy link
Member

Let's go with >>>. If Nuno or Owen disagree, its not a major thing to alter 👍


uses(MyFailingCustomClassTest::class);

test('custom traits can be used', function () {
Copy link
Member

Choose a reason for hiding this comment

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

This TestCase is no longer needed and will actually fail completely after the change to >>>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just updated the tests to include >>> in the folder name, as it seems to work on macOS. I think that keeping the test can help people having the same issue when they have some strange folder names as I had.

Copy link
Member

@lukeraymonddowning lukeraymonddowning Jun 3, 2021

Choose a reason for hiding this comment

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

Out of interest, what would happen if you attempted to pull this repo on a Windows machine? Seen as > is a forbidden character.

@owenvoke
Copy link
Member

owenvoke commented Jun 3, 2021

Using >>> sounds fine to me. 👍🏻 Ah, as we checkout the tests on Windows, it will fail to checkout that directory (see the failing CI runs). I think we probably should use @@pest@@ then (or something), as long as that's supported in Windows names.

@lukeraymonddowning
Copy link
Member

@owenvoke I don't think it needs that, we just don't need the test class with >>> in the title. No developer can ever use > in a directory if they ever plan on supporting windows platforms, which is why I suggested it. That makes the test case unnecessary. Hope that makes some sort of sense.

@owenvoke
Copy link
Member

owenvoke commented Jun 3, 2021

@lukeraymonddowning I guess that could be removed, same with the one ending in >, just wasn't sure if we needed at least one test with the separator in. 🤔 Probably not, as you said.

@titouanmathis
Copy link
Contributor Author

I removed the tests, this PR will keep the history of the bug in case anyone has some >>> in their folder path.

@lukeraymonddowning
Copy link
Member

lukeraymonddowning commented Jun 3, 2021

Lol, sorry @titouanmathis

It would make sense to me to keep the first test, but have the @ symbol in the directory, which was the original issue. But there is no need to have a test case with the > symbol in a directory because if they have that in their project, Pest is going to be the least of their problems.

@titouanmathis
Copy link
Contributor Author

Haha, my bad, I will re-add the first test 👍

@nunomaduro
Copy link
Member

@lukeraymonddowning Tests are not passing. But once tests are passing, feel free to merge and to release.

A release requires changes on the changelog + 9133b88.

@titouanmathis
Copy link
Contributor Author

I added the output of the 2 new tests to the success.txt snapshot, the integration tests should pass now.

@lukeraymonddowning lukeraymonddowning merged commit cdc3bd3 into pestphp:master Jun 7, 2021
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.

4 participants