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

Improve tests for ln -s with relative source arguments #835

Open
nfischer opened this issue Apr 6, 2018 · 1 comment
Open

Improve tests for ln -s with relative source arguments #835

nfischer opened this issue Apr 6, 2018 · 1 comment

Comments

@nfischer
Copy link
Member

nfischer commented Apr 6, 2018

Also inspired by #833.

ln -s is weird in that the semantics differ depending on whether it's given a relative path or an absolute path. For example:

$ touch file.txt
$ mkdir dir/
$ # Create a link, with an absolute path
$ ln -s "$PWD/file.txt" absoluteLink # ./absoluteLink is non-broken
$ mv absoluteLink dir/ # ./dir/absoluteLink is still non-broken
$ # Create a link, with a relative path
$ ln -s ./file.txt relativeLink # ./relativeLink is currently non-broken
$ mv relativeLink dir/ # But now ./dir/relativeLink is broken

I think shelljs does the right thing, but I'm not sure if our tests obviously handle this.

We should also consider making this explicit, but adding a utility function like utils.symlinkIsBroken(pathToLink).

@nfischer
Copy link
Member Author

nfischer commented Apr 6, 2018

Another thought regarding code coverage: how good is our coverage for other utilities handling broken links? For example, does rm('-r') do the right thing if there's a broken link in the folder? What about cp('some-real-file', 'broken-link')?

We might consider making a utility function called utils.createBrokenLink(), which creates a broken link and returns the name. Ideally, this should create the link in the tempdir (it probably needs an argument for that).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant