-
Notifications
You must be signed in to change notification settings - Fork 64
Support path resolution #228
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -336,7 +336,40 @@ class SmokeFileTest { | |
} | ||
assertEquals("second third", | ||
SystemFileSystem.source(path).buffered().use { it.readString() }) | ||
} | ||
|
||
@Test | ||
fun resolve() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I need to add more tests: to check for an exception if the path does not exist, to check for an absolute path, etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the test for absolute path, all other cases are already there. It would be nice to test symlink resolution, but we don't have an API for links yet. |
||
assertFailsWith<FileNotFoundException>("Non-existing path resolution should fail") { | ||
SystemFileSystem.resolve(createTempPath()) | ||
} | ||
|
||
val cwd = SystemFileSystem.resolve(Path(".")) | ||
val parentRel = Path("..") | ||
assertEquals(cwd.parent, SystemFileSystem.resolve(parentRel)) | ||
|
||
assertEquals(cwd, SystemFileSystem.resolve(cwd), | ||
"Absolute path resolution should not alter the path") | ||
|
||
// root | ||
// |-> a -> b | ||
// |-> c -> d | ||
val root = createTempPath() | ||
SystemFileSystem.createDirectories(Path(root, "a", "b")) | ||
val tgt = Path(root, "c", "d") | ||
SystemFileSystem.createDirectories(tgt) | ||
|
||
val src = Path(root, "a", "..", "a", ".", "b", "..", "..", "c", ".", "d") | ||
try { | ||
// root/a/../a/./b/../../c/./d -> root/c/d | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
assertEquals(SystemFileSystem.resolve(tgt), SystemFileSystem.resolve(src)) | ||
} finally { | ||
// TODO: remove as soon as recursive file removal is implemented | ||
SystemFileSystem.delete(Path(root, "a", "b")) | ||
SystemFileSystem.delete(Path(root, "a")) | ||
SystemFileSystem.delete(Path(root, "c", "d")) | ||
SystemFileSystem.delete(Path(root, "c")) | ||
} | ||
} | ||
|
||
private fun constructAbsolutePath(vararg parts: String): String { | ||
|
Uh oh!
There was an error while loading. Please reload this page.