Repository navigation
feat(Cache): add file Cache.Lean with helper functions and cleanup checkForToolchainMismatch - #21663
joneugster wants to merge 10 commits into
Conversation
PR summary 0030317f89Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
| -- unit tests for `System.FilePath.clean` | ||
| #guard FilePath.clean "" == "" | ||
| #guard FilePath.clean "." == "" | ||
| #guard FilePath.clean ("." / ".") == "" | ||
| #guard FilePath.clean ("." / "") == "" | ||
| #guard FilePath.clean ("." / "A") == "A" | ||
| #guard FilePath.clean ("." / "..") == ".." | ||
| #guard FilePath.clean (".." / "..") == (".." / "..") | ||
| #guard FilePath.clean ("A" / ".." / "B") == "B" | ||
| #guard FilePath.clean ("A" / "." / "B") == ("A" / "B") | ||
| #guard FilePath.clean ("A" / "B" / "C" / ".." / ".." / ".." / "..") == ".." | ||
| #guard FilePath.clean ("A" / "B" / "C" / ".." / ".." / "." / ".." / "..") == ".." | ||
| #guard FilePath.clean ("A" / "B" / "C" / ".." / ".." / ".." / "D") == "D" |
There was a problem hiding this comment.
Is there a better place to put tests?
a7ade54 to
ef94142
Compare
Cache.Lean with helper functions
Cache.Lean with helper functionsCache.Lean with helper functions and cleanup checkForToolchainMismatch
| #guard FilePath.clean "." == "" | ||
| #guard FilePath.clean ("." / ".") == "" | ||
| #guard FilePath.clean ("." / "") == "" |
There was a problem hiding this comment.
These make me unconfortable; I'd expect the first two to return ., and the second one seems nonsensical since "" isn't a legal path component
There was a problem hiding this comment.
FilePath itself makes me uncomfortable:
#eval mkFilePath [] |>.components -- result: [""]But I'll change it, using . is probably the better convention
There was a problem hiding this comment.
and the second one seems nonsensical since
""isn't a legal path component
As far as I understand the current implementation of FilePath, "" and "." are considered equivalent and "" might appear in a (uncleaned) path like ././A//B/./C//X.lean
| | "" :: path => go path | ||
| | c :: path => c :: go path | ||
|
|
||
| -- unit tests for `System.FilePath.clean` |
There was a problem hiding this comment.
Can you add a test for this POSIX spec:
A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.
That is, //foo/bar///baz should normalize to //foo/bar/baz.
| #guard FilePath.clean ("." / ".") == "." | ||
| #guard FilePath.clean ("." / "") == "." | ||
| #guard FilePath.clean ("." / "A") == "A" | ||
| #guard FilePath.clean ("" / "..") == ".." |
There was a problem hiding this comment.
Haven't you incorrectly replaced /.. with .. here?
There was a problem hiding this comment.
Next attempt. Would you mind having a look if this implementation is better. It should now treat leading / and // better.
I haven't yet thought about whether there is anything windows-specific that needs to be considered...
|
This PR/issue depends on:
|
|
Update: Now I had an idea to avoid this completely. I'll add |
Move helper functions to
Cache.Leanand addFilePath.cleanCache.Lean#21816Note: a future PR will remove
isMathlibRootcompletely, so we do the first step here.