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

Support symlinked test files - fixes #1143 #1145

Merged
merged 7 commits into from
Dec 17, 2016

Conversation

rnkdev
Copy link
Contributor

@rnkdev rnkdev commented Dec 6, 2016

Fixes #1143

Following from the bug thread, I modified api.js hashmap preparation so that it uses resolved path as the key. I also added one test to ensure that ava can now be ran with linked test file.

@rnkdev rnkdev changed the title Symlinkpatch Hashmap now uses resolved path #1143 Dec 6, 2016
@rnkdev
Copy link
Contributor Author

rnkdev commented Dec 6, 2016

Hmm it seems that it fails the test for Windows. I'm not sure how to handle the symlink in it.

Edit: it passes all of the test in Windows with the exception of my new test to check whether the symlink is working or not.

@rnkdev
Copy link
Contributor Author

rnkdev commented Dec 6, 2016

After some research, I think what I could do is I can add check to the test not to be run (or to be automatically passed) if the environment is detected to be Windows. But I'm not sure if it's the right approach considering Windows has no symlink support.

Copy link
Member

@novemberborn novemberborn left a comment

Choose a reason for hiding this comment

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

After some research, I think what I could do is I can add check to the test not to be run (or to be automatically passed) if the environment is detected to be Windows. But I'm not sure if it's the right approach considering Windows has no symlink support.

It does, actually! http://stackoverflow.com/questions/11662868/what-happens-when-i-clone-a-repository-with-symlinks-on-windows has details. I've pushed a commit to your branch which enables symlink support in our AppVeyor builds.

PR looks good, would just like the test to be more explicit.


var api = apiCreator();

return api.run([path.join(__dirname, 'fixture/symlink')])
Copy link
Member

Choose a reason for hiding this comment

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

What you're passing here are patterns that the API then resolves to actual test files. In this case the pattern is a symlink, and the API needs to resolve tests within the directory it's pointing at.

Could you add another test where you provide a symlink to a test file? The API should use that path as-is, whereas if you provide a (symlinked) directory other code gets in between which may decide to resolve the path for us.

@rnkdev
Copy link
Contributor Author

rnkdev commented Dec 6, 2016

Thanks for adding that support for Windows!

On the other hand, there is a new problem, when I added new direct symlink to a test file in the test, it fails to recognise that file exist.

It throws AvaError: Couldn't file any files to teststrangely. Normally you would think if it can resolve a symlink to a directory, it should resolve symlink to a file as well.

The following commit shows the problem. It stops before even calling precompilation and Api._runFile

@rnkdev
Copy link
Contributor Author

rnkdev commented Dec 6, 2016

So I copied the same tests to the ava master branch. Surprisingly it failed all of the tests including the one that points to directory.

In a sense this fix fixes problem #1143 #1137 as the user is trying to do a symlink to a directory containing test files.

But then it also uncovers that direct symlink is somehow can't be resolved. (Maybe it has something to do with how files are searched in ava-files)

@novemberborn
Copy link
Member

On the other hand, there is a new problem, when I added new direct symlink to a test file in the test, it fails to recognise that file exist.

You need to make sure it has the .js extension.

Let's keep the test for symlinked directories, but also add one for symlinked files.

@rnkdev
Copy link
Contributor Author

rnkdev commented Dec 8, 2016

Hi I just added the last commit with the requested change. (My bad for not researching that .js part) Is there anything else I should do to get the PR accepted? Thanks.

Copy link
Member

@novemberborn novemberborn left a comment

Choose a reason for hiding this comment

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

Hi I just added the last commit with the requested change. (My bad for not researching that .js part) Is there anything else I should do to get the PR accepted? Thanks.

Looks great to me! @avajs/core any thoughts on the symlink handling here?

@sindresorhus sindresorhus changed the title Hashmap now uses resolved path #1143 Support symlinked test files - fixes #1143 Dec 17, 2016
@sindresorhus sindresorhus merged commit 033d4dc into avajs:master Dec 17, 2016
@sindresorhus
Copy link
Member

Looks good to me too. Nice work @rnkdev :)

@mastilver
Copy link

@rnkdev Thank you so much for your work 👍

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.

AVA fails when running test files which are actually symlinks
4 participants