Bug 225476 - Add API test for FileSystem::fileExists() on a broken symbolic link
Summary: Add API test for FileSystem::fileExists() on a broken symbolic link
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-06 12:13 PDT by Chris Dumez
Modified: 2021-05-06 16:14 PDT (History)
5 users (show)

See Also:


Attachments
Patch (2.37 KB, patch)
2021-05-06 12:17 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2021-05-06 12:13:21 PDT
Add API test for FileSystem::fileExists() on a broken symbolic link.
Comment 1 Chris Dumez 2021-05-06 12:17:57 PDT
Created attachment 427918 [details]
Patch
Comment 2 Darin Adler 2021-05-06 13:09:34 PDT
Comment on attachment 427918 [details]
Patch

Should also add one for a non-broken symlink *to* a broken symlink
Comment 3 Chris Dumez 2021-05-06 13:11:10 PDT
(In reply to Darin Adler from comment #2)
> Comment on attachment 427918 [details]
> Patch
> 
> Should also add one for a non-broken symlink *to* a broken symlink

For what it's worth FileSystem::exists() for a symlink to a *non-broken* symlink seems to return false. I have noticed this today. I will try and figure out why but the good? news is that it seems this is not new behavior from porting to std::filesystem.
Comment 4 Darin Adler 2021-05-06 13:26:34 PDT
I suppose all these test cases show why we’d rather *not* have our own file system layer. But the convenience of using WTF::String directly is so tempting.
Comment 5 Chris Dumez 2021-05-06 13:27:07 PDT
Comment on attachment 427918 [details]
Patch

Clearing flags on attachment: 427918

Committed r277113 (237411@main): <https://commits.webkit.org/237411@main>
Comment 6 Chris Dumez 2021-05-06 13:27:10 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2021-05-06 13:28:19 PDT
<rdar://problem/77622567>
Comment 8 Chris Dumez 2021-05-06 13:32:51 PDT
(In reply to Darin Adler from comment #4)
> I suppose all these test cases show why we’d rather *not* have our own file
> system layer. But the convenience of using WTF::String directly is so
> tempting.

I personally don't mind having our own FileSystem layer with WTF::String convenience and some other small niceties, as long as we keep the WTF::FileSystem layer cross-platform & small (by leveraging std::filesystem) and with a good set of tests.

The issue in my opinion was that we had 3 separate implementations with slightly different behaviors and almost no tests.
Comment 9 Chris Dumez 2021-05-06 15:55:58 PDT
(In reply to Chris Dumez from comment #3)
> (In reply to Darin Adler from comment #2)
> > Comment on attachment 427918 [details]
> > Patch
> > 
> > Should also add one for a non-broken symlink *to* a broken symlink
> 
> For what it's worth FileSystem::exists() for a symlink to a *non-broken*
> symlink seems to return false. I have noticed this today. I will try and
> figure out why but the good? news is that it seems this is not new behavior
> from porting to std::filesystem.

access() on a symlink to a valid symlink returns -1 and errno is 2, which is:
[ENOENT]           The named file does not exist.
Comment 10 Chris Dumez 2021-05-06 16:06:58 PDT
(In reply to Chris Dumez from comment #9)
> (In reply to Chris Dumez from comment #3)
> > (In reply to Darin Adler from comment #2)
> > > Comment on attachment 427918 [details]
> > > Patch
> > > 
> > > Should also add one for a non-broken symlink *to* a broken symlink
> > 
> > For what it's worth FileSystem::exists() for a symlink to a *non-broken*
> > symlink seems to return false. I have noticed this today. I will try and
> > figure out why but the good? news is that it seems this is not new behavior
> > from porting to std::filesystem.
> 
> access() on a symlink to a valid symlink returns -1 and errno is 2, which is:
> [ENOENT]           The named file does not exist.

Oh, it was an issue with the way FileSystemTest::SetUp() was constructing the symlink. I'll fix that and add more tests shortly.